英文:
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.
<!-- 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()
}
答案1
得分: 2
打开 intent-filter 标签中缺少了 autoVerify
属性。
<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>
英文:
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>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论