在后台模式下打开时,FCM Ionic Notification无法执行操作

时间:2019-01-06 07:59:35

标签: node.js angular firebase ionic-framework firebase-cloud-messaging

this.fcm.onNotification().subscribe(data => {
      if (data.wasTapped) {
        if (data.condition) {
            self.nav.push(NewsPage, { condition: data.condition });
         }
        console.log("Received in background");
      } else {
        console.log("Received in foreground");
      };
    });
  

NODEJS

firebaseController.message = (topic = "", data = {}, notification = null) => {
    let message={};
    message.data = data;
    message.notification.title = notification.title;
    message.notification.body = notification.body;
    message.notification.click_action="FCM_PLUGIN_ACTIVITY";
    message.topic = topic;
    return new Promise((resolve, reject) => {
        admin.messaging().send(message)
            .then((response) => {
                // Response is a message ID string.
                console.log('Successfully sent message:', response);
                resolve();
            }, (res) => {
                console.log("failure to send message", res);
                reject();
            })
            .catch((error) => {
                console.log('Error sending message:', error);
                reject();
            });
    });
}

在应用程序运行期间和在后台运行时,我都收到如图所示的通知。但是,在电话上单击通知图标后,onNotification并没有在后台运行。

我实际上是想在后台单击电话时做些事情。

任何想法我该如何实现。

0 个答案:

没有答案