0

I need a way to include a link in an email which either opens a mobile app or redirects the user to a website depending on whether the mobile app is installed or not. I need a solution for both Android and IOS, it is there a set practice on how to achieve this?

Thanks!

CaptJak
  • 3,592
  • 1
  • 29
  • 50
user1937021
  • 10,151
  • 22
  • 81
  • 143

2 Answers2

0

You need a combo of answers here I think.

For iOS, You can replace http:// with itms:// or itms-apps:// to avoid redirects.

How to link to apps on the app store

For Android, I think you'll want to look at the <intent-filter> element of your Mainfest file. Specifically, take a look at the documentation for the <data> sub-element.

Make a link in the Android browser start up my app?

Community
  • 1
  • 1
StephenG
  • 2,851
  • 1
  • 16
  • 36
0

On Android, you need to handle this via Intent Filter:

    <activity
        android:name="com.permutassep.IntentEvaluator"
        android:label="@string/app_name">
        <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:host="your/url"
                android:scheme="http" />
            <data
                android:host="your/url"
                android:scheme="https" />

        </intent-filter>
    </activity>

And the class you need to handle the intent data should look like this:

public class IntentEvaluator extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Intent intent = null;

        if(getIntent() != null && getIntent().getData() != null){
         // Do whatever you want with the Intent data.

        }
    }
}

Taken from an app I developed: https://raw.githubusercontent.com/lalongooo/permutas-sep/master/app/src/main/java/com/permutassep/IntentEvaluator.java

Jorge E. Hernández
  • 2,800
  • 1
  • 26
  • 50