aboutsummaryrefslogtreecommitdiff
path: root/juick-notifications/src/main/java/com/juick/components/Notifications.java
diff options
context:
space:
mode:
Diffstat (limited to 'juick-notifications/src/main/java/com/juick/components/Notifications.java')
-rw-r--r--juick-notifications/src/main/java/com/juick/components/Notifications.java7
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));