Im trying to make firebase push notification work on IONIC 3 using phonegap-plugin-push with @ionic-native/push plugin
This is my Ionic info
global packages:
Cordova CLI : 7.0.1
local packages:
@ionic/app-scripts : 2.1.3
Cordova Platforms : android 6.2.3 ios 4.4.0
Ionic Framework : ionic-angular 3.6.0
System:
Android SDK Tools : 25.2.2
Node : v8.1.3
OS : macOS Sierra
Xcode : Xcode 8.3.3 Build version 8E3004b
ios-deploy : 1.9.1
ios-sim : 6.0.0
npm : 5.1.0
I cannot understand how create create the notification object server-site to make notification work either iOS and Android. I read all aboout difference from notification and data payload, then I cannot understand how the object has to be to work on all platforms and in all app state (background and foreground).
This is my initial object
$p = array(
'id' => $post['id'],
'title' => $post['title'],
'description' => $post['description'],
'text' => $post['text'],
'image_url' => $post['image_url']
);
$msg = array(
'title' => "test",
'body' => $post['title'],
'post' => $p,
'vibrate' => 1,
'sound' => "default"
);
$fields = array();
$fields['to'] = "/topics/news";
$fields['data'] = $msg;
$fields["notification"] = array('title' => 'test', 'body' => $post['title'], 'sound' => 1);
So I tried to put together data and notification payload The result is
- Android Foreground ->notification arrived and I can go to detail page
- Android Background -> notification arrived but on('notification') is not called, thus I cannot navigate through detail page
- iOS Foreground -> notification arrived and I can go to detail page
- iOS Background -> notification arrived and I can go to detail page
The only issue is cannot control Android in background.
If I use just data payload on Android all works (can go to detail page either in background and foreground) but on iOS notification don't arrive at all.
If I use just notification payload notification arrives on Andorid and iOS but without data payload, so My app doesn't go to detail page.
My question is: What kind of object I should send to make iOS and Android work in foreground and background??