Firebase Magic Link in Jetpack Compose

huangapple go评论79阅读模式
英文:

Firebase Magic Link in Jetpack Compose

问题

我正在使用 Android 进行 Firebase 的无密码身份验证。魔法链接通过电子邮件接收,但只在 Chrome 中打开指定的 URL,而不是我的应用程序。以下是客户端的设置,如果有相关的代码缺失,请告诉我。我还在我的站点的根目录发布了 .well-known/assetlinks.json,希望它会有所帮助,但没有效果。

<!-- 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() 
}
英文:

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.

&lt;!-- AndroidManifest.xml --&gt;
&lt;intent-filter&gt;
  &lt;action android:name=&quot;android.intent.action.VIEW&quot; /&gt;
  &lt;category android:name=&quot;android.intent.category.DEFAULT&quot; /&gt;
  &lt;category android:name=&quot;android.intent.category.BROWSABLE&quot; /&gt;
  &lt;data android:host=&quot;es0329.com&quot; android:scheme=&quot;https&quot; /&gt;
&lt;/intent-filter&gt;
// Screens.kt
sealed class Screens {
  object Feed : Screens(
    route = &quot;feed&quot;,
    title = R.string.feed,
    icon = Icons.Rounded.TravelExplore
) {
  val deepLinks: List&lt;NavDeepLink&gt; = listOf(
    navDeepLink {
      uriPattern = &quot;$deepLinkBaseUrl$route&quot;
      action = Intent.ACTION_VIEW
    })
  }
}

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

答案1

得分: 2

打开 intent-filter 标签中缺少了 autoVerify 属性。

&lt;intent-filter android:autoVerify=&quot;true&quot;&gt;
  &lt;action android:name=&quot;android.intent.action.VIEW&quot; /&gt;
  &lt;category android:name=&quot;android.intent.category.DEFAULT&quot; /&gt;
  &lt;category android:name=&quot;android.intent.category.BROWSABLE&quot; /&gt;
  &lt;data android:host=&quot;es0329.com&quot; android:scheme=&quot;https&quot; /&gt;
&lt;/intent-filter&gt;
英文:

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

&lt;intent-filter android:autoVerify=&quot;true&quot;&gt;
  &lt;action android:name=&quot;android.intent.action.VIEW&quot; /&gt;
  &lt;category android:name=&quot;android.intent.category.DEFAULT&quot; /&gt;
  &lt;category android:name=&quot;android.intent.category.BROWSABLE&quot; /&gt;
  &lt;data android:host=&quot;es0329.com&quot; android:scheme=&quot;https&quot; /&gt;
&lt;/intent-filter&gt;

huangapple
  • 本文由 发表于 2023年2月18日 18:17:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/75492642.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定