Home » Php » javascript – 'Navigation is blocked' when opening Intent

javascript – 'Navigation is blocked' when opening Intent

Posted by: admin July 12, 2020 Leave a comment


I am working on the payment process for an app. When the user has paid in the browser he has to get redirected back to the app.

My solution is to open an Intent from the browser. To achieve this I made a button and clicked it using javascript:

<body onload="document.getElementById('backToApp').click();">
    <a style="margin: 50px auto;" id="backToApp" class="btn btn-success" href="intent://app/#Intent;scheme={{ scheme }};package={{ package }};S.data={{ data }};end">Return to app</a> 

The only problem is that when I open the site in my mobile browser the Chrome debugger says: Navigation is blocked. Is there a way to fix this?

How to&Answers:

I found the problem a while ago, forgot to mention it here, sorry! You only can open an app with an intent if you have opened this site/session with your app.
So if you go to the page with the intent button in your browser by typing the URL. You will get ‘Navigation is blocked’.
If you open the page by redirecting there from your app and you click the button, it works!