crisp-sdk-android icon indicating copy to clipboard operation
crisp-sdk-android copied to clipboard

How do I know if it has been initialized?

Open SunSeekerX opened this issue 2 years ago • 11 comments

How do I know if it has been initialized?

SunSeekerX avatar Sep 13 '22 12:09 SunSeekerX

I wish i can use like the Crisp.isInitialized() to get

SunSeekerX avatar Sep 13 '22 12:09 SunSeekerX

Can you explain what you are trying to do?

Baptiste Jamin

On 13 Sep 2022, at 14:38, SunSeekerX @.***> wrote:

I wish i can use like the Crisp.isInitialized() to get

— Reply to this email directly, view it on GitHub https://github.com/crisp-im/crisp-sdk-android/issues/138#issuecomment-1245352954, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGTRQ3TXIKACPR2QWW3ZHLV6BYSRANCNFSM6AAAAAAQLMVMGQ. You are receiving this because you are subscribed to this thread.

baptistejamin avatar Sep 13 '22 12:09 baptistejamin

Thank you for such a quick reply!

The websiteID is required to start the crisp activity interface, if not I get an error java.lang.AssertionError: Crisp ChatBox SDK has not been configured yet. Please make sure to call Crisp.configure(String websiteID) first!, so I want to know if I have set the websiteID.

SunSeekerX avatar Sep 13 '22 12:09 SunSeekerX

Answer is very simple. Did you follow the docs ? Just add a Log.d after setting the website ID. If you see the log, then you settled the site ID…Sent from my iPhoneOn 13 Sep 2022, at 14:49, SunSeekerX @.***> wrote: Thank you for such a quick reply! The websiteID is required to start the crisp activity interface, if not I get an error java.lang.AssertionError: Crisp ChatBox SDK has not been configured yet. Please make sure to call Crisp.configure(String websiteID) first!, so I want to know if I have set the websiteID.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

baptistejamin avatar Sep 13 '22 12:09 baptistejamin

This error came after I entered the crisp interface, and I had no way to catch it, so I needed to do a determination of whether it was initialized before I entered the crisp interface.

SunSeekerX avatar Sep 13 '22 12:09 SunSeekerX

Answer is very simple. Did you follow the docs ? Just add a Log.d after setting the website ID. If you see the log, then you settled the site ID…Sent from my iPhoneOn 13 Sep 2022, at 14:49, SunSeekerX @.> wrote: Thank you for such a quick reply! The websiteID is required to start the crisp activity interface, if not I get an error java.lang.AssertionError: Crisp ChatBox SDK has not been configured yet. Please make sure to call Crisp.configure(String websiteID) first!, so I want to know if I have set the websiteID. —Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.>

Sure, but the websiteId is passed in externally.

SunSeekerX avatar Sep 13 '22 12:09 SunSeekerX

My requirement is to know if I have set the websiteId before starting crisp, and I need to use if to determine this, rather than outputting a log

SunSeekerX avatar Sep 13 '22 12:09 SunSeekerX

Externally ?Sent from my iPhoneOn 13 Sep 2022, at 14:55, SunSeekerX @.***> wrote:

Answer is very simple. Did you follow the docs ? Just add a Log.d after setting the website ID. If you see the log, then you settled the site ID…Sent from my iPhoneOn 13 Sep 2022, at 14:49, SunSeekerX @.> wrote: Thank you for such a quick reply! The websiteID is required to start the crisp activity interface, if not I get an error java.lang.AssertionError: Crisp ChatBox SDK has not been configured yet. Please make sure to call Crisp.configure(String websiteID) first!, so I want to know if I have set the websiteID. —Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.>

Sure, but the websiteId is passed in externally.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

baptistejamin avatar Sep 13 '22 12:09 baptistejamin

Take look this

if(Crisp.isInitialized()){
      Intent crispIntent = new Intent(mUniSDKInstance.getContext(), ChatActivity.class);
      mUniSDKInstance.getContext().startActivity(crispIntent);
      result.put("success", true);
      result.put("code", 200);
      result.put("msg", "启动成功!");
    } else {
      return  "Please set websiteId first!";
    }

SunSeekerX avatar Sep 13 '22 13:09 SunSeekerX

Hi @SunSeekerX.

As soon as the Crisp.configure(Context applicationContext, String websiteID) returns, SDK is initialized with your new websiteID, except in a specific case where chatbox is already running where we wait until the chatbox is closed... So in your sample code, you could just make a call to Crisp.configure(Context applicationContext, String websiteID) before starting the ChatActivity.

For the moment, there is no public API available to know if Crisp is initialized.

Doc1faux avatar Sep 13 '22 13:09 Doc1faux

Okay, thanks for the answer, but I still need a way to know if it's initialized or not to optimize the code logic.

SunSeekerX avatar Sep 13 '22 14:09 SunSeekerX