@nirav_ionic, i know native Push working in all condition but in push i cannot able to open the app when i click on notification so can you help me on this?
which plugin use FCM or Push?
In push plugin click action is not working.
Can anyone find any solution?
@nirav_ionic thank you so much finally i found the solution using https://ionicframework.com/docs/native/push/.
always welcome
please mark as solution so easily identified by other
Just need to implement forceStart:ā1ā in JSON format and app will be awake from closed app so finally this is my final code with REST API
<===== REST API =====>
let headers = new Headers();
headers.append('Content-Type', 'application/json');
headers.append('Authorization', 'key=' + "**SERVER KEY**");
let option = new RequestOptions({ headers: headers });
let body = {
"data": {
"title": "TITLE",
"body": "MSG",
"forceStart": "1"
},
"priority": "high",
"to": **TOKEN**
}
this.http.post('https://fcm.googleapis.com/fcm/send', JSON.stringify(body), option)
.map(res => res.json())
.subscribe(data => {
console.log(data);
this.autostart.enable();
});
}
<===== PusH plugin ====>
const options: PushOptions = {
android: {
senderID: '**APP ID**',
sound: 'true',
vibrate: true,
forceShow: "1",
},
ios: {
alert: 'true',
badge: 'true',
sound: 'true',
clearBadge: 'true'
},
windows: {}
};
const pushObject: PushObject = this.push.init(options);
pushObject.on('notification').subscribe((notification: any) => {**foreground and background coding**});
pushObject.on('registration').subscribe((data: any) => {
console.log('device token -> ' + data.registrationId);
});
pushObject.on('error').subscribe(error => console.error('Error with Push plugin' + error));
}
Hi Muji,
Could you explain how do you do with OneSignal to send/receive notifications when app is closed/killed ?
You donāt do anything special.
Notifications are received by default when app is closed.
Not for me ⦠I can receive notifications when app in foreground or background but not when the app is closedā¦
Is that for Android or iOS?
Android, thanks if you can help me
Not really sure. It requires a bit of analysis.
Have you checked the OneSignal console? It should have details of each message sent.
Also check if the app is still running from your āapp settingsā if the āstop allā button is not enabled then the app is fully killed and it wonāt receive a notification.
This is the case with all apps, you can try force stop WhatsApp from there and you would see that you donāt receive a notification
Thanks ! I think the issue is that my app isnāt running anymore when I close it⦠I donāt know exactly how to let it run, but I will try to use the plugin autostart which could help me to run a service of the in background.
Hi, you shouldnāt need autostart, your phone is probably optimising performance by killing some apps.
Check ur phone settings and any optimising apps you might have installed
Hi! @Muji , I have the same problem in Android 
With OneSignal Itās works fine in iOS, but when I close my app in Android push notification donāt receive anymre
hi @jbgomez21, have you seen my above solution code and have you try it ?
Hi @Anithakor0610, I donāt understand where do you have to implement your āREST APIā code ⦠Do you think your solution works with OneSignal ?
hi @Favral this solution works fine with Push notification plugin and REST API you can check this REST API in postman then Apply your API in send message function.
Hi Anitha,
I have tested from postman but unable to send the notification when app is closed.
Please help me striggling with this issue from 15 days