v3rm0n / intercom_flutter

Flutter wrapper for Intercom libraries
95 stars 141 forks source link

Intercoms loginIdentifiedUser method is not working on web #481

Closed thanhit93 closed 1 week ago

thanhit93 commented 1 week ago

Problems

Intercom web is always opening visitors mode. The loginIdentifiedUser method does not seem to be working on web version. It is working fine on mobile versions.

Current version in use: 9.1.1

Steps to reproduce:

  1. Get user hash from dashboard UI or from backend generated from email and secret key
  2. Intercom initialization: Intercom.instance.initialize(Env.intercomAppId, iosApiKey: Env.intercomIOSKey, androidApiKey: Env.intercomAndroidKey)
  3. Set user hash: await Intercom.instance.setUserHash(userHash)
  4. Login Identified User with email: await Intercom.instance.loginIdentifiedUser(email: email)
  5. show messenger: Intercom.instance.displayMessageComposer(message)

https://github.com/user-attachments/assets/94fedf97-65ce-4208-a80c-c2871aa07204

Expected: should show identified user instead of visitor mode

Actual

Intercom web is always opening visitors mode

thanhit93 commented 1 week ago

I noticed that the setup user hash, it didn't save to the intercom setting, so when updating the user with the email it didn't work

My current solution is that:

  1. add a global variable to store the value when the user sets the user hash from outside image image
  2. In function loginIdentifiedUser and updateUser we will add 1 userHash attribute as shown and need to pass signUpAt field from outside image image await Intercom.instance.updateUser( email: email, signedUpAt: DateTime.now().secondsSinceEpoch, statusCallback: IntercomStatusCallback(onFailure: (error) { logger.e('loginIdentifiedUser failed: $error'); }, onSuccess: () { logger.d('loginIdentifiedUser onSuccess'); })); Final result:

https://github.com/user-attachments/assets/33ac2358-3125-48df-9d6c-0c90c608a1e6

if you have a better way please contribute, thanks

deepak786 commented 1 week ago

@thanhit93 I already noticed the same thing and seems that it has been changed recently. Because earlier there was no such issue. But now it seems that user_hash and user_id or email must be in Intercom settings.

deepak786 commented 1 week ago
  1. In function loginIdentifiedUser and updateUser we will add 1 userHash check condition as shown and need to add signUpAt field

What do you mean by need to add signUpAt field?

deepak786 commented 1 week ago

Duplicate of https://github.com/v3rm0n/intercom_flutter/issues/479

thanhit93 commented 1 week ago
  1. In function loginIdentifiedUser and updateUser we will add 1 userHash check condition as shown and need to add signUpAt field

What do you mean by need to add signUpAt field?

yes we need email, user_hash and signup At field, i tried all of them

deepak786 commented 1 week ago

Please override the intercom_flutter_web like below and test if the issue is fixed or not

dependency_overrides:
  intercom_flutter_web:
    git:
      url: https://github.com/v3rm0n/intercom_flutter
      ref: fix_479
      path: intercom_flutter_web
thanhit93 commented 1 week ago

Please override the intercom_flutter_web like below and test if the issue is fixed or not

dependency_overrides:
  intercom_flutter_web:
    git:
      url: https://github.com/v3rm0n/intercom_flutter
      ref: fix_479
      path: intercom_flutter_web

check, thanks. I will let you know when I have checked

thanhit93 commented 1 week ago

@deepak786 setUserHash and updateUser function seems to work correctly on my side

deepak786 commented 1 week ago

I have released the new version intercom_flutter: 9.2.0