Closed ammarmarn closed 3 years ago
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.
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.
Yes we do. ZohoSalesIQ.Chat.isEnabled
can be used to check the state.
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"
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?
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()
}
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?
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
}
}
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.
I have splitVC on which Support is an option that's always visible (can't hide it) and can be selected anytime/mulitple times.
And following is simple code when support selected
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()
} }
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).
I have splitVC on which Support is an option that's always visible (can't hide it) and can be selected anytime/mulitple times.
And following is simple code when support selected
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:
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.
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.
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.