[英]how can i get the message from my push notification service and display to my message activity
[英]How to get a message from a silent Push notification with OneSignal?
在某些情況下,我需要發送一些消息並在后台做一些事情,我在 OneSignal 的文檔中找到了這個例子,它展示了如何設置,但我看不到我將如何獲得它發送的消息!
public class NotificationExtenderBare extends NotificationExtenderService {
@Override
protected boolean onNotificationProcessing(OSNotificationReceivedResult receivedResult) {
OverrideSettings overrideSettings = new OverrideSettings();
overrideSettings.extender = new NotificationCompat.Extender() {
@Override
public NotificationCompat.Builder extend(NotificationCompat.Builder builder) {
// Sets the background notification color to Green on Android 5.0+ devices.
return builder.setColor(new BigInteger("FF00FF00", 16).intValue());
}
};
OSNotificationDisplayedResult displayedResult = displayNotification(overrideSettings);
// Read properties from result.
// Return true to stop the notification from displaying.
return true;
謝謝你的提問。 我將更新文檔以使其更加清晰。
您可以使用receivedResult.payload
獲取消息
這是OSNotificationReceivedResult
的類定義
public class OSNotificationReceivedResult {
public boolean restoring;
public boolean isAppInFocus;
public OSNotificationPayload payload;
}
編輯:更新的文檔更清晰,帶有示例代碼
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.