【发布时间】:2019-01-24 07:50:00
【问题描述】:
我正在为 Ionic 3 的通知使用以下插件。
<plugin name="phonegap-plugin-push" spec="1.10.5">
对于 iOS,我可以通过在我的后端使用它来实现多行:
private static String iosMessage = "Test Alert Header\nTest Message";
ApnsService service =
APNS.newService()
.withCert(PATH_TO_P12_CERT, CERT_PASSWORD)
.withProductionDestination()
.build();
String payload = APNS.newPayload()
.alertBody(iosMessage)
.sound("default")
.build();
service.push(DEVICE_TOKEN, payload);
System.out.println("The message has been sent...");
对于安卓:
private static String title = "Message Header";
private static String message = "Message Text";
String pushMessage = "{\"priority\":\"high\",\"notification\":{\"title\":\"" +
title +
"\",\"message\":\"" +
message +
"\"},\"to\":\"" +
DEVICE_TOKEN +
"\"}";
// Create connection to send FCM Message request.
URL url = new URL("https://fcm.googleapis.com/fcm/send");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("Authorization", "key=" + SERVER_KEY);
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestMethod("POST");
conn.setDoOutput(true);
// Send FCM message content.
OutputStream outputStream = conn.getOutputStream();
outputStream.write(pushMessage.getBytes());
System.out.println(conn.getResponseCode());
System.out.println(conn.getResponseMessage());
我无法显示仅“消息标题”出现在单行通知中的“消息文本”。
我正在尝试在 Android 上实现多行通知。任何指针将不胜感激。
【问题讨论】:
标签: ionic-framework push-notification ionic3