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/
8 stars 12 forks source link

[react-native][Android] App crashes on launch due to 'Attempt to invoke virtual method...' #15

Closed Md-Mudassir closed 3 years ago

Md-Mudassir commented 3 years ago

in iOS its working fine but in android its throwing the below error on app launch.

Reason java.lang.NullPointerException: Attempt to invoke virtual method 'android.graphics.drawable.Drawable com.zoho.commons.LauncherProperties.getIcon()' on a null object reference

Stacktrace

FATAL EXCEPTION: main
Process: com.careerlabs, PID: 23555
java.lang.NullPointerException: Attempt to invoke virtual method 'android.graphics.drawable.Drawable com.zoho.commons.LauncherProperties.getIcon()' on a null object reference
at com.zoho.livechat.android.operation.SalesIQApplicationManager$7$1.run(SalesIQApplicationManager.java:984)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

"react-native": "^0.64.0",

Angu-G commented 3 years ago

@Md-Mudassir, Can you please let us know is this always reproducible and also whether you have used the following API?

Md-Mudassir commented 3 years ago

@Angu-G I followed this setup docs. & i'm calling only these 2 API's in one of my component.

ZohoSalesIQ.init("android_app_key","android_access_key"); ZohoSalesIQ.setLauncherVisibility(true);

Error in Android Emulator and i get the same error in a real device as well in debug mode. it shows for few seconds and then closes the app automatically.

error

Is there are any additionaly setup which i'm missing for android?

Angu-G commented 3 years ago

@Md-Mudassir, Can you please try the following code block as a replacement of the ZohoSalesIQ.init() API and let us know that the issue persists?

ZohoSalesIQ.initWithCallback("your appKey","your accessKey", (success) => {
      if(success){
          ZohoSalesIQ.setLauncherVisibility(true);
      }
      else{
          // your code
      }
});
Md-Mudassir commented 3 years ago

@Angu-G tried it but callback is returning false.. success seems to be false

Angu-G commented 3 years ago

@Md-Mudassir Please share your screen name(portal name)

Md-Mudassir commented 3 years ago

are you referring this? @Angu-G portal name

Angu-G commented 3 years ago

Yes, @Md-Mudassir. Let me check and get back

Md-Mudassir commented 3 years ago

@Md-Mudassir, Can you please try the following code block as a replacement of the ZohoSalesIQ.init() API and let us know that the issue persists?

ZohoSalesIQ.initWithCallback("your appKey","your accessKey", (success) => {
      if(success){
          ZohoSalesIQ.setLauncherVisibility(true);
      }
      else{
          // your code
      }
});

Even in iOS its returning false.. where as ZohoSalesIQ.init() works (iOS)

Md-Mudassir commented 3 years ago

@Angu-G any fix for the above issue? and apart from that i have 2 questions..

  1. The floating icon is by default set globally in almost all of the components.. ideally it should only appear in one component where I am defining ZohoSalesIQ.setLauncherVisibility(true); right? is there a way to control it to appear only in specified component?
  2. How to customize the floating icon like color, position..
Angu-G commented 3 years ago

@Md-Mudassir Thank you for your patience. We have identified the issue. Our server team is checking for the mismatch in the key. We will revert back once the fix is live.

Angu-G commented 3 years ago

@Angu-G any fix for the above issue? and apart from that i have 2 questions..

  1. The floating icon is by default set globally in almost all of the components.. ideally it should only appear in one component where I am defining ZohoSalesIQ.setLauncherVisibility(true); right? is there a way to control it to appear only in specified component?
  2. How to customize the floating icon like color, position..

@Md-Mudassir Customization is not possible as of now. You can disable our default launcher and have your own custom launcher and call the openChat() to open the SDK.

Md-Mudassir commented 3 years ago

@Md-Mudassir, Can you please try the following code block as a replacement of the ZohoSalesIQ.init() API and let us know that the issue persists?

ZohoSalesIQ.initWithCallback("your appKey","your accessKey", (success) => {
      if(success){
          ZohoSalesIQ.setLauncherVisibility(true);
      }
      else{
          // your code
      }
});

Thanks for the fix @Angu-G using the above API inside useEffect fixed the problem & for customisation I turned ZohoSalesIQ.setLauncherVisibility(false); to false & made use of openChat() API and added my own floating icon in which i had the full control over it.

Angu-G commented 3 years ago

@Md-Mudassir, Thank you for your time over the screen-sharing session. SDK should always be initialized at the Application level. In React-Native case, we recommend initializing the SDK in useEffect or componentDidMount method.