Search code examples
androidfirebasekotlinfirebase-authenticationjetpack-compose-navigation

Firebase Magic Link in Jetpack Compose


I'm working on Firebase's Passwordless Authentication using Android. The Magic Link is received via email, but clicking it only opens the specified URL in Chrome, instead of my app. Here's how things are setup on the client, let me know if relevant code is missing. I've also posted .well-known/assetlinks.json at the root of my site hoping it would help, to no avail.

<!-- AndroidManifest.xml -->
<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:host="es0329.com" android:scheme="https" />
</intent-filter>
// Screens.kt
sealed class Screens {
  object Feed : Screens(
    route = "feed",
    title = R.string.feed,
    icon = Icons.Rounded.TravelExplore
) {
  val deepLinks: List<NavDeepLink> = listOf(
    navDeepLink {
      uriPattern = "$deepLinkBaseUrl$route"
      action = Intent.ACTION_VIEW
    })
  }
}

companion object {
  const val deepLinkBaseUrl = "https://es0329.com/"
}
// AuthStore.kt
actionCodeSettings {
  url = "${Screens.deepLinkBaseUrl}feed"
  handleCodeInApp = true
  setAndroidPackageName(
    BuildConfig.APPLICATION_ID,
    INSTALL_IF_NOT_AVAILABLE,
    BuildConfig.VERSION_NAME
  )
}
// NavGraph.kt
composable(
  route = Feed.route,
  deepLinks = Feed.deepLinks
) { 
  BreweryList() 
}

Solution

  • The manifest's opening intent-filter tag was missing the autoVerify attribute.

    <intent-filter android:autoVerify="true">
      <action android:name="android.intent.action.VIEW" />
      <category android:name="android.intent.category.DEFAULT" />
      <category android:name="android.intent.category.BROWSABLE" />
      <data android:host="es0329.com" android:scheme="https" />
    </intent-filter>