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>