我正在使用 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"
}
}
Run Code Online (Sandbox Code Playgroud)
我在 Android 应用程序的 FCM 文档中看到,如果通知和数据字段都存在并且应用程序位于后台,则通知会出现在系统托盘中,数据会出现在意图的附加部分中。
当我点击通知时,我得到了正确的数据,但就我而言,我想在简历中获取这些数据,而不点击通知。
在这种情况下有什么办法可以获取这些数据吗?
android push-notification ionic-framework firebase-cloud-messaging capacitor