Is It possible to use deeplink in a Module that is used by many other applications?
Asked Answered
H

1

4

I'm trying to create an .aar file to be used by other applications. In this module, the user needs to go out of the application due to the payment. I want to open the application after the payment is finished and a button on the website is clicked. If it was in my application, I could easily handle it by adding an intent-filter for deep linking in manifest. But now I don't know how I can read manifest and read the deep link defined on the application.

I searched for it and I couldn't find any answer.

Thanks in advance.

Houselights answered 22/12, 2020 at 11:30 Comment(0)
A
4

You can add an Activity to your Android module (library) and define the same intent-filter in the manifest for your Activity.

So when the browser is done with payment flow they can fire up your library's Activity Using Deep-Links.

I highly suggest to read up on Android App Links as well.

This way you can handle everything right in your .aar and end App developers don't have to play the relay role for you.

There is one important catch with this approach and that is to be careful when multiple applications have integrated your .aar on the same device. In that case after the payment flow, Android will suggest to the user both of the apps, which is wrong and might lead to an unexpected result.

There is a simple fix to this by using $applicationId key in the intent-filter defined for your Activity. Just make sure your browser will call the correct callback-URL with the correct applicationId when it's done.

Here is a complete sample of that Activity manifest:

<activity
            android:name=".CallBackActivity"
            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:scheme="https" />
                 <data android:host="www.yourDomainName.com" />
                 <data android:pathPattern="payment/$applicationId" />
            </intent-filter>
</activity>
Awlwort answered 29/12, 2020 at 7:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.