Search code examples
androidandroid-intenttwitterdeep-linkingintentfilter

Deep-links to my app from twitter - not working


I have the following intent filter in my manifest to accept deep-link urls:

<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="http" />
    <data android:scheme="https" />
    <data android:host="www.example.com"/>
    <data android:host="example.com"/>
    <data android:pathPattern="/path.*" />

</intent-filter>

Everything works great when tapping on links such as:

However - in Twitter, URLs are automatically shortened to something like this:

shortened twitter url example

(sorry for pic - SO won't let me post a shortened link example... wth?)

This URL is then resolved into the real URL when the user hits the link - however(!!), at this point once the URL is resolved into one that matches the above examples, android no longer seems to care about my intent filter and the URL is opened in a browser.

How can I resolve this so that URLs to my app from twitter properly open my app (or at least open the app picker)?


Solution

  • You are correct — with App Links, Android checks the actual URL being opened to see if any app is registered to handle it. If the URL is shortened (assuming the shortened domain itself is not registered, which is obviously the case with t.co), then subsequent URLs reached via redirects are not considered. iOS Universal Links work exactly the same way.

    On Android, you have two options:

    1. Put a custom URI scheme redirect on your destination URL. Then when the shortened link resolves, your user will end up in the app. Of course, you'll also need something like this to handle the app-not-installed situation. This is how we do it for Android at Branch.io (full disclosure: I'm on the Branch team).
    2. Show a deep-linked CTA button/link/smart banner on the destination URL. This is how things must work on iOS for apps like Twitter and Facebook, but on Android you still have the custom URI scheme option so this is less ideal.