iosfirebasecordovaionic3cordova-plugin-fcm

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


I am working on shopping related mobile application and implemented push notification in it using firebase FCM. Everything working fine on android and i am receiving notification very well with code:

app.component.ts

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

its successfully showing the notification data in android, but in IOS when i am hitting my php code for notification, its showing notification when my application is closed but when i already opened the application it does not executing the this.fcm.onNotification()function. And i just debug this issue and noticed this, in my xcode console its showing:

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 file

$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);

can any one please tell me why its happing and what's going wrong?


Solution

  • after some RND on google get a solution for myself , you need to downgrade FCM Plugin version to 1.1.5

    cordova-plugin-fcm: "^1.1.5"
    

    add this in your package.json file. hope this will work for you also.