我已经为我的所有活动添加了这样的深层链接。
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
<data
android:host="www.example.com"
android:path="/stores"
android:scheme="https" />
</intent-filter>
当我使用这样的 uri 在应用程序内调用时,效果很好:
android-app://com.example.app/https/www.example.com/stores
但是,当我访问移动网站到此页面时,它为我提供了在应用程序或浏览器中打开页面的多个选项:https://www.example.com/stores。我有一些页面仅在用户登录时显示,但如果用户从移动网站登录,它将重定向到应用程序并中断。我不想使用自定义架构。
您需要在活动的入口点检查用户的登录状态,如果他们未登录,则向他们显示登录活动(或对话框)。
您必须在可通过深度链接访问的不同活动中自行处理此问题。只需在每次打开这些活动时检查登录状态,并在需要时重定向到登录活动或对话框。
如果您不希望浏览器将您的应用程序添加到 URI 意图建议列表中,只需删除“可浏览”,如下所示:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT"/>
<data
android:host="www.example.com"
android:path="/stores"
android:scheme="https" />
</intent-filter>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)