Nativescript angular Push notifications that trigger a background refresh before showing the push notification

46 Views Asked by At

I would like to extend ordinary push notifications by giving applications a chance to update content in the background before notifying the user so that the user can open the application and be presented with new content immediately.

I'm using https://github.com/NativeScript/firebase in my project. Where users get push notifications and update the List in the background so once users open the application and have the latest messages or blogs list. How to achieve this in Nativescript Angular iOS? How to achieve this using Native implementation in the Nativescript-Angular project?

1

There are 1 best solutions below

0
Cateye On

I am not quite sure if I have understood the question correctly but I hope the following helps you.

If the app is active, you can use the firebase().messaging().onMessage() method to query the content of the push message sent and thereby trigger actions in the system.

If the app is not active, the following links may help you:

https://github.com/NativeScript/firebase/issues/42

https://github.com/NativeScript/firebase/issues/77

When starting the app, we listen to whether it has been opened by message or not. If via the message, this can be read out.

firebase().messaging().onNotificationTap((message) => {
  // gets called when a notification tap while app is in the background
  console.log('[MessagingService][onNotificationTap]', message);
});