Java 单击推送通知时打开应用程序

Java 单击推送通知时打开应用程序,java,firebase,ionic-framework,push-notification,ionic2,Java,Firebase,Ionic Framework,Push Notification,Ionic2,我有一个通过FCM接收推送通知的Ionic应用程序。问题是,当应用程序不在前台,我单击状态栏上的通知时,应用程序将不会打开(尽管从开始(“通知”)执行操作)。这是我的移动应用程序代码: this.pushNotifications.on('notification').subscribe((data: any) => { if (data.additionalData.foreground) { alert('Ai primit un mesaj nou'); } th

我有一个通过FCM接收推送通知的Ionic应用程序。问题是,当应用程序不在前台,我单击状态栏上的通知时,应用程序将不会打开(尽管从开始(“通知”)执行操作)。这是我的移动应用程序代码:

this.pushNotifications.on('notification').subscribe((data: any) => {
  if (data.additionalData.foreground) {
    alert('Ai primit un mesaj nou');
  }
  this.events.publish("gotMessage");
});
注意,
this.events.publish(“gotMessage”)被执行

这就是我通过Java发送通知的方式:

Map body = DataMap.map(
    "registration_ids", tokens,
    "data", DataMap.map(
        "content-available", "1",
        "title", "Fmcg Reporter",
        "body", "Ai primit un mesaj nou",
        "sound", "default"
    ),
    "collapse_key", "FmcgReporter"
);

Map headers = DataMap.map(
   "Authorization", "key=" + key,
   "Content-Type", "application/json"
);

Strings.readMethodURL("POST", "https://fcm.googleapis.com/fcm/send", headers, Strings.toJSON(body));

确保在使用服务器发送推送通知时指定“单击\u操作”。下面是my node.js服务器的工作示例:

// method: "POST",
//url: "https://fcm.googleapis.com/fcm/send",
    // get the key from Firebase console
    headers: { Authorization: `key=${fcmServerKey}` }, 
    json: {
        "notification": { 
            "title": "Message title",
            "body": "Message body",
            "click_action": "URL to your app?"
        },
        // userData is where your client stored the FCM token for the given user
        // it should be read from the database
        "to": userData.fcmRegistrationKey
    }

什么是设备平台-android?你是否尝试将“点击动作”添加到你的“数据”对象中?是的,我使用android对我不起作用。或者我在“点击动作”中添加了错误的内容。我已经从config.xml添加了我的ap id。我在哪里可以找到应用程序的url?嘿,Alex,你的应用程序安装在真正的设备上,对吗?您需要为url添加并使用特殊模式。我可以看看我是否能找到它