react-native-intercom icon indicating copy to clipboard operation
react-native-intercom copied to clipboard

Something went wrong on android

Open saagarbhagwat opened this issue 5 years ago • 15 comments

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();

saagarbhagwat avatar Nov 19 '20 10:11 saagarbhagwat

What's the error? What RN version are you using?

mateioprea avatar Nov 19 '20 10:11 mateioprea

Can you use latest build gradle version?

classpath("com.android.tools.build:gradle:4.0.2")

mateioprea avatar Nov 19 '20 10:11 mateioprea

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

saagarbhagwat avatar Nov 19 '20 14:11 saagarbhagwat

Does the upgrade to latest build:gradle tools work? I've managed to fix the errors when upgrading to build gradle 4.0.2

mateioprea avatar Nov 19 '20 14:11 mateioprea

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

saagarbhagwat avatar Nov 20 '20 04:11 saagarbhagwat

Hi,

I am getting the below exception even with gradle build - 4.0.2. Am I missing some steps? image

kavithastockpile avatar Jan 20 '21 00:01 kavithastockpile

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?

Screenshot_1612899595

hentielouw avatar Feb 09 '21 19:02 hentielouw

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)

hentielouw avatar Feb 09 '21 20:02 hentielouw

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.

Screen Shot 2021-04-15 at 5 38 46 PM

hellogerard avatar Apr 15 '21 21:04 hellogerard

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?

Screenshot_1612899595

After I try this, the app Crash :(

michaelVictoriaDev avatar May 05 '21 08:05 michaelVictoriaDev

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

henrymoulton avatar May 13 '21 12:05 henrymoulton

I actually have had issues using .registerUser as well:

image

.registerUnidentifiedUser seems to work:

image

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

henrymoulton avatar May 13 '21 12:05 henrymoulton

I've had some success following the docs and using the registerIdentifiedUser method:

image

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>;

henrymoulton avatar May 13 '21 13:05 henrymoulton

I'll try and get round to a PR, but keen to hear anyone else's solutions!

henrymoulton avatar May 13 '21 13:05 henrymoulton

@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.

hentielouw avatar May 18 '21 10:05 hentielouw