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?
- 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
2 Answers
Reset to default 6I 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
版权声明:本文标题:javascript - 'Navigation is blocked' when opening Intent - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741499004a2381968.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论