kotlin-multiplatform-oidc icon indicating copy to clipboard operation
kotlin-multiplatform-oidc copied to clipboard

Current launchMode setting stops redirect from Firefox custom tabs

Open Lazalatin opened this issue 6 months ago • 0 comments

Hello there,

I recently came across a problem with my KMP Android App using this great library with handling the OIDC Flow with Firefox custom tabs.

Redirect error when using firefox custom tab. The image shows a custom tab with a blank page only with a link labeled 'Found.'.

As similar problems were already mentioned in other issues, I tried different approaches to the problem and ended up overriding the merged AndroidManifest.xml.

This is what the effective <activity> looked like before overriding:

<activity
    android:name="org.publicvalue.multiplatform.oidc.appsupport.HandleRedirectActivity"
    android:exported="true"
    android:launchMode="1">

    <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="my.custom.app.scheme" />
    </intent-filter>
</activity>

android:launchMode="1" got me wondering, it represents the launch mode singleTop as configured in the plugin at https://github.com/kalinjul/kotlin-multiplatform-oidc/blob/521ca085a3d634d870f146e5396e45270623c800/oidc-appsupport/src/androidMain/AndroidManifest.xml#L22 Trying different launchModes I ended up with a working solution when setting singleTask. So I wrote an override in my projects AndroidManifest.xml like so:

<activity
  android:name="org.publicvalue.multiplatform.oidc.appsupport.HandleRedirectActivity"
  android:launchMode="singleTask"
  tools:replace="android:launchMode"
  tools:ignore="IntentFilterExportedReceiver">
</activity>

Which results in the effective AndroidManifest.xml as:

<activity
    android:name="org.publicvalue.multiplatform.oidc.appsupport.HandleRedirectActivity"
    android:exported="true"
    android:launchMode="2">

    <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="my.custom.app.scheme" />
    </intent-filter>
</activity>

Maybe it is worth considering to change the default launchMode to singleTask? If you need more information just let me know :)

Lazalatin avatar May 14 '25 10:05 Lazalatin