React-native-intercom: Adnroid version 13.0.1 push notifications doesn't work

Created on 12 Jul 2019  路  16Comments  路  Source: tinycreative/react-native-intercom

I am using RN 59.10 and I was using version 12.5.1 and everything worked fine.
Then I upgraded to 13.0.1 and I was not able to receive push notifications.
I downgraded to 12.5.1 and it work again.
In logs I catch this error:
AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.robinpowered.react.Intercom.IntercomIntentService" on path: DexPathList[[zip file "/data/app/com.myapp.app-MjCojLNq91ID9dVsmf902Q==/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp.app-MjCojLNq91ID9dVsmf902Q==/lib/arm64, /data/app/com.myapp.app-MjCojLNq91ID9dVsmf902Q==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64, /product/lib64]]

Most helpful comment

You no longer need the IntercomIntentService after v13, so you can just remove it from your AndroidManifest.xml

See -> https://github.com/tinycreative/react-native-intercom/releases/tag/v13.0.0

All 16 comments

I have I get the same error, the class is not found, I am using RN 0.60

You no longer need the IntercomIntentService after v13, so you can just remove it from your AndroidManifest.xml

See -> https://github.com/tinycreative/react-native-intercom/releases/tag/v13.0.0

Hello @tuncaulubilge
This is my manifest :

    <application
      android:name=".MainApplication"
      android:launchMode="singleTop"
      xmlns:tools="http://schemas.android.com/tools"
    >
      <activity
        android:name=".MainActivity"
         android:configChanges="keyboard|keyboardHidden|screenSize" android:windowSoftInputMode="adjustPan"
        android:launchMode="singleTask">

       <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>
      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
      <meta-data android:name="asset_statements" android:resource="@string/asset_statements" />
      <meta-data android:name="com.onesignal.NotificationAccentColor.DEFAULT" android:value="0009A5" />

       <service
          android:name=".MainMessagingService"
          android:enabled="true"
          android:exported="true">
            <intent-filter>
              <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" />
     </application>

And MyMessaginService (because I'm also using OneSignal for my push notifications, so need to handle both services I guess as explained in the doc...

...
import io.intercom.android.sdk.push.IntercomPushClient;
import com.google.firebase.messaging.RemoteMessage;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.onesignal.OSNotificationPayload;
import com.onesignal.NotificationExtenderService;
import com.onesignal.OSNotificationReceivedResult;

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

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        Map message = remoteMessage.getData();
        if (intercomPushClient.isIntercomPush(message)) {
            intercomPushClient.handlePush(getApplication(), message);
        } else {
            super.onMessageReceived(remoteMessage);
            // DO HOST LOGIC HERE
        }
    }
}

Versions :

package.json : 
    "react-native-intercom": "13.1.0",
     react-native: 0.59.1
build.gradle:
    implementation 'com.google.firebase:firebase-core:17.0.0'
    implementation 'com.google.firebase:firebase-analytics:15.0.0'
        // From node_modules
    //implementation 'io.intercom.android:intercom-sdk:5.+'
    implementation 'io.intercom.android:intercom-sdk-fcm:5.+'

OneSignal push notifications are working very well, but Intercom ones doens't, I never received them. I tried literally everythings... Did you have any tips or hint to help me please and make it works :'( ?

@MayoudP are you sending your FCM token to intercom?

Firebase.messaging().getToken()
  .then((token) => {
    console.log('Device FCM Token: ', token);
    Intercom.sendTokenToIntercom(token);
});

@MayoudP are you sending your FCM token to intercom?

Firebase.messaging().getToken()
  .then((token) => {
    console.log('Device FCM Token: ', token);
    Intercom.sendTokenToIntercom(token);
});

It seems not. But from which library should I add Firebase since I'm not using react-native-firebase inside my project...

It can either be a GCM token or a FCM token depending on which one you are using.

@tuncaulubilge

Alright I think got the main problem, however I still have a little tricky problem to make it works.

=> I have to implement the onNewToken() method inside my MessagingService.java file.
Problem is that even if I updated to implementation 'com.google.firebase:firebase-messaging:20.0.0' I still got a Method does not override method from its superclass, and Indeed if I ctrl+click on extends FirebaseMessagingService for my class, there isn't any onNewToken() method, tried to clean, rebuild, invalidate and restart, nothing worked...

EDIT : Bad library used, well, I finally succeed to implement the onNewToken() method, and registering a user on Intercom to push notification (Enabled push messaging : unknown -> true). But however it seems that the onMessageReceived is never called if I send a push, I get no log in the console, no push... What could be the reason ? Any ideas ?

I also cannot receive push notification on Android, but it is working on IOS. @tuncaulubilge How can I know if I send token to Intercom successfully?

@lilosir Actually, if you're upgrading to FCM, you need to send a token required by Firebase to Intercom to identified your user for push messaging.
I thought I could handle it by implementing onNewToken() in my MessagingService.java file but in fact, you need to do it directly in your JS code.

Like @tuncaulubilge said :

@MayoudP are you sending your FCM token to intercom?

Firebase.messaging().getToken()
  .then((token) => {
    console.log('Device FCM Token: ', token);
    Intercom.sendTokenToIntercom(token);
});

If your user on intercom got his status Enabled push messaging updated to true it means that Intercom well received the token.

However, I got a lot of conflicts by implementing react-native-firebase inside my project, didn't suceed to make it works unti now :/

@MayoudP Ok, I deleted all other services which are related to firebase.MESSAGING_EVENT from AndroidManifest.xml, then it seems working

Any update on this? I can receive push notifications on Android (If i set the check box to true ) while sending the in app message. But I cannot send the direct mobile push from Intercom. Any help guys?

@MayoudP Any news on this? I have the same troubles.

@MayoudP , I used to make Intercom work with OneSignal, it didn't require Firebase before, I just did

    OneSignal.addEventListener('ids', device => {
      const { userId, pushToken } = device;
      Intercom.sendTokenToIntercom(pushToken)
    });

This gives me a valid push token, and Intercom support tells me they actually receive it.
I can also send pushes from FCM console with this token and receive them.

However, if I try to send a push through Intercom interface, I don't receive them anymore (in 13.0 installDebug build).

Worst: it used to work in production (afaik, older Intercom SDK) and now it doesn't... so it means it's actually not this update (this is not published yet) that broke the android pushes in our app. Sadly we only noticed now that this is not working for a while.

To me it looks like there's something wrong with Intercom. My app is able to receive pushes sent by a curl command, but not pushes sent by the interface, yet the support tells me they see and received the token I sent them.

curl -X POST --header 'Authorization: key=xxx' \
    --Header "Content-Type: application/json" \
    https://fcm.googleapis.com/fcm/send \
    -d "{\"to\":\"xxx\",\"notification\":{\"body\":\"ENTER YOUR MESSAGE HERE\"}}"

Note that in the FCM dashboard it does not even show their push attempts (we are in prod for a while and afaik android intercom pushes used to work... not anymore).

image

Edit: problem is definitively on their side, their logs show "push sent to GCM", see https://twitter.com/sebastienlorber/status/1227665034312134656

Hello @slorber , on my side, in order to get the pushToken, I used import firebase from "react-native-firebase"; and did like this :

 firebase.messaging().getToken()
                .then((token) => {
                    Intercom.sendTokenToIntercom(token);
                })

and it works well now, I deleted some GCM too to make it works tho, because including firebase with an old GCM config created some conflict.

    "react-native-onesignal": "3.1.0",
    "react-native-intercom": "13.0.0",
    "react-native-firebase": "^5.5.6",

What worked for me was:

  1. changing intercom sdk version to implementation 'io.intercom.android:intercom-sdk:6.+

  2. sending FCM to Intercom Intercom.sendTokenToIntercom(token)

  3. IMPORTANT! Leaving just one <action android:name="com.google.firebase.MESSAGING_EVENT" /> in AndroidManifest.xml
    I had three of them, one from expoKit, one from react-native-firebase and one from intercom. I left only the one from intercom, which was already extending RNFirebaseMessagingService

Was this page helpful?
0 / 5 - 0 ratings

Related issues

felippepuhle picture felippepuhle  路  9Comments

paomosca picture paomosca  路  3Comments

canpoyrazoglu picture canpoyrazoglu  路  3Comments

skleest picture skleest  路  8Comments

mrharel picture mrharel  路  4Comments