React-native-fcm: Android 8 Support

Created on 19 Dec 2017  路  25Comments  路  Source: evollu/react-native-fcm

for Android 5 & 6 it's working fine but for Android 8 Device I cann't get any notification

Most helpful comment

"FIXED"
In your notification payload set "channel": "default"

{
"to":"fcm_token",
"data": {
"custom_notification": {
"body": "Hey There",
"title": "I am APP",
"color":"#00ACD4",
"priority":"high",
"icon":"ic_notif",
"channel": "default",
"groupSummary": true,
"show_in_foreground": true
}
}
}

All 25 comments

what is your build target SDK? android 8?

Hi I use 26.0.0 for android 8

might have to do with new SDK broadcasting limitation.
are you using the latest version of react-native-fcm?

try change your target SDK to be 25.

UPDATE
android 8 has a breaking change which requires you to create notification channel first and associate all notifications to channels
it is still backward compatible for app built with SDK <=25 though.

well I've figured how to bridge the new change, but can't upgrade com.android.support:support-core-utils to >26 as the app crashes.

Any help to solve this problem is welcome.
https://github.com/evollu/react-native-fcm/pull/699

I use latest version of react-native-fcm so thanks for update

I successfully built and ran the sdk-26 branch and verified it on two images (SDK 25 and 27, before and after the API changes to ensure compatibility), after making some small fixes (https://github.com/evollu/react-native-fcm/pull/726). I didn鈥檛 see any crashes.

@haggholm Have you tried to use it together with other packages that uses firebase SDK like react-native-firebase? any resolution challenge?
I can't have the example project working

No, I don鈥檛 think the application uses Firebase except for this.

@haggholm so the example project works for you?

@evollu I haven鈥檛 tried the example project鈥擨鈥檒l find a moment to do so, but when I was trying things out, I was somewhat urgently trying to get our own product running!

@haggholm if you want to target sdk 26 now you can use this sdk-26 branch.
But there is risk as react-native itself may not fully support compiling against sdk 26.

@evollu I've used sdk-26 branch but the local notification not working. Remote notification still working when the app on background

@dashracer did you register your notification channel?

i'am register channel in my app, but notification in android 8 in galaxy s8 not work. @evollu

i'm send push use PHP

@chanramadhan have you set default notification channel for firebase notifications?

@evollu i set High in my notification channel but not work in android 8 (Galaxy S8), can you help me?

@chanramadhan are you talking about remote notificaiton? if so, do you have this?
<meta-data android:name="com.google.firebase.messaging.default_notification_channel_id" android:value="my_default_channel"/>

@evollu yes, i have this

in my androidmanifest. but not work in android 8

The below solution worked for me!
channel should be passed.

const notificationChannelId = 'my_notif_channel';

await FCM.createNotificationChannel({
    id: notificationChannelId,
    name: notificationChannelId,
    priority: 'max'
  });
...

FCM.presentLocalNotification({
   ..(notification parameters),
    channel: notificationChannelId
  })

"FIXED"
In your notification payload set "channel": "default"

{
"to":"fcm_token",
"data": {
"custom_notification": {
"body": "Hey There",
"title": "I am APP",
"color":"#00ACD4",
"priority":"high",
"icon":"ic_notif",
"channel": "default",
"groupSummary": true,
"show_in_foreground": true
}
}
}

Thanks @kaytee319, for some reason this advice you just gave is extremely hard to find elsewhere on the interwebs!

Hey!
.createNotificationChannel() is not available on my FCM object. Do I need to upgrade?

Yes @wmonecke

Was this page helpful?
0 / 5 - 0 ratings