4

I am working on Android/Kotlin with Google Chrome Custom Tab, CCT for doing an oAuth for 3rd party server. When oAuth is completed, CCT is supposed to redirects to my redirect_url where, I am catching it in onNewIntent and onCreate. Unfortunately my redirect_url is not being called for the first launch. But it gets called when I relaunch it for second time. What can be the possible cause?

My AndroidManifests.xml:

<activity android:name=".activities.MainActivity"
        android:exported="true"
        android:launchMode="singleTop">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

        <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="test"
                android:host="apps.test.abc.com" />
        </intent-filter>
    </activity>

My MainActivity.kt:

class MainActivity : BaseActivity() {

    override fun onNewIntent(intent: Intent?) {
        super.onNewIntent(intent)
        Logger.v(classTag, "onNewIntent")
    }

    override fun onCreate(onCreate: Bundle?)
        super.onCreate(onCreate)
        Logger.v(classTag, "onCreate")
    }
}

My call to CCT

val builder = CustomTabsIntent.Builder()
val cctIntent = builder.build()
cctIntent.intent.flags = Intent.FLAG_ACTIVITY_NO_HISTORY
cctIntent.intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
cctIntent.launchUrl(mContext, Uri.parse(3RD_PARTY_OAUTH_URL))

When I launch 3RD_PARTY_OAUTH_URL with CCT for the 1st time after oAuth is complete it does not call to test://apps.test.abc.com, But when I call it for the second time it's calling test://apps.test.abc.com may be after getting from cache or cookies. Is there any chance in my native side issue or that is might be fault from 3rd party server side?

Note that for valid redirect_url, web browser works well at the first attempt.

Sazzad Hissain Khan
  • 37,929
  • 33
  • 189
  • 256

0 Answers0