【问题标题】:Android app gets opened from links sent in email从电子邮件中发送的链接打开 Android 应用程序
【发布时间】:2017-06-11 15:36:25
【问题描述】:

我们的用户不时收到电子邮件,例如更改他们的密码。当他们点击链接时,我想让他们发送到我们的网站,但我们的 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 不是由应用程序处理的)。我不知道为什么customhostwww.ourdomain.com 完全不同...

【问题讨论】:

  • 您好像在发帖前更改了链接。这让人有点困惑。但这似乎是对的。此链接不应由应用程序打开。你能重新检查你的问题。 ?您发布的链接是否正确?
  • 是的; www.ourdomain.com 是德语网址,customhost-stuff 与网址完全不同,change-password-thing 是 1:1 对的。
  • 是否有其他原因/配置导致应用监听该域?
  • 此重复:stackoverflow.com/questions/34276617/… 已通过答案测试并且有效。

标签: android deep-linking


【解决方案1】:

您可以尝试将其分成不同的&lt;intent-filter&gt; 组件,因为一个&lt;intent-filter&gt; 应用程序可能会混淆,即使它编写正确。

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

【讨论】:

    猜你喜欢
    • 2012-10-21
    • 2012-07-30
    • 2013-08-30
    • 2011-01-03
    • 1970-01-01
    • 1970-01-01
    • 2011-08-06
    相关资源
    最近更新 更多