Firebase通知未进入前台,但在iOS Ionic 2应用程序中为后台工作

时间:2018-10-30 07:52:12

标签: ios firebase ionic-framework notifications cordova-plugins

我正在尝试从Firebase控制台向我的iOS设备发送通知。它在后台接收。但是,当应用程序位于前台时,不会收到相同的通知。同样适用于Android前景和背景。我正在使用onMessage().subscribe(......) API并尝试在通知到来时显示警报。

我使用的插件是 cordova-plugin-firebase-messaging 1.1.4

在Firebase控制台中,当我尝试在前台发送通知时,消息状态仅停留在“已调度”,并且永远不会发送到设备。我想了解我可能会失踪的地方。

我在应用程序中使用的插件在下面列出。不确定是否有其他插件导致此问题或存在其他问题。如果有人解决了类似问题或对此有知识,请寻求您的指导。

com.darktalker.cordova.screenshot 0.1.5 "Screenshot"
cordova-plugin-android-fingerprint-auth 1.4.4 "FingerprintAuth"
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-background-mode 0.7.2 "BackgroundMode"
cordova-plugin-badge 0.8.7 "Badge"
cordova-plugin-ble-central 1.2.2 "BLE"
cordova-plugin-calendar 5.1.2 "Calendar"
cordova-plugin-camera 4.0.3 "Camera"
cordova-plugin-compat 1.2.0 "Compat"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-file 6.0.1 "File"
cordova-plugin-firebase-messaging 1.1.4 "FirebaseMessagingPlugin"
cordova-plugin-geolocation 4.0.1 "Geolocation"
cordova-plugin-inappbrowser 3.0.0 "InAppBrowser"
cordova-plugin-ionic-keyboard 2.1.3 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 2.1.4 "cordova-plugin-ionic-webview"
cordova-plugin-local-notification 0.9.0-beta.3 "LocalNotification"
cordova-plugin-mauron85-background-geolocation 2.3.6 "CDVBackgroundGeolocation"
cordova-plugin-network-information 2.0.1 "Network Information"
cordova-plugin-safariviewcontroller 1.5.4 "SafariViewController"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-touch-id 3.3.1 "Touch ID"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova-plugin-x-socialsharing 5.4.1 "SocialSharing"
cordova-support-android-plugin 1.0.1 "cordova-support-android-plugin"
cordova-support-google-services 1.2.1 "cordova-support-google-services"
cordova.plugins.diagnostic 4.0.10 "Diagnostic"
es6-promise-plugin 4.2.2 "Promise"
mx.ferreyra.callnumber 0.0.2 "Cordova Call Number Plugin"
phonegap-plugin-barcodescanner 8.0.0 "BarcodeScanner"

1 个答案:

答案 0 :(得分:1)

当您在前台收到通知时,

点击本地通知。这样的事情。

      this.firebaseNoti.onNotificationOpen().subscribe(data=>{
        if(data.tap){
          console.log('Received in background');
        }
        else{
          console.log('Received in foreground');

          this.localNotifications.schedule({
            id: 1,
            title: ""+data.title+"",
            text: ""+data.body+""
          });
        }
      });