question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Doesn't receive Push Notifications on Android

See original GitHub issue

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!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:33 (1 by maintainers)

github_iconTop GitHub Comments

9reactions
jrbaudincommented, Jan 18, 2018

I fixed this issue by overriding the MessagingService of the react-native-fcm library. This gives the effect of IntercomIntentService not being used since the push handling happens in the class OverriddenMessagingService (just an example name).

Example:

public class OverriddenMessagingService extends MessagingService {
    private static final String TAG = "OverriddenMessagingService";
    private final IntercomPushClient intercomPushClient = new IntercomPushClient();

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        Map message = remoteMessage.getData();
        if (intercomPushClient.isIntercomPush(message)) {
            Log.d(TAG, "Intercom message received");
            intercomPushClient.handlePush(getApplication(), message);
        } else {
            super.onMessageReceived(remoteMessage);
        }
    }
}
3reactions
mtford90commented, Jan 28, 2019

@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.java I now have:

    @Override
    public void onCreate() {
        // ...
        SoLoader.init(this, /* native exopackage */ false);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            int importance = NotificationManager.IMPORTANCE_HIGH;
            NotificationChannel intercomChannel = new NotificationChannel("intercom_chat_replies_channel", "Intercom Replies", importance);
            intercomChannel.setDescription("Replies from Support (Chat to us)");
            NotificationManager notificationManager = getSystemService(NotificationManager.class);
            assert notificationManager != null;
            notificationManager.createNotificationChannel(intercomChannel);
        }
    }
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix Notifications Not Showing up on Android - Lifewire
How to Fix No Notifications on Android · Check That Do Not Disturb is not enabled. · Restart your phone. · Make sure...
Read more >
Why am I not getting ClassCover Booking Push Notifications ...
Why am I not getting ClassCover Booking Push Notifications on my Android phone? · Settings > Sounds & Vibration > Do Not Disturb:...
Read more >
[Android] I'm not getting push notifications. - Between
[Android] I'm not getting push notifications. · Please check the settings of your device system notifications. · Device Settings > Applications > Between...
Read more >
I'm not receiving push (app) notifications - Android - Solutions
Go to the Settings of your phone · Go to Application manager (or Apps) · Find and select SubAssistant · Ensure there is...
Read more >
How to fix Android notifications not working - Carlcare Service
As well as clearing the app cache to fix the notification issue, you may also try to uninstall and reinstall the affected app...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found