React-native-firebase: Android 9 foreground notification onMessage/onNotification does not fire

Created on 3 Sep 2018  路  4Comments  路  Source: invertase/react-native-firebase

Issue

On Android 9 (tested on Google Pixel XL), when the app receives a notification when it's in foreground, onMessage() or onNotification callbacks are not triggered. The same code worked fine on the previous Android version.

Environment

  1. Application Target Platform:

Android 9

  1. Development Operating System:

macOS High Sierra

  1. Build Tools:

Android Studio

  1. React Native version:

0.55.4

  1. React Native Firebase Version:

4.2.0

  1. Firebase Module:

messaging, notification

  1. Are you using typescript?

No


Loving react-native-firebase? Please consider supporting them with any of the below:

Most helpful comment

Unfortunately, updating firebase core and cloud messaging didn't work for me.

When I updated, originally, I got this gradle sync error:

Error:Failed to notify dependency resolution listener.
The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[16.0.2,16.0.2]], but resolves to 16.0.0. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.

So updated the node_modules/react-native-firebase/build.gradle to use the latest packages, and that got things compiling.

compileOnly "com.google.android.gms:play-services-base:15.0.1"
  compileOnly "com.google.firebase:firebase-ads:15.0.1"
  compileOnly "com.google.firebase:firebase-auth:16.0.3"
  compileOnly "com.google.firebase:firebase-config:16.0.0"
  compileOnly "com.google.firebase:firebase-core:16.0.3"
  compileOnly "com.google.firebase:firebase-crash:16.2.0"
  compileOnly "com.google.firebase:firebase-database:16.0.2"
  compileOnly "com.google.firebase:firebase-firestore:17.1.0"
  compileOnly "com.google.firebase:firebase-functions:16.1.0"
  compileOnly "com.google.firebase:firebase-invites:16.0.3"
  compileOnly "com.google.firebase:firebase-storage:16.0.2"
  compileOnly "com.google.firebase:firebase-messaging:17.3.2"
  compileOnly "com.google.firebase:firebase-perf:16.1.0"

Not sure if I did something stupid there.

I receive messages fine when the app is in the background or closed. And messages fully work for me on ios, including when the app is open. It's just on android, and if the app is open.

All 4 comments

I manage to fix it by upgrading these packages to the latest versions:

Firebase Core -> com.google.firebase:firebase-core:16.0.3
Cloud Messaging -> com.google.firebase:firebase-messaging:17.3.0

Unfortunately, updating firebase core and cloud messaging didn't work for me.

When I updated, originally, I got this gradle sync error:

Error:Failed to notify dependency resolution listener.
The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[16.0.2,16.0.2]], but resolves to 16.0.0. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.

So updated the node_modules/react-native-firebase/build.gradle to use the latest packages, and that got things compiling.

compileOnly "com.google.android.gms:play-services-base:15.0.1"
  compileOnly "com.google.firebase:firebase-ads:15.0.1"
  compileOnly "com.google.firebase:firebase-auth:16.0.3"
  compileOnly "com.google.firebase:firebase-config:16.0.0"
  compileOnly "com.google.firebase:firebase-core:16.0.3"
  compileOnly "com.google.firebase:firebase-crash:16.2.0"
  compileOnly "com.google.firebase:firebase-database:16.0.2"
  compileOnly "com.google.firebase:firebase-firestore:17.1.0"
  compileOnly "com.google.firebase:firebase-functions:16.1.0"
  compileOnly "com.google.firebase:firebase-invites:16.0.3"
  compileOnly "com.google.firebase:firebase-storage:16.0.2"
  compileOnly "com.google.firebase:firebase-messaging:17.3.2"
  compileOnly "com.google.firebase:firebase-perf:16.1.0"

Not sure if I did something stupid there.

I receive messages fine when the app is in the background or closed. And messages fully work for me on ios, including when the app is open. It's just on android, and if the app is open.

Hi. I followed your advices to use latest packages. But i still unable to use onMessage(). Also android 9. Android build-tools(SDK v26)

i think you must define channel
you can use this url
https://rnfirebase.io/docs/v5.x.x/notifications/android-channels

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rgoldiez picture rgoldiez  路  3Comments

alizahid picture alizahid  路  3Comments

ODelibalta picture ODelibalta  路  3Comments

callmejm picture callmejm  路  3Comments

csumrell picture csumrell  路  3Comments