I have an issue, I've created an angular PWA and my app uses auth0-lock as its authentication now my problem is.. when you click one of the single sign-in options like Google, for example, you get taken out of the PWA and into safari, Is there any way I can prevent this??
I have tried putting this code in my index.html
<!-- Prevent app from opening new safari page -->
<script type="text/javascript">
(function(document,navigator,standalone) {
// prevents links from apps from oppening in mobile safari
// this javascript must be the first script in your <head>
if ((standalone in navigator) && navigator[standalone]) {
var curnode, location=document.location, stop=/^(a|html)$/i;
document.addEventListener('click', function(e) {
curnode=e.target;
while (!(stop).test(curnode.nodeName)) {
curnode=curnode.parentNode;
}
// Condidions to do this only on links to your own app
// if you want all links, use if('href' in curnode) instead.
if('href' in curnode && ( curnode.href.indexOf('http') || ~curnode.href.indexOf(location.host) ) ) {
e.preventDefault();
location.href = curnode.href;
}
},false);
}
})(document,window.navigator,'standalone');
</script>
but that doesn't seem to be working, I have seen some other javascript hacks that can prevent this and I have still yet to find one that works in my angular application?
Does anyone have any experience with this??
Thanks
from How to prevent PWA from opening links and Auth0 single sign in authentication in new Safari Window
No comments:
Post a Comment