Source:
public void sendPushMessage(final Variant variant, final Collection<String> tokens, final UnifiedPushMessage pushMessage, final NotificationSenderCallback callback) { if (tokens.isEmpty()) { return; } final iOSVariant iOSVariant = (iOSVariant) variant; Message message = pushMessage.getMessage(); PayloadBuilder builder = APNS.newPayload() .alertBody(message.getAlert()) .badge(message.getBadge()) .sound(message.getSound()) .category(message.getActionCategory()); if (message.isContentAvailable()) { builder = builder.instantDeliveryOrSilentNotification(); } builder = builder.customFields(message.getUserData()); if (builder.isTooLong()) { logger.warning("Nothing sent to APNs since the payload is too large"); callback.onError("message too long for APNs"); return; } final String apnsMessage = builder.build(); ApnsService service = buildApnsService(iOSVariant, callback); if (service != null) { try { logger.fine("Sending transformed APNs payload: " + apnsMessage); service.start(); Date expireDate = createFutureDateBasedOnTTL(pushMessage.getConfig().getTimeToLive()); service.push(tokens, apnsMessage, expireDate); logger.info("Message to APNs has been submitted"); final Set<String> inactiveTokens = service.getInactiveDevices().keySet(); final Set<String> transformedTokens = lowerCaseAllTokens(inactiveTokens); if (! transformedTokens.isEmpty()) { logger.info("Deleting '" + inactiveTokens.size() + "' invalid iOS installations"); clientInstallationService.removeInstallationsForVariantByDeviceTokens(iOSVariant.getVariantID(), transformedTokens); } callback.onSuccess(); } catch (Exception e) { callback.onError("Error sending payload to APNs server: " + e.getMessage()); } finally { service.stop(); } } else { logger.severe("No certificate was found. Could not send messages to APNs"); callback.onError("No certificate for APNs was found"); } }

Target:
public void sendPushMessage(final Variant variant, final Collection<String> tokens, final UnifiedPushMessage pushMessage, final NotificationSenderCallback callback) { if (tokens.isEmpty()) { return; } final iOSVariant iOSVariant = (iOSVariant) variant; Message message = pushMessage.getMessage(); PayloadBuilder builder = APNS.newPayload() .alertBody(message.getAlert()) .badge(message.getBadge()) .sound(message.getSound()) .category(message.getActionCategory()); if (message.isContentAvailable()) { builder = builder.instantDeliveryOrSilentNotification(); } builder = builder.customFields(message.getUserData()); if (builder.isTooLong()) { callback.onError("Nothing sent to APNs since the payload is too large"); return; } final String apnsMessage = builder.build(); ApnsService service = buildApnsService(iOSVariant, callback); if (service != null) { try { logger.fine("Sending transformed APNs payload: " + apnsMessage); service.start(); Date expireDate = createFutureDateBasedOnTTL(pushMessage.getConfig().getTimeToLive()); service.push(tokens, apnsMessage, expireDate); logger.info("Message to APNs has been submitted"); final Set<String> inactiveTokens = service.getInactiveDevices().keySet(); final Set<String> transformedTokens = lowerCaseAllTokens(inactiveTokens); if (! transformedTokens.isEmpty()) { logger.info("Deleting '" + inactiveTokens.size() + "' invalid iOS installations"); clientInstallationService.removeInstallationsForVariantByDeviceTokens(iOSVariant.getVariantID(), transformedTokens); } callback.onSuccess(); } catch (Exception e) { callback.onError("Error sending payload to APNs server: " + e.getMessage()); } finally { service.stop(); } } else { callback.onError("No certificate was found. Could not send messages to APNs"); } }