fun openCustomTab()

in core/src/main/kotlin/com/uber/sdk2/core/utils/CustomTabsHelper.kt [49:79]


  fun openCustomTab(
    context: Context,
    customTabsIntent: CustomTabsIntent,
    uri: Uri,
    fallback: CustomTabFallback?,
  ) {
    val packageName = getPackageNameToUse(context)
    if (packageName != null) {
      val connection =
        object : CustomTabsServiceConnection() {
          override fun onCustomTabsServiceConnected(
            componentName: ComponentName,
            client: CustomTabsClient,
          ) {
            client.warmup(0L) // This prevents backgrounding after redirection
            customTabsIntent.intent.setPackage(packageName)
            customTabsIntent.intent.setData(uri)
            customTabsIntent.launchUrl(context, uri)
          }

          override fun onServiceDisconnected(name: ComponentName?) {}
        }
      CustomTabsClient.bindCustomTabsService(context, packageName, connection)
      this.connection = connection
    } else
      fallback?.openUri(context, uri)
        ?: Log.e(
          UBER_AUTH_LOG_TAG,
          "Use of openCustomTab without Customtab support or a fallback set",
        )
  }