Tapas Mukherjee
Tapas Mukherjee

Reputation: 2178

Notification when app is closed in Ionic3

I am building my app using Ionic3 and Firebase. Here users can send eatch other messages. I want when a use sends a message to another ures he/she should get a notification in the phone even when the app is closed. I have no idea how to achieve this with Ionic3. Any suggesions please.

I can see there are mainly 2 plugins for push notifications. cordova-plugin-firebase and cordova-plugin-fcm

At least I can fine some tutorial for cordova-plugin-fcm in the internet. There is no clear example of any wayout given for cordova-plugin-firebase.

Upvotes: 3

Views: 1793

Answers (2)

Charu Agarwal
Charu Agarwal

Reputation: 37

You have to use the cordova-plugin-firebase and each time a user logs in using a device, a unique device ID will be registered with respect to that device. This device ID is used to send notifications. Make sure to handle this (device ID), every time a user logs in & logs out. If you do not remove the device_id from the database when a user logs out, he will continue to receive notifications.

Upvotes: 2

David
David

Reputation: 7507

You have to use a cordova-plugin for sending push notifications. One of the many available plugins is: cordova-plugin-firebase. This one is a good fit for Ionic 3 because there is an ionic-native wrapper available.

For sending the push notification you can use a third party service (there is also one offered by ionic) or you can send them yourself from your backend.

Upvotes: 0

Related Questions