ios - Firebase 使用电话号码 : use of unresolved identifier AuthAPNSTokenTypeProd and UIBackgroundFetchResultNoData error 进行身份验证

标签 ios firebase swift3 firebase-authentication appdelegate

我正在使用电话号码在 iOS 上将 Authenticate 与 Firebase 集成,并且在此 link. 中的文档中提到的过程的初始实现中出现错误

我按照他们提到的程序安装了 pod 并导入了 firebase SDK。
错误来自以下两种方法:

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
  // Pass device token to auth
  Auth.auth().setAPNSToken(deviceToken, type: AuthAPNSTokenTypeProd)

  // Further handling of the device token if needed by the app
  // ...
}


func application(_ application: UIApplication,
didReceiveRemoteNotification notification: [AnyHashable : Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
if Auth.auth().canHandleNotification(notification) {
    completionHandler(UIBackgroundFetchResultNoData)
    return
  }
  // This notification is not auth related, developer should handle it.
}

它说“ 使用未解析的标识符 'AuthAPNSTokenTypeProd' ”和“ 使用未解析的标识符 'UIBackgroundFetchResultNoData' ”。

我不确定我在实现中缺少的程序。执行过程我经历了很多次,我找不到错误。

最佳答案

请尝试以下代码

Auth.auth().setAPNSToken(deviceToken, type: AuthAPNSTokenType.prod)

还有这个
func application(_ application: UIApplication,
                 didReceiveRemoteNotification notification: [AnyHashable : Any],
                 fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
    if Auth.auth().canHandleNotification(notification) {
        completionHandler(UIBackgroundFetchResult.noData)
        return
    }
    // This notification is not auth related, developer should handle it.
}

关于ios - Firebase 使用电话号码 : use of unresolved identifier AuthAPNSTokenTypeProd and UIBackgroundFetchResultNoData error 进行身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44352917/

相关文章:

ios - 检测是否在空的 UISearchBar 中按下 iOS 键盘上的 "delete"按钮

iphone - UITableView 的动画 UIView

ios - NSTimer 不会停止

ios - 在播放音频时保持 UIButton 处于选中状态

swift - 具有特定代码的 Swift 3 中的 GCRectMake 错误

ios - 无法在 Swift 3/iOS 10 中触发 continueUserActivity

ios - UIKit Dynamics 和 CALayers 与 UIView 分离

java - 如何在firebase数据库中搜索

firebase - 什么是在 Flutter 中使用 Firebase Cloud Functions 的方法。

ios - Swift 包管理器与未版本化包有关的问题(例如 : firebase-ios-sdk)