admin管理员组

文章数量:1291089

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> 
</body>

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?

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> 
</body>

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?

Share Improve this question asked Aug 12, 2016 at 11:24 Bart BergmansBart Bergmans 4,1214 gold badges31 silver badges58 bronze badges 2
  • I am having this problem too. It is weird. It wasn't blocked on my android phone until an upgrade to android 5.1.1. But it wasn't blocked on other devices I could find. I couldn't find people talking about it. : ( – Flmhdfj Commented Oct 25, 2016 at 22:07
  • I have this same problem when the intent is quite large. When it a small one, it works great. And, as @Flmhdfj said, it fails on some android versions and works great on others. Any solution yet? – ojovirtual Commented Nov 11, 2016 at 8:42
Add a ment  | 

2 Answers 2

Reset to default 6

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!

This feature was blocked due to security and performance issues but there's a workaround that works. First, you declare your intent filter in your android manifest

 <activity
        android:name=".SplashScreen"
        android:exported="true"
        android:label="@string/app_name"
        android:theme="@style/SplashTheme">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data
                android:scheme="pany"
                android:host="invoice"
                android:path="/" />
        </intent-filter>
 </activity>

then, in your HTML you do this

<a href="intent://invoice/#Intent;scheme=pany;package=YOUR_PACKAGE_NAME;end" rel="noreferrer" target="_blank">launch</a>

Also, to get more insight into the issue you can read more about it here

本文标签: javascript39Navigation is blocked39 when opening IntentStack Overflow