Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android app gets opened from links sent in email

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

like image 735
swalkner Avatar asked Jan 26 '17 07:01

swalkner


1 Answers

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>
like image 148
Aleksandar G Avatar answered Nov 15 '22 22:11

Aleksandar G