14

Our users get emails from time to time to e.g. change their password. When they click the link, I would like to have them sent to our website, but our Android app gets opened.

The link e.g. is https://www.ourdomain.com/change-password/{random-string}.

We do have deep links enabled in our app, but they are configured the following way:

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

So the change-password part doesn't fit in any of that configurations, what could be the reason our app gets opened nevertheless?

EDIT

it seems as if the problem is the first data-tag; if I comment that out, it behaves as expected (i.e. https://www.ourdomain.com/change-password/1234 is not handled by the app). I don't know why as customhost is a complete different word from www.ourdomain.com...

swalkner
  • 16,679
  • 31
  • 123
  • 210
  • It seems like you have changed the links before posting. Which makes it a bit confusing. But this seems right. This link shouldn't be open by app. Can you recheck your question. ? Are you posting the links correctly? – Nouman Ghaffar Jan 26 '17 at 07:55
  • yes; `www.ourdomain.com` is a german url, the `customhost`-stuff is something completely different from the url, the `change-password`-thing is 1:1 right. – swalkner Jan 26 '17 at 07:59
  • could there be other reasons/configurations causing the app to listen to that domain? – swalkner Jan 26 '17 at 07:59
  • Duplicate of this: http://stackoverflow.com/questions/34276617/android-deep-links-not-following-path-prefix Tested with answer and it worked. – Roman Kolomenskii Feb 03 '17 at 12:39

1 Answers1

2

You may try to separate it into different <intent-filter> components, because with one <intent-filter> application can get confused, even if it is written correctly.

<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>
Pedro Rodrigues
  • 1,662
  • 15
  • 19
Aleksandar G
  • 1,163
  • 2
  • 20
  • 25