我们的用户不时收到电子邮件,例如更改他们的密码。当他们点击链接,我想让他们发送到我们的网站,但我们的Android应用程序被打开。
例如,链接是https://www.ourdomain.com/change-password/{random-string}。
我们的应用程序中确实启用了深度链接,但它们的配置方式如下:
<intent-filter android:label="...">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="customhost"
android:pathPrefix="/"
android:scheme="https" />
<data
android:host="www.ourdomain.com"
android:pathPrefix="/somethingelse"
android:scheme="https" />
<data
android:host="www.ourdomain.com"
android:pathPrefix="/againsomethingelse"
android:scheme="https" />
<data
android:host="someothercustomhost"
android:scheme="https" />
<data
android:host="andagainacustomhost"
android:scheme="https" />
</intent-filter>因此,change-password部分不适合这些配置,我们的应用程序被打开的原因是什么?
编辑
问题似乎是第一个data-tag;如果我将其注释掉,它的行为就像预期的那样(即https://www.ourdomain.com/change-password/1234不是由应用程序处理的)。我不知道为什么customhost和www.ourdomain.com完全不同.
发布于 2017-01-28 09:46:51
您可能会尝试将其分离为不同的<intent-filter>组件,因为使用一个<intent-filter>应用程序可能会混淆,即使它是正确编写的。
<intent-filter android:label="...">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="www.ourdomain.com"
android:pathPrefix="/somethingelse"
android:scheme="https" />
<data android:host="www.ourdomain.com"
android:pathPrefix="/againsomethingelse"
android:scheme="https" />
</intent-filter>
<intent-filter android:label="...">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="customhost"
android:pathPrefix="/"
android:scheme="https" />
</intent-filter>
<intent-filter android:label="...">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="someothercustomhost"
android:scheme="https" />
</intent-filter>
<intent-filter android:label="...">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="andagainacustomhost"
android:scheme="https" />
</intent-filter>https://stackoverflow.com/questions/41868819
复制相似问题