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; PayloadBuilder builder = APNS.newPayload() .alertBody(pushMessage.getAlert()) .badge(pushMessage.getBadge()) .sound(pushMessage.getSound()) .category(pushMessage.getActionCategory()); if (pushMessage.isContentAvailable()) { builder = builder.instantDeliveryOrSilentNotification(); } builder = builder.customFields(pushMessage.getData()); if (builder.isTooLong()) { logger.log(Level.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.log(Level.FINE, "Sending transformed APNs payload: " + apnsMessage); service.start(); Date expireDate = createFutureDateBasedOnTTL(pushMessage.getTimeToLive()); service.push(tokens, apnsMessage, expireDate); logger.log(Level.INFO, "Message to APNs has been submitted"); final Set<String> inactiveTokens = service.getInactiveDevices().keySet(); final Set<String> transformedTokens = lowerCaseAllTokens(inactiveTokens); if (! transformedTokens.isEmpty()) { logger.log(Level.INFO, "Deleting '" + inactiveTokens.size() + "' invalid iOS installations"); clientInstallationService.removeInstallationsForVariantByDeviceTokens(iOSVariant.getVariantID(), transformedTokens); } } catch (Exception e) { logger.log(Level.SEVERE, "Error sending payload to APNs server", e); callback.onError("Error sending payload to APNs server: " + e.getMessage()); } finally { service.stop(); } } else { logger.log(Level.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; PayloadBuilder builder = APNS.newPayload() .alertBody(pushMessage.getAlert()) .badge(pushMessage.getBadge()) .sound(pushMessage.getSound()) .category(pushMessage.getActionCategory()); if (pushMessage.isContentAvailable()) { builder = builder.instantDeliveryOrSilentNotification(); } builder = builder.customFields(pushMessage.getData()); if (builder.isTooLong()) { logger.log(Level.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.log(Level.FINE, "Sending transformed APNs payload: " + apnsMessage); service.start(); Date expireDate = createFutureDateBasedOnTTL(pushMessage.getTimeToLive()); service.push(tokens, apnsMessage, expireDate); logger.log(Level.INFO, "Message to APNs has been submitted"); final Set<String> inactiveTokens = service.getInactiveDevices().keySet(); final Set<String> transformedTokens = lowerCaseAllTokens(inactiveTokens); if (! transformedTokens.isEmpty()) { logger.log(Level.INFO, "Deleting '" + inactiveTokens.size() + "' invalid iOS installations"); clientInstallationService.removeInstallationsForVariantByDeviceTokens(iOSVariant.getVariantID(), transformedTokens); } } catch (Exception e) { callback.onError("Error sending payload to APNs server: " + e.getMessage()); } finally { service.stop(); } } else { logger.log(Level.SEVERE, "No certificate was found. Could not send messages to APNs"); callback.onError("No certificate for APNs was found"); } }