Something went wrong on android
Hello,
I have an issue with android when I try to display the intrcome massenger page. We are not using the Expo. In IOS it works fine.
here is what I did // in App.js
Intercom.setApiKey( Platform.OS === 'android' ? intrcomAndroidApiKey : intrcomIosApiKey , intrcomAppId ); // in another page I called the below methods in onPress event.
Intercom.registerUserWithIdentifier('[email protected]', '008990809'); Intercom.presentMessenger();
What's the error? What RN version are you using?
Can you use latest build gradle version?
classpath("com.android.tools.build:gradle:4.0.2")
Hello Team, We are using the following RN version. "react": "16.13.1", "react-native": "0.63.2",
Following the build gradle we have used.
classpath('com.android.tools.build:gradle:4.0.1')
On Thu, Nov 19, 2020 at 4:27 PM Matei Oprea [email protected] wrote:
Can you use latest build gradle version?
classpath("com.android.tools.build:gradle:4.0.2")
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mateioprea/react-native-intercom/issues/12#issuecomment-730294036, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARTWWNNOX23XXTXUEOZMQH3SQT2Y7ANCNFSM4T3GH36Q .
-- Thanks and Regards, Sagar Bhagwat
Sr. React-Native Developer
+917709690807
Does the upgrade to latest build:gradle tools work? I've managed to fix the errors when upgrading to build gradle 4.0.2
Yes It works when upgrading to build 4.0.2.
*And without upgrading it also works but for android but we need to used Intercom.registerUser(email) * *for registering a user.This Intercom.registerUserWithIdentifier(email, userId) method is not workd for android in build gradle 4.0.1 *
Thank you for such a wonderful and helpful library and your support.
On Thu, Nov 19, 2020 at 8:09 PM Matei Oprea [email protected] wrote:
Does the upgrade to latest build:gradle tools work? I've managed to fix the errors when upgrading to build gradle 4.0.2
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mateioprea/react-native-intercom/issues/12#issuecomment-730418250, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARTWWNMTF2VIPOTPI63FCDDSQUU3RANCNFSM4T3GH36Q .
-- Thanks and Regards, Sagar Bhagwat
Sr. React-Native Developer
+917709690807
Hi,
I am getting the below exception even with gradle build - 4.0.2. Am I missing some steps?

Reproduced the original issue. The screenshot below is what I see if I use registerUserWithIdentifier before calling presentMessenger. If I use registerUser instead, it works as expected and the rest of the integration works fine.
Note: to reproduce this issue I had to uninstall my app from the emulator. It seems Intercom stores some information on the device, so once you've registered a user successfully all future sessions work regardless of whether you use registerUserWithIdentifier or registerUser.
Possibly related: it seems setUserAttributes isn't working for me (the attributes I set don't appear in Intercom). Since the implementation for registerUserWithIdentifier is also based on setting user attributes, maybe it's the same issue?

Some additional information for my previous comment:
-
classpath('com.android.tools.build:gradle:4.1.0') -
"react-native": "0.63.3", -
"react-native-intercom-native": "^1.0.2", - Emulator: Pixel 3 API 30; Android 11.0 (Google Play)
Confirming that registerUser works, regardless of gradle version, and registerUserWithIdentifier does not work, regardless of gradle version.
Note: to reproduce this issue I had to uninstall my app from the emulator. It seems Intercom stores some information on the device, so once you've registered a user successfully all future sessions work regardless of whether you use registerUserWithIdentifier or registerUser.
Good catch. I think you can also call Intercom.logout when you are switching calls, to get a "fresh" session.
After calling registerUserWithIdentifer, I get a couple errors from Intercom in Android Studio.
Reproduced the original issue. The screenshot below is what I see if I use
registerUserWithIdentifierbefore callingpresentMessenger. If I useregisterUserinstead, it works as expected and the rest of the integration works fine.Note: to reproduce this issue I had to uninstall my app from the emulator. It seems Intercom stores some information on the device, so once you've registered a user successfully all future sessions work regardless of whether you use
registerUserWithIdentifierorregisterUser.Possibly related: it seems
setUserAttributesisn't working for me (the attributes I set don't appear in Intercom). Since the implementation forregisterUserWithIdentifieris also based on setting user attributes, maybe it's the same issue?
After I try this, the app Crash :(
Reproduced the issue Just chiming in here - has anyone figured out a workaround? cc @hentielouw @hellogerard
Think @hentielouw is correct seems it's an issue with setting up the user's attributes
I actually have had issues using .registerUser as well:
.registerUnidentifiedUser seems to work:
Looks like the code is calling similar methods to the sample...
https://github.com/mateioprea/react-native-intercom/blob/master/android/src/main/java/com/reactnativeintercom/IntercomModule.kt#L29
https://github.com/intercom/intercom-android/blob/master/samples/fcm-sample/src/main/java/io/intercom/sample/MainActivity.java#L45
I've had some success following the docs and using the registerIdentifiedUser method:
https://developers.intercom.com/installing-intercom/docs/android-installation
patch / diff:
diff --git a/node_modules/react-native-intercom-native/android/src/main/java/com/reactnativeintercom/IntercomModule.kt b/node_modules/react-native-intercom-native/android/src/main/java/com/reactnativeintercom/IntercomModule.kt
index b865deb..aa12f25 100644
--- a/node_modules/react-native-intercom-native/android/src/main/java/com/reactnativeintercom/IntercomModule.kt
+++ b/node_modules/react-native-intercom-native/android/src/main/java/com/reactnativeintercom/IntercomModule.kt
@@ -30,6 +30,13 @@ class RNNIntercomModule(reactContext: ReactApplicationContext) : ReactContextBas
promise.resolve(null)
}
+ @ReactMethod
+ fun registerIdentifiedUser(userId: String, promise: Promise) {
+ val registration = Registration.create().withUserId(userId)
+ Intercom.client().registerIdentifiedUser(registration)
+ promise.resolve(null)
+ }
+
@ReactMethod
fun registerUserWithIdentifier(email: String?, userId: String?, promise: Promise) {
val attributes: IntercomUserAttributes = io.intercom.android.sdk.UserAttributes.Builder()
diff --git a/node_modules/react-native-intercom-native/src/types/Intercom.tsx b/node_modules/react-native-intercom-native/src/types/Intercom.tsx
index e34ff83..76c929e 100644
--- a/node_modules/react-native-intercom-native/src/types/Intercom.tsx
+++ b/node_modules/react-native-intercom-native/src/types/Intercom.tsx
@@ -4,6 +4,7 @@ export type Intercom = {
setApiKey(apiKey: string, appId: string): Promise<any>;
registerUser(email: string): Promise<any>;
registerUserWithIdentifier(email?: string, userId?: string): Promise<any>;
+ registerIdentifiedUser(userId: string): Promise<any>;
registerUnidentifiedUser(): Promise<any>;
setUserHash(userHash: string): Promise<any>;
setLauncherVisible(visible: boolean): Promise<any>;
I'll try and get round to a PR, but keen to hear anyone else's solutions!
@henrymoulton Haven't looked at it since I last posted here, sadly. Had to go for an integration that only relies on registerUser, which wasn't ideal, but good enough for what we needed at the time.