【发布时间】:2021-04-01 04:59:39
【问题描述】:
我正在构建一个带有电话号码登录的屏幕。我一遍又一遍地检查,项目是新创建的,但是,我得到了这个日志:
7.2.0 - [Firebase/Auth][I-AUT000015] UIApplicationDelegate 必须处理远程通知,电话号码身份验证才能正常工作。 如果禁用了 app delegate swizzling,则 UIApplicationDelegate 收到的远程通知需要转发到 FIRAuth 的 canHandleNotificaton: 方法。
我确实阅读了有关 swizzling 的文档,但我不知道为什么它似乎被禁用,我没有禁用它。我已将 GoogleServices-Info.plist 添加到应用程序中,我在 firebase 面板中添加了应用程序 apn auth 密钥。
我在应用程序中的入口点如下所示:
@main
struct partidulverdeApp: App {
init() {
FirebaseApp.configure()
}
var body: some Scene {
WindowGroup {
MainView()
.onOpenURL { url in
Auth.auth().canHandle(url.absoluteURL)
}
}
}
}
我的 URL 类型属性有一个带有 RESERVED_CLIENT_ID 的条目
我对这个问题非常绝望。任何想法都受到高度赞赏。
编辑1:
我确实阅读了文档并尝试在禁用 swizzling 的情况下处理通知,但我得到了同样的错误:
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication,
didReceiveRemoteNotification notification: [AnyHashable : Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
if Auth.auth().canHandleNotification(notification) {
completionHandler(.noData)
return
}
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
print("Your code here")
return true
}
}
@main
struct partidulverdeApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
init() {
FirebaseApp.configure()
}
var body: some Scene {
WindowGroup {
MainView()
.onOpenURL { url in
Auth.auth().canHandle(url.absoluteURL)
}
}
}
}
【问题讨论】:
-
@koen 我编辑了我的问题。长话短说,我已经尝试了几次,但没有任何结果。我有同样的错误。你知道为什么它不起作用吗?
-
哦,现在我明白了:您已经实现了 -[
application:didReceiveRemoteNotification:fetchCompletionHandler:],但您仍然需要将“remote-notification”添加到您的列表中Info.plist 中支持 UIBackgroundModes。我看看怎么解决。
标签: swift firebase firebase-authentication swiftui