最近の検索
最近の検索はありません
TypeError: client.on is not a function
投稿日時:2023年3月05日
Hi Team,
I have loaded Zendesk SDK using https://static.zdassets.com/zendesk_app_framework_sdk/2.0/zaf_sdk.min.js and after load ZAFClient object is returned. However init method does not return client object instead returns false.
Code Snippet as follows:
const client = window.ZAFClient.init();
client.on('voice.dialout', function appRegistered(e: any) {
console.log("test");
});
Please suggest what should be done to get proper client object.
1
18
18件のコメント
Eric Nelson
To confirm, you mean that you're webpacking this down and then having it installed locally into the zendesk account (in your manifest file you'd see the location pointing at a html file, not a web address)? If that's the case your example is missing a variety of vital pieces (e.g. manifest.json, webpack config that packs down to a single entry point). If you're indeed doing this and not hosting it somewhere else and just iframing it in - then I'd need to see the full application.
If you're hosting it somewhere else, and iframing it in (e.g. in your location field of your manifest file it says a web address and not an html file) then even though react is client side, to ZAF it's considered server side as it's being hosted somewhere else. In these circumstances you'd need to follow the steps in the link above.
0
Balaji
Hi Eric,
This is pure client-side application created in react.
0
Eric Nelson
I'm assuming you've set this up as a server side app, if that assumption is wrong - please let me know. When using a server side app you need to be providing the app_guid and origin to every page of your application so that it can continue utilizing ZAF. We cover this here.
Hope this helps!
0
Balaji
Hi Eric,
Please find attached link (Click Here for repo link) for sample app to reproduce this issue.
For executing the app, please perform below steps in your local.
- npm install
- npm start
0
Eric Nelson
Hey Balaji,
It's tough to debug without seeing your actual application. Would you mind providing a link to your example apps repository?
Thanks!
0
Balaji
Hi Eric,
To further investigate the issue, we created a very simple react app just with 2 components in it.
In first component we are calling ZAFClient.init method and getting client object as expected. But as soon as we redirect to another component using history.push() or react router dom and create a new instance of client object using ZAFClient.init we are getting the value as false.
Before Redirection (In component 1)
After Redirection (In component 2)
0
Balaji
Thank you Eric for the response
we use window object to call, as when we load Zendesk SDK in our react typescript application, ZAFClient object was getting attached to window object.
Also we tried using directly by defining class as below, still we received the same error.
Here we do use Micro Frontend architecture. So we have a nested app to load Zendesk SDK. And on initial load we find that it works for 1 time, but when we redirect for login page which is in the same domain.
After authentication when we reload the page it start failing. Here we get client as false.
Can this be due to the reason that we do redirect from our initial page to another page?
0
Eric Nelson
May I ask why you're setting the ZAFClient through the window object? What happens when you call it directly?
0
サインインしてコメントを残します。