Deep link with custom permission

204 views Asked by At

I have created a deep link with auto verify using this as instructed, the

android:exported

tag needs to be set to true for the activity to be launched by the OS. I wanted to know, If I can add a custom/created permission

    <permission android:name="com.sample.app.DEEP_LINK_PERMISSION"/>

Add this custom/created permission to the activity tag and still make the deep link work?

<activity
        android:name=".sample.ui.CustomActivity"
        android:exported="true"
        android:permission="com.sample.app.DEEP_LINK_PERMISSION">
        <intent-filter android:autoVerify="true">
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data android:scheme="https" />
            <data android:host="someValue" />
            <data android:path="someValue" />
        </intent-filter>
    </activity>

After adding the custom/created permission, the deep parse link has stopped working. Is there a way to keep the custom/created permission and make the deep link work?

1

There are 1 answers

0
CommonsWare On

Adding android:permission="com.sample.app.DEEP_LINK_PERMISSION" says "only apps that hold com.sample.app.DEEP_LINK_PERMISSION can start this activity". No existing Web browsers are likely to hold that permission. As a result, they cannot start your activity.

You have three main options:

  1. Start saving your money, then acquire Google, Samsung, etc. Then, with your new-found authority, order them to add your custom permission to their apps. This may take some time.
  2. Eliminate the permission, so browsers can potentially start your activity. Bear in mind that some browsers, such as Firefox and Samsung Internet, may not support deeplinks by default.
  3. Eliminate the deeplink, so only your app (or other apps that hold your custom permission) can start the activity.

More generally, you should step back and consider what your objectives are with this custom permission.