IONIC 3:IOS 无法在前台接收推送通知

IONIC 3: Unable to receive push notification on foreground in IOS

我正在开发与购物相关的移动应用程序,并使用 firebase FCM 在其中实现了推送通知。在 android 上一切正常,我收到的通知代码非常好:

app.component.ts

platform.ready().then(() => {
   this.fcm.onNotification().subscribe(data => {
      console.log(data);
   });
});

它在 android 中成功显示了通知数据,但是在 IOS 中,当我点击我的 php 代码进行通知时,它当我的应用程序关闭时显示通知,但当我已经打开应用程序时它不执行 this.fcm.onNotification() 函数。我刚刚调试了这个问题并注意到了这一点,在我的 xcode 控制台中它显示:

2018-12-14 18:08:34.299048+0530 BeMeals[1351:322531] 
Warning: Application delegate received call to -application:didReceiveRemoteNotification:fetchCompletionHandler: 
but the completion handler was never called.

php 文件

$url = 'https://fcm.googleapis.com/fcm/send';
    $msg = array
    (
     'title'  => 'This is title', // type of notification
     'tickerText' => 'This is message', // message
     'tab' => 'This is tab', // screen to open based on subtitle
     'screen' => "request_list",
     'message'  => 'hey',
     'body' => 'test',
     'vibrate' => 1,
     'sound'  => 1,
     'click_action'=>'FCM_PLUGIN_ACTIVITY'
    );

    $fields = array
    (
     'registration_ids'  => ['my device token'],
     'notification'   => $msg,
     'data' => [
        'test'=>123
     ],
     'priority' => 'high',
     'content_available' => true
    );

    $headers = array
    (
     'Authorization: key=' . self::$API_ACCESS_KEY,
     'Content-Type: application/json'
    );

    $result = self::useCurl($url, $headers, $fields);

任何人都可以告诉我它为什么快乐以及出了什么问题吗?

在 google 上的一些 RND 为我自己找到解决方案后,您需要将 FCM 插件版本降级到 1.1.5

cordova-plugin-fcm: "^1.1.5"

将此添加到您的 package.json 文件中。 希望这对你也有用。