如何防止来自Android移动网站的深层链接? [英] How to prevent deep linking from mobile site in android?

查看:63
本文介绍了如何防止来自Android移动网站的深层链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为我的所有活动添加了深层链接。

I have added deep links to all of my activities like this.

          <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这样在应用程序内调用时,此方法很好:

This works fine when I am calling within app using uri like this:

android-app://com.example.app/https/www.example.com/stores

android-app://com.example.app/https/www.example.com/stores

但是当我访问手机时网站到此页面,它为我提供了在应用程序或浏览器中打开页面的多种选择: https://www.example.com/商店。我有一些页面仅在用户登录时显示,但如果用户从移动网站登录,它将重定向到应用程序并中断。我不想使用自定义架构。

But when I am visiting mobile site to this pages it gives me multiple options to open page in app or browser: https://www.example.com/stores. I have some pages which show only when user is logged in but if user logins from mobile site it will redirect to app and it breaks. I don't want to use custom schema.

推荐答案

您需要在您的入口点检查用户的登录状态。活动,并在未登录时向他们显示登录活动(或对话框)。

you need to check login status of the user in the entry point of your activities and show the login activity (or dialog) to them if they are not logged in.

您必须在其他活动中自行处理。可以通过深层链接获得。只需在每次这些活动打开时检查登录状态,并在需要时直接登录活动或对话框。

you must handle this yourself in your different activities. which re available through deep linking. just check the logged in status each time these activities open and direct to login activity or dialog in the case they need.

如果您不希望浏览器添加您的应用程序在URI意向建议列表中,只需删除如下所示的可浏览即可:

if you dont want your browser to add your your application in the list of URI intent suggestions, just delete the "browsable" like below:

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

这篇关于如何防止来自Android移动网站的深层链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆