diff options
author | Vitaly Takmazov | 2017-10-18 02:21:27 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2017-10-18 02:21:27 +0300 |
commit | 6632a1d0828ed1bb73b19b8f61153b746240dc94 (patch) | |
tree | 5ca704f692902d75165bdf05353d834fabbd5179 /juick-notifications/src/main/java/com | |
parent | 38c743822518f832bd002a2ecc3eb1922a26456d (diff) |
notifications: format APNS notification
Diffstat (limited to 'juick-notifications/src/main/java/com')
-rw-r--r-- | juick-notifications/src/main/java/com/juick/components/Notifications.java | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/juick-notifications/src/main/java/com/juick/components/Notifications.java b/juick-notifications/src/main/java/com/juick/components/Notifications.java index 575f7460..222e3c0e 100644 --- a/juick-notifications/src/main/java/com/juick/components/Notifications.java +++ b/juick-notifications/src/main/java/com/juick/components/Notifications.java @@ -21,6 +21,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.android.gcm.server.*; import com.juick.DeviceRegistration; import com.juick.User; +import com.juick.formatters.PlainTextFormatter; import com.turo.pushy.apns.ApnsClient; import com.turo.pushy.apns.PushNotificationResponse; import com.turo.pushy.apns.util.ApnsPayloadBuilder; @@ -173,8 +174,10 @@ public class Notifications implements NotificationClientListener, AutoCloseable .map(DeviceRegistration::getToken).collect(Collectors.toList()); if (!tokens.isEmpty()) { ApnsPayloadBuilder apnsPayloadBuilder = new ApnsPayloadBuilder(); - String payload = apnsPayloadBuilder.setAlertTitle("@" + jmsg.getUser().getName()) - .setAlertBody(jmsg.getText()).buildWithDefaultMaximumLength(); + String post = PlainTextFormatter.formatPost(jmsg); + String[] parts = post.split("\n", 2); + String payload = apnsPayloadBuilder.setAlertTitle(parts[0]) + .setAlertBody(parts[1]).buildWithDefaultMaximumLength(); for (String token : tokens) { final Future<PushNotificationResponse<SimpleApnsPushNotification>> notification = apns.sendNotification(new SimpleApnsPushNotification(token, topic, payload)); |