Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notifications stop displaying on Android 8 and 8.1 #933

Closed
tss101 opened this issue May 7, 2018 · 20 comments
Closed

Notifications stop displaying on Android 8 and 8.1 #933

tss101 opened this issue May 7, 2018 · 20 comments

Comments

@tss101
Copy link

tss101 commented May 7, 2018

  1. React-Native version 0.51, react-native-fcm version (14.1.2 sdk-26 branch)
  2. Nokia 8 (Android 8.1) and Nokia 7 Plus (Android One 8.0.0)
  3. App is not running or running in background (user bug report, user was not sure)
  4. Firebase version 11.8.0

Hi,

I have an an released with react-native-fcm, and I'm getting user reports that notifications work for a while, then just stop. I finally managed to get a log report of one of the incidents, and the message that comes up is this:

05-07 17:18:01.849 27551 27551 W GCM     : broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10000000 pkg=to.synced.synced (has extras) }

Once the message comes up, it continues coming, and no further notifications arrive

Googling around it seems this crops up most often when the app is force killed by a battery saving mechanism more common in phones like the OnePlus 3T.

But in this case there is no battery saving being applied, at some point this message pops up and the notifications stop (along with the foreground service the app runs while it is closed).

I've also tried the same code on Android 5.1 and it runs without issue

I'm using custom notifications for Android, with the following format

{
            "custom_notification": {
                "channel":"default",
                "id":id,
                "number": number,
                "body": body,
                "big_text": body,
                "title": title,
                "icon":"ic_notif",
                "priority":"high",
                "sound":"default",
                "show_in_foreground": showinfg
                }
}
@evollu
Copy link
Owner

evollu commented May 7, 2018

this seems to be more of a firebase ticket
com.google.android.c2dm.intent.RECEIVE is not an intent this package listens to or send out.

@tss101 tss101 changed the title Notifications stop coming on Android 8 and 8.1 Notifications stop displaying on Android 8 and 8.1 May 7, 2018
@tss101
Copy link
Author

tss101 commented May 7, 2018

Thanks, though I'm not sure why notifications in our app are getting killed, since we only use the react-native-fcm package. We're pretty certain this is the event that's responsible for stopping the notifications, but we're not sure why it might be related to com.google.android.c2dm.intent.RECEIVE.

@tss101
Copy link
Author

tss101 commented May 8, 2018

Many thanks @evollu

I'd taken a look at the first one before but I don't think applies here. I've received a few more reports, and some of them didn't receive the:

05-07 17:18:01.849 27551 27551 W GCM : broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10000000 pkg=to.synced.synced (has extras) }

message. Also this is pretty much on stock Android, so swiping the app away shouldn't result in force kill like on the OnePlus 3T. However it might be related to Android 8's new battery saving features.

The second link is interesting:

notification payload can be send using data tag or notification tag.
using data tag
it will trigger the FirebaseMessagingService onMessageReceived method. it will not work on some devices, when an app is in the background.

We're still trying to figure out when exactly notifications stop working, but it is quite possible they stop delivering while the app is in the background, and don't restart until the app is swiped away and restarted.

It's quite hard to catch however as it happens infrequently (why we think it's related to the battery saving Android 8 features). Currently we're sending notifications every five minutes to some test devices, and once they're stop appearing on the device they don't reappear until the app is reopened.

@evollu
Copy link
Owner

evollu commented May 8, 2018

I think it might have to do battery saving as well.
Can you try native firebase SDK example for Android and see if you can reproduce the issue?

@tss101
Copy link
Author

tss101 commented May 8, 2018

Sure, I've installed it, and will try sending regular notifications to see if they stop at the same time

@tss101
Copy link
Author

tss101 commented May 8, 2018

Actually maybe the best strategy is to send a notification to Firebase after my app stops receiving them

@tss101
Copy link
Author

tss101 commented May 8, 2018

And see if they arrive

@tss101
Copy link
Author

tss101 commented May 8, 2018

One possible solution might be not send my notifications as data, but instead as standard notifications, which would then get handled by Firebase regardless of whether the app is running or not.

The downside of this approach is that they can't be shown in the foreground anymore

@tss101
Copy link
Author

tss101 commented May 9, 2018

Digging through the logs I did come across this. Is number supposed to be a float?

05-07 22:57:01.280  6508  9943 W Bundle  : Key number expected Double but value was a java.lang.Integer.  The default value 0.0 was returned.
05-07 22:57:01.281  6508  9943 W Bundle  : Attempt to cast generated internal exception:
05-07 22:57:01.281  6508  9943 W Bundle  : java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Double
05-07 22:57:01.281  6508  9943 W Bundle  :      at android.os.BaseBundle.getDouble(BaseBundle.java:1069)
05-07 22:57:01.281  6508  9943 W Bundle  :      at android.os.BaseBundle.getDouble(BaseBundle.java:1051)
05-07 22:57:01.281  6508  9943 W Bundle  :      at com.evollu.react.fcm.SendNotificationTask.doInBackground(SendNotificationTask.java:77)
05-07 22:57:01.281  6508  9943 W Bundle  :      at com.evollu.react.fcm.SendNotificationTask.doInBackground(SendNotificationTask.java:36)
05-07 22:57:01.281  6508  9943 W Bundle  :      at android.os.AsyncTask$2.call(AsyncTask.java:333)
05-07 22:57:01.281  6508  9943 W Bundle  :      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
05-07 22:57:01.281  6508  9943 W Bundle  :      at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
05-07 22:57:01.281  6508  9943 W Bundle  :      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
05-07 22:57:01.281  6508  9943 W Bundle  :      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
05-07 22:57:01.281  6508  9943 W Bundle  :      at java.lang.Thread.run(Thread.java:764)

@evollu
Copy link
Owner

evollu commented May 10, 2018

what does SendNotificationTask.java:77 have?

AFAIK, JS should pass double/float into native.

@tss101
Copy link
Author

tss101 commented May 10, 2018

.setNumber((int)bundle.getDouble("number"))

@tss101
Copy link
Author

tss101 commented May 10, 2018

I pass in 3 as number in my test cases

@tss101
Copy link
Author

tss101 commented May 10, 2018

from FCM

@evollu
Copy link
Owner

evollu commented May 15, 2018

fixed in v15.0.1

@jurajkrivda
Copy link

After update on 15.0.1 app crashed

@evollu
Copy link
Owner

evollu commented May 15, 2018

@jurajkrivda step to reproduce?

@tss101
Copy link
Author

tss101 commented May 15, 2018

Thanks @evollu. Could you update the sdk-26 branch (I'm using that branch)?

About the originally posted issue, I tracked down where the app was being force stopped. The notifications were stopping because of the force stop.

@tss101 tss101 closed this as completed May 15, 2018
@evollu
Copy link
Owner

evollu commented May 15, 2018

@tss101 I've merged changes into sdk-26

@tss101
Copy link
Author

tss101 commented May 16, 2018

Many thanks @evollu!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants