react-native-intercom: Doesn't receive Push Notifications on Android
Hello, First off, thanks for a great library!
98% of the implementation went swiftly and easily but getting pushes to show up has shown itself to be impossible (for me at least).
Problem
To repeat, the problem is that I can’t get push notifications sent from Intercom to show up on an Android device. In App messages work fine and all the other features. The user used for testing is verified to be accepting pushes and we’re sending the push tokens to Intercom like this:
FCM.getFCMToken().then(pushToken => {
if (pushToken) {
// Send to internal backend push service
this.props.postUserPush(pushToken, 'fcm')
Intercom.sendTokenToIntercom(pushToken)
}
})
And when running adb logcat I’m seeing MessagingService: Remote message received when sending pushes from Intercom. Which I interpret as the push arriving at the device but something blocks it from showing up, ergo some problem with my implementation. But I can’t for the life of me figure out what’s wrong.
Environment
We have an existing Push Notification setup using react-native-fcm which is verified to be receiving pushes from our own Push Service as before.
Some code
build.gradle
...
compileSdkVersion 26
buildToolsVersion "26.0.2"
...
minSdkVersion 16
targetSdkVersion 23
...
...
compile project(':react-native-fcm')
compile 'com.google.firebase:firebase-core:11.+'
...
compile 'io.intercom.android:intercom-sdk-base:4.+'
compile 'io.intercom.android:intercom-sdk-fcm:4.+'
compile 'com.google.firebase:firebase-messaging:11.+'
AndroidManifest.xml
...
<service android:name="com.robinpowered.react.Intercom.IntercomIntentService" android:exported="false">
<intent-filter android:priority="999">
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<receiver android:name="io.intercom.android.sdk.push.IntercomPushBroadcastReceiver" tools:replace="android:exported" android:exported="true" />
<service android:name="com.evollu.react.fcm.MessagingService" android:enabled="true" android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<service android:name="com.evollu.react.fcm.InstanceIdService" android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
...
Any help or guidance would be greatly appreciated!
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 33 (1 by maintainers)
I fixed this issue by overriding the MessagingService of the
react-native-fcmlibrary. This gives the effect of IntercomIntentService not being used since the push handling happens in the class OverriddenMessagingService (just an example name).Example:
@vvusts - ha, nope - I realised that a couple hours after I implemented this…
I moved the creation of the channels to native land and now I can. So in my
MainApplication.javaI now have:@jrbaudin I implemented the following and still could not get it working. Could you be more specific? Do I need to do any JS for this to work? Will using any of the libraries JS functions override what’s done here? Which server key did you use: legacy or standard? Did you specify a sender id? My FCM notifications are working from firebase, just not from Intercom. I’m using react-native-firebase, would make a difference in my overrides? They seem to have the same classes.
@vongohren had same problem on nativescript.
implementation 'io.intercom.android:intercom-sdk-base:6.+'does not create notification channel for push notifications
implementation 'io.intercom.android:intercom-sdk:6.+'solved the problem. Didn’t spot that sdk-base and sdk difference at first…
I would like to add one update to this.
Solution from @mtford90 works well. But later I found that Intercom Android SDK implements this on their own, since version
4.0.0here changelog:What fixed the same issue for me was using this sdk in my
build.gradleI removed the
io.intercom.android:intercom-sdk-fcm:5.+which was recommended in readme here.After this it all worked out of the box.
@vvusts
This + the solution in #208 helped me out. I’m using react-native-firebase and react-native-intercom with FCM. I had to add this MessagingService code, but also had to remove the
<service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService"> <intent-filter> <action android:name="com.google.firebase.MESSAGING_EVENT" /> </intent-filter> </service> <service android:name="io.invertase.firebase.messaging.RNFirebaseInstanceIdService"> <intent-filter> <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/> </intent-filter> </service>code in the manifest in favour of the manifest code specified in these issues.