I am trying to integrate SnapKit login into ionic 5 and also testing in ionic 4. But, I am not able to access window properties. I get error:
> snapKitInit does not exist in Window & typeof globalThis
I have included the following script tag which loads the js library from inside index.html
<script>
// Load the SDK asynchronously
(function (d, s, id) {
var js,
sjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s);
js.id = id;
js.src = "https://sdk.snapkit.com/js/v1/login.js";
sjs.parentNode.insertBefore(js, sjs);
})(document, "script", "loginkit-sdk");
</script>
In app.component.ts
doLogin() {
window.snapKitInit = function () {
var loginButtonIconId = 'my-login-button-target';
// Mount Login Button
snap.loginkit.mountButton(loginButtonIconId, {
clientId: 'YOUR_CLIENT_ID',
redirectURI: 'YOUR_REDIRECT_URI',
scopeList: [
'user.display_name',
'user.bitmoji.avatar',
'user.external_id'
],
handleResponseCallback: function() {},
});
};
}
1 post - 1 participant