Closed tszajna0 closed 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.
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)
Hello @tszajna0, Thank you for your patience. This issue has been addressed in our latest version(v4.2.4).
@tszajna0, We are closing this issue now. Please feel free to write us for further queries.
Environment
Stack trace