ios - Firebase 通知不在前台,但在 iOS Ionic 2 应用程序中为后台工作

标签 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"

最佳答案

在前台收到通知后点击本地通知。像这样的东西。

      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+""
          });
        }
      });

关于ios - Firebase 通知不在前台,但在 iOS Ionic 2 应用程序中为后台工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53059634/

相关文章:

ios - 为什么调用我的 CABasicAnimation 在 vi​​ewDidAppear 中不起作用?

ios - 如何以编程方式在不在同一 Storyboard 上的 View Controller 之间切换?

iOS 已弃用的 dataWithContentsOfMappedFile 替换

android - Android/Ionic 上 navigator.mediaDevices.getUserMedia 的 DOMException

ios - 在 iOS 应用程序中计算 G - Force

ios - 从 firebase 数据库中删除特定值

firebase - 需要帮助了解 Firebase 存储 CDN

Swift CollectionView.reload 数据在 Firebase 中发生变化时不起作用?

javascript - ngStorage 和原型(prototype)

javascript - Angular JS 的某些结果在 Google Chrome 中不显示,但在 FireFox 中显示