Source:
<code>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()) <START> .alertTitle(message.getApns().getTitle()) END> .alertAction(message.getApns().getAction()) .urlArgs(message.getApns().getUrlArgs()) .category(message.getApns().getActionCategory()); if (message.getApns().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"); } }</code><technical_language>stash APns objc</technical_language>

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(); APNs apns = message.getApns(); PayloadBuilder builder = APNS.newPayload() .alertBody(message.getAlert()) .badge(message.getBadge()) .sound(message.getSound()) .alertTitle(apns.getTitle()) .alertAction(apns.getAction()) .urlArgs(apns.getUrlArgs()) .category(apns.getActionCategory()) .localizedTitleKey(apns.getLocalizedTitleKey()); if(apns.getLocalizedTitleArguments() != null) { builder .localizedArguments(apns.getLocalizedTitleArguments()); } if (apns.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"); } }