【发布时间】:2020-10-02 07:23:35
【问题描述】:
我正在使用 PushNotifications Capacitor 插件和 FCM 发送通知,一切正常,直到我想在 Android 上发送带有 notification 和 data 字段的推送通知。
我想要做的是发送带有通知的自定义数据并在应用恢复时使用通知。我使用PushNotifications.getDeliveredNotifications() 方法来获取简历上的通知,在iOS 上我使用正确的data 获取所有通知,但在Android 上data 属性被以下对象替换:
{
body: "My Body",
data: {
android.appInfo: "ApplicationInfo{809371c app}",
android.bigText: "My Body",
android.progress: 0,
android.progressIndeterminate: false,
android.progressMax: 0,
android.reduced.images: true,
android.showChronometer: false,
android.showWhen: true,
android.template: "android.app.Notification$BigTextStyle",
android.text: "My Body",
android.title: "My Title",
gameDndOn: false,
specialType: "",
topFullscreen: false,
groupSummary: false,
id: 0,
title: "My Title"
}
}
我在 Android 应用程序的 FCM 文档中看到,如果通知和数据字段都存在并且应用程序在后台,则通知会出现在系统托盘中,数据会出现在 Intent 的附加部分中。
当我点击通知时,我正在获取正确的数据,但在我的情况下,我希望在不点击通知的情况下在简历中获取该数据。
在这种情况下有什么方法可以获取这些数据吗?
【问题讨论】:
-
Mateusz 运气好吗?
标签: android ionic-framework push-notification firebase-cloud-messaging capacitor