From 6632a1d0828ed1bb73b19b8f61153b746240dc94 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 18 Oct 2017 02:21:27 +0300 Subject: notifications: format APNS notification --- .../src/main/java/com/juick/components/Notifications.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'juick-notifications/src/main') 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> notification = apns.sendNotification(new SimpleApnsPushNotification(token, topic, payload)); -- cgit v1.2.3