Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Invoking ZohoSalesIQ.Chat.show() API does not work prior to SDK initialization. #20

Closed
ammarmarn opened this issue Sep 15, 2021 · 13 comments
Labels
awaiting user input Awaiting input from the user for a query

Comments

@ammarmarn
Copy link

Describe the bug
The chat will not open on calling ZohoSalesIQ.Chat.show() if Mobilisten is unable to initialize yet for any undefined reason (no idea why its taking time even if called in appdidFinishLaunching).

To Reproduce
That's how we do right now on code:

ZohoSalesIQ.initWithAppKey("....")
ZohoSalesIQ.Chat.show()

Expected behavior
the chat window should always show or atleast give a error so developer can handle the failure.

Finding
If this "✅ MOBILISTEN » INITIALIZED {4.1.0}" is not printed yet the calling "ZohoSalesIQ.Chat.show()" will have no affect.

@Rishabh-Raghunath
Copy link
Member

The process of initializing Mobilisten is asynchronous in nature.
The initWithAppKey API comes with a completion closure within which the status of initialization is provided.

APIs like ZohoSalesIQ.Chat.show() require that Mobilisten is successfully initialized before invocation.
If you wish to open chat immediately after initialization, here is how you can do it;

ZohoSalesIQ.initWithAppKey(appKey, accessKey: accessKey) { (success) in
  if success {
    ZohoSalesIQ.Chat.show()
  }
}

We do have plans to provide an error in return as well in the API. Using the completion closure provided with the initWithAppKey API should resolve your issue.

@Rishabh-Raghunath Rishabh-Raghunath added awaiting user input Awaiting input from the user for a query and removed awaiting user input Awaiting input from the user for a query labels Sep 16, 2021
@ammarmarn
Copy link
Author

ok, so do you have any method to check whether SDK is initialized or not? So I can check before calling ZohoSalesIQ.Chat.show(). Incase, I have calling init in AppDelegate for example in order to avoid wait for the user when help button tapped in ViewController.

@Rishabh-Raghunath
Copy link
Member

Yes we do. ZohoSalesIQ.Chat.isEnabled can be used to check the state.

@Rishabh-Raghunath Rishabh-Raghunath changed the title Chat window sometimes don't show at all on calling ZohoSalesIQ.Chat.show() Question: Invoking ZohoSalesIQ.Chat.show() API does not work prior to SDK initialization. Sep 20, 2021
@ammarmarn
Copy link
Author

ammarmarn commented Sep 20, 2021

Right now faced one more issue, the sdk is initialized while Invoking ZohoSalesIQ.Chat.show() I am getting the following error, and no chat window is visible;

"Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service"

@Rishabh-Raghunath
Copy link
Member

Hi @ammarmarn, the message shared is not related to the Chat.show() API or the chat window.
Could you share more details on how and where the API is being invoked?

@ammarmarn
Copy link
Author

In the ViewController I am initializing the SDK, while when support button is pressed then setting some user info and then showing chat window.

    override func viewDidLoad() {
        ZohoHandler.setupZohoChat()
    }

    @IBAction func supportBtnTapped(_ sender: UIButton) {
        let visitor = VisitorClass.init()
        visitor.setName(userName)
        visitor.setEmail(email)
        ZohoSalesIQ.Chat.show()
   }

@Rishabh-Raghunath
Copy link
Member

Rishabh-Raghunath commented Sep 21, 2021

If Mobilisten is initialized at the time of invoking the ZohoSalesIQ.Chat.show() API, everything should work.
Is the button using which the chat is opened made visible only after successful initialization?

I would also like to point out that the visitor information is being incorrectly set in the shared code snippet.
Please set the information as shown below;

ZohoSalesIQ.Visitor.setName(userName)
ZohoSalesIQ.Visitor.setEmail(userEmail)

I would also highly suggest having Mobilisten initialized in the AppDelegate within the application(_:didFinishLaunchingWithOptions:) method. This way, ZohoSalesIQ.initWithAppKey is called only once, and not every time an instance of the view controller loads within the viewDidLoad method.

Could you try applying the above suggestions and let us know if everything works as expected?

@ammarmarn
Copy link
Author

ammarmarn commented Sep 21, 2021

Thanks for the suggestions I will incorporate them, one thing want to ask that instead of removing initialization in viewDidLoad() I am thinking to check if SDK is initialized if not then initialize it within the check.

  override func viewDidLoad() {
    if !ZohoSalesIQ.Chat.isEnabled {
          ZohoSalesIQ.initWithAppKey
        }
   }

@Rishabh-Raghunath
Copy link
Member

This would not be needed since Chat may be disabled for other reasons as well. For example, if you choose to hide the chat option when operators are offline.

Within the viewDidLoad method of a view controller, the value for ZohoSalesIQ.Chat.isEnabled alone can be checked and the chat button can then be made visible if it's true and similarly be hidden if the value is false.

@ammarmarn
Copy link
Author

I have splitVC on which Support is an option that's always visible (can't hide it) and can be selected anytime/mulitple times.
Screenshot 2021-09-23 at 7 00 10 PM
And following is simple code when support selected
Screenshot 2021-09-23 at 7 01 50 PM

What do you suggest will be suitable if "ZohoSalesIQ.Chat.isEnabled" returns false. Shall I then call following. But problem is I don't know when it will return and what if user selected any other side menu option meanwhile popping up chat window later on suddenly will make bad user experience.

ZohoSalesIQ.initWithAppKey(appKey, accessKey: accessKey) { (success) in
  if success {
    ZohoSalesIQ.Chat.show()
  } }

@ammarmarn
Copy link
Author

ammarmarn commented Sep 23, 2021

Apart from above question I got this crash:
"NSInvalidArgumentException: Application tried to present modally a view controller <Mobilisten.LCNavigationController: 0x14a8f9400> that is already being presented by <Marn.BaseSlidingController: 0x14b525590>."
What do you think can be the cause? (although I think this could be when user multiple tap on support button, but if I am trying to reproduce I am not getting this crash though).

@Rishabh-Raghunath
Copy link
Member

I have splitVC on which Support is an option that's always visible (can't hide it) and can be selected anytime/mulitple times.
Screenshot 2021-09-23 at 7 00 10 PM
And following is simple code when support selected
Screenshot 2021-09-23 at 7 01 50 PM

What do you suggest will be suitable if "ZohoSalesIQ.Chat.isEnabled" returns false. Shall I then call following. But problem is I don't know when it will return and what if user selected any other side menu option meanwhile popping up chat window later on suddenly will make bad user experience.

ZohoSalesIQ.initWithAppKey(appKey, accessKey: accessKey) { (success) in
  if success {
    ZohoSalesIQ.Chat.show()
  } }

The value for ZohoSalesIQ.Chat.isEnabled is false when the option to open chat is not to be shown.

The value can be false in the following cases:

  1. Mobilisten is not initialized.
  2. The user is IP blocked by an operator.
  3. All departments are offline and you choose to hide chat during the time.
  4. If the current time falls outside the configured business hours and you choose to hide chat during the time.

In this case, you may display the "Support" option as disabled (greyed out) or be hidden.
You may refresh the list once when the init completion closure is executed.

@Rishabh-Raghunath
Copy link
Member

We hope that the API reference provided answers your question. We are closing this issue since it has had no recent activity.
Please feel free to get back to us through the comments in case you have further queries.
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting user input Awaiting input from the user for a query
Projects
None yet
Development

No branches or pull requests

2 participants