电话号码(续1)

// Pass device token to auth. [[FIRAuth auth] setAPNSToken:deviceToken type:FIRAuthAPNSTokenTypeProd]; // Further handling of the device token if needed by the app. }


要处理推送通知,请在 `application(_:didReceiveRemoteNotification:fetchCompletionHandler:):` 方法中,通过调用 `Auth` 的 `canHandleNotification(_:)` 方法检查 Firebase 身份验证相关的通知。

### Swift

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; it should be handled separately. }


### Objective-C

  • (void)application:(UIApplication )application didReceiveRemoteNotification:(NSDictionary )notification fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { // Pass notification to auth and check if they can handle it. if ([[FIRAuth auth] canHandleNotification:notification]) { completionHandler(UIBackgroundFetchResultNoData); return; } // This notification is not auth related; it should be handled separately. }

如需处理自定义架构重定向网址,请实现 `application(_:open:options:)` 方法,并在其中将该网址传递给 `Auth` 的 `canHandleURL(_:)` 方法。

### Swift

func application(_ application: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool { if Auth.auth().canHandle(url) { return true } // URL not auth related; it should be handled separately. }


### Objective-C

  • (BOOL)application:(UIApplication )app openURL:(NSURL )url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options { if ([[FIRAuth auth] canHandleURL:url]) { return YES; } // URL not auth related; it should be handled separately. }

如果您使用 SwiftUI 或 `UISceneDelegate` 处理重定向网址,请实现 `scene(_:openURLContexts:)` 方法,并在其中将该网址传递给 `Auth` 的 `canHandleURL(_:)` 方法。

### Swift

func scene(_ scene: UIScene, openURLContexts URLContexts: Set&ltUIOpenURLContext&gt) { for urlContext in URLContexts { let url = urlContext.url _ = Auth.auth().canHandle(url) } // URL not auth related; it should be handled separately. }


### Objective-C

  • (void)scene:(UIScene )scene openURLContexts:(NSSet&ltUIOpenURLContext &gt )URLContexts { for (UIOpenURLContext urlContext in URLContexts) { [FIRAuth.auth canHandleURL:urlContext.url]; // URL not auth related; it should be handled separately. } } ```