I am trying to implement phone auth in SwiftUI using Firebase. I keep getting the following error in the console:
If app delegate swizzling is disabled, remote notifications received by UIApplicationDelegate need to be forwarded to FIRAuth's canHandleNotificaton: method.
I have not disabled swizzling from what I know and I have tried different things. I set-up my firebase project correctly, anyone else facing the same problem?
I looked up in the documentation and I found a part about this:
func application(_ application: UIApplication,
didReceiveRemoteNotification notification: [AnyHashable : Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
if Auth.auth().canHandleNotification(notification) {
completionHandler(.noData)
return
}
// This notification is not auth related, developer should handle it.
}
But I don't know where to put it or how to declare it.
Tried doing the following but nothing changes:
import SwiftUI
import Firebase
import GoogleMaps
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
}
// This notification is not auth related, developer should handle it.
}
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
for urlContext in URLContexts {
let url = urlContext.url
Auth.auth().canHandle(url)
}
// URL not auth related, developer should handle it.
}
}
@main
struct partidulverdeApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
init() {
FirebaseApp.configure()
GMSServices.provideAPIKey("AIzaSyAaze5cpEcJUgw2WFgLhlTWYr9ZP4fyDNk")
}
var body: some Scene {
WindowGroup {
MainView()
.onOpenURL(perform: { url in
Auth.auth().canHandle(url)
})
}
}
}