evollu / react-native-fcm

react native module for firebase cloud messaging and local notification
MIT License
1.73k stars 681 forks source link

Scheduled notification not triggered when app in background (banner is showing) #925

Open vvusts opened 6 years ago

vvusts commented 6 years ago

Remote notifications work local notifications work scheduled notification work I am getting banners etc.

I need to update badge when app is in background and when I fire scheduled notification.

On android when it is fired this is triggered:

FCM.on(FCMEvent.Notification, async notif => {
      console.log(notif);
      let existing = await FCM.getBadgeNumber();
      await FCM.setBadgeNumber(existing+1);

But on IOS when scheduled notification is fired this is not triggered. Any idea why?

This is how I schedule it:

FCM.scheduleLocalNotification({
      fire_date: time,
      id: id.toString(),
      title: title,
      body: message,
      priority: "high",
      wake_screen: true,
      my_custom_data: data
  })
vvusts commented 6 years ago

Even on example project when scheduled notification is sent can't update badge icon. And also if I set vibrate to true scheduled notification on IOS doesn't make phone vibrate.

evollu commented 6 years ago

did you kill the app?

vvusts commented 6 years ago

No, just put it in background

evollu commented 6 years ago

from the document, seems it won't trigger anything if the app is in the background for local notification https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/SchedulingandHandlingLocalNotifications.html

vvusts commented 6 years ago

Hm and on android work wierd :( Let me ask you something it's not related to this directly...

  1. Will this project remain for long term or it will be replaced by react native firebase (asking this because when I install this in project and rn firebase click on banner is not detected on ios and I needed it for firebase analytics which doesn't work when I install only this library)?

  2. What is best practice to send same payload that will work on both phone or it must be different (like in example project)?

evollu commented 6 years ago

I would recommend use react-native-firebase for long-term now because they have a larger support team and their messaging/notification package provides pretty much the same feature as mine. This repo will go into maintenance mode soon.

As for your second question, nope.