zoho / SalesIQ-Mobilisten-ReactNative

Your mobile app's ideal live chat partner. Power up your mobile App with the SalesIQ Mobilisten SDK for React-Native.
https://mobilisten.io/
9 stars 11 forks source link

Android crash v.4.2.2 .registerVisitor #30

Closed tszajna0 closed 2 years ago

tszajna0 commented 2 years ago

Environment

Stack trace

Fatal Exception: java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.String android.content.SharedPreferences.getString(java.lang.String, java.lang.String)' on a null object reference
       at com.zoho.livechat.android.utils.LiveChatUtil.getCVUID(SourceFile:211)
       at com.zoho.livechat.android.utils.LiveChatUtil.setCVUID(SourceFile:216)
       at com.zoho.livechat.android.ZohoLiveChat.registerVisitor(SourceFile:1265)
       at com.zohosalesiq.reactlibrary.RNZohoSalesIQ$34.run(SourceFile:696)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:246)
       at android.app.ActivityThread.main(ActivityThread.java:8633)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
Angu-G commented 2 years ago

Hello @tszajna0, This issue happens when registerVisitor() API is triggered before init() call. If the API is used in the right way this issue will not occur. Similar behavior is the reason for issue #31. We will be working on this so that even any API call that is triggered before init() shouldn't cause any exceptions. This will be pushed in our next immediate update and let you know here. We can track both #31 and this one here on the same thread.

tszajna0 commented 2 years ago

Still seeing the #31 crash even if registerVisitor() is invoked after init():

ZohoSalesIQ.initWithCallback(APP_KEY, ACCESS_KEY, success => {
  if (success) {
    ZohoSalesIQ.disablePreChatForms();
    if (user?.profileId) ZohoSalesIQ.registerVisitor(user.profileId);
    if (user?.fullName) ZohoSalesIQ.setVisitorName(user.fullName);
    if (user?.email) ZohoSalesIQ.setVisitorEmail(user.email);
    if (user?.phone) ZohoSalesIQ.setVisitorContactNumber(user.phone);
    if (user?.customerID) ZohoSalesIQ.setVisitorAddInfo("BR customerId", `${user.customerID}`);
  }
});

It only crashes in Android:

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bossrevolution.money.production/com.zoho.livechat.android.ui.activities.ChatActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.content.SharedPreferences.getBoolean(java.lang.String, boolean)' on a null object reference
   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3835)
   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4011)
   at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
   at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
   at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2325)
   at android.os.Handler.dispatchMessage(Handler.java:106)
   at android.os.Looper.loop(Looper.java:246)
   at android.app.ActivityThread.main(ActivityThread.java:8633)
   at java.lang.reflect.Method.invoke(Method.java)
   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
Caused by java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.content.SharedPreferences.getBoolean(java.lang.String, boolean)' on a null object reference
   at com.zoho.livechat.android.utils.LiveChatUtil.isFormEnabled(SourceFile:3283)
   at com.zoho.livechat.android.ui.activities.ChatActivity.initChat(SourceFile:160)
   at com.zoho.livechat.android.ui.activities.ChatActivity.onCreate(SourceFile:96)
   at android.app.Activity.performCreate(Activity.java:8207)
   at android.app.Activity.performCreate(Activity.java:8191)
   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3808)
   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4011)
   at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
   at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
   at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2325)
   at android.os.Handler.dispatchMessage(Handler.java:106)
   at android.os.Looper.loop(Looper.java:246)
   at android.app.ActivityThread.main(ActivityThread.java:8633)
   at java.lang.reflect.Method.invoke(Method.java)
   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
Angu-G commented 2 years ago

Hello @tszajna0, Thank you for your patience. This issue has been addressed in our latest version(v4.2.4).

Angu-G commented 2 years ago

@tszajna0, We are closing this issue now. Please feel free to write us for further queries.