Android。深层链接不适用于 http/https 方案
Android. Deep linking doesn't work with http/https scheme
我通过这种方式向我的 Android 应用程序添加了深层链接:
<activity
android:name=".views.DeepLinkingActivity"
android:exported="true">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="https"
android:host="example.com"/>
</intent-filter>
</activity>
当我点击 https://example.com
时,我被重定向到该网站。
当我将 android:scheme="https"
更改为 android:scheme="appscheme"
时,它会起作用并将我重定向到我的应用程序。
如何强制通过 https
方案打开我的应用程序?
更新
我添加了一个子域,但它仍然不起作用。
<activity
android:name=".views.DeepLinkActivity"
android:exported="true">
<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="https"
android:host="www.example.ru"/>
</intent-filter>
</activity>
试试这个
<activity
android:name=".views.DeepLinkingActivity"
android:exported="true">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="open"
android:scheme="example" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="example.com"
android:pathPrefix="/"
android:scheme="http" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="example.com"
android:pathPrefix="/"
android:scheme="https" />
</intent-filter>
</activity>
您指的是深度链接,但 android:autoVerify="true"
用于 App 链接,因此域 example.com
(您不拥有?)将接受数字资产链接检查 json 文件。参见 https://developer.android.com/training/app-links/index.html
为了让您的测试正常进行,我建议您删除 android:autoVerify="true"
并向主机添加一个子域,例如android:host="www.example.com"
您好,请使用以下数据并尝试参考此 doc
<intent-filter>
<data
android:scheme="ou unique scheme(appname,package name)" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
或
<data
android:scheme="you unique scheme(appname,package name)"
android:host="www.example.ru"/>
请查看下方可能有帮助
只需使用 http。不知道什么时候改实现。
但我刚刚测试过,使用 http 将使 http 和 https 都能正常工作。
因此,将您的意图过滤器更改为:
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="http"
android:host="example.com"/>
</intent-filter>
你也可以加进去
sub.example.com
<intent-filter android:label="@string/app_name">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" android:host="example.com" />
<data android:scheme="app" android:host="com.example.example" />
</intent-filter>
感谢 I removed android:autoVerify="true"
from https-scheme. I also changed the scheme from https
to http
. (You can read about autoVerify).
所以,目前有两种不同的方案:
<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:host="your-site.com"
android:pathPrefix="/"
android:scheme="http"
/>
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="your-site.com"
android:pathPrefix="/"
android:scheme="myapp"
/>
</intent-filter>
当点击 link myapp://your-site.com/... 时,将打开一个应用程序。当点击 http://your-site.com/... Chrome 浏览器将提供在应用程序或其他浏览器中打开,而其他移动浏览器忽略此并尝试自行打开。
更新
有关应用程序链接,请参阅 。
我通过这种方式向我的 Android 应用程序添加了深层链接:
<activity
android:name=".views.DeepLinkingActivity"
android:exported="true">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="https"
android:host="example.com"/>
</intent-filter>
</activity>
当我点击 https://example.com
时,我被重定向到该网站。
当我将 android:scheme="https"
更改为 android:scheme="appscheme"
时,它会起作用并将我重定向到我的应用程序。
如何强制通过 https
方案打开我的应用程序?
更新
我添加了一个子域,但它仍然不起作用。
<activity
android:name=".views.DeepLinkActivity"
android:exported="true">
<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="https"
android:host="www.example.ru"/>
</intent-filter>
</activity>
试试这个
<activity
android:name=".views.DeepLinkingActivity"
android:exported="true">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="open"
android:scheme="example" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="example.com"
android:pathPrefix="/"
android:scheme="http" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="example.com"
android:pathPrefix="/"
android:scheme="https" />
</intent-filter>
</activity>
您指的是深度链接,但 android:autoVerify="true"
用于 App 链接,因此域 example.com
(您不拥有?)将接受数字资产链接检查 json 文件。参见 https://developer.android.com/training/app-links/index.html
为了让您的测试正常进行,我建议您删除 android:autoVerify="true"
并向主机添加一个子域,例如android:host="www.example.com"
您好,请使用以下数据并尝试参考此 doc
<intent-filter>
<data
android:scheme="ou unique scheme(appname,package name)" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
或
<data
android:scheme="you unique scheme(appname,package name)"
android:host="www.example.ru"/>
请查看下方可能有帮助
只需使用 http。不知道什么时候改实现。
但我刚刚测试过,使用 http 将使 http 和 https 都能正常工作。
因此,将您的意图过滤器更改为:
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="http"
android:host="example.com"/>
</intent-filter>
你也可以加进去
sub.example.com
<intent-filter android:label="@string/app_name">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" android:host="example.com" />
<data android:scheme="app" android:host="com.example.example" />
</intent-filter>
感谢 android:autoVerify="true"
from https-scheme. I also changed the scheme from https
to http
. (You can read about autoVerify).
所以,目前有两种不同的方案:
<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:host="your-site.com"
android:pathPrefix="/"
android:scheme="http"
/>
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="your-site.com"
android:pathPrefix="/"
android:scheme="myapp"
/>
</intent-filter>
当点击 link myapp://your-site.com/... 时,将打开一个应用程序。当点击 http://your-site.com/... Chrome 浏览器将提供在应用程序或其他浏览器中打开,而其他移动浏览器忽略此并尝试自行打开。
更新
有关应用程序链接,请参阅 。