我无法在 iOS 上的 Firebase App Check 中注册我的应用程序

问题描述 投票:0回答:1

我无法访问 Firebase App Check。我正在 SwiftUI 上开发一个应用程序,并决定连接 App Attest 。在 FireBase 控制台中,我注册了我的应用程序,其状态显示“已注册”。我已经在 AppDelegate 中写了连接

class AppDelegate: NSObject, UIApplicationDelegate {
  func application(_ application: UIApplication,
                   didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
    FirebaseApp.configure()
    
    let providerFactory = YourAppCheckProviderFactory()
    AppCheck.setAppCheckProviderFactory(providerFactory)
      
    UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { granted, error in
      print("Permission granted: \(granted)")
    }
    application.registerForRemoteNotifications()

    return true
  }

  func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    // Обработка регистрации удаленных уведомлений
    Auth.auth().setAPNSToken(deviceToken, type: .unknown)
  }

  func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
    // Обработка ошибки регистрации удаленных уведомлений
    print("Failed to register for remote notifications: \(error.localizedDescription)")
  }

  func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
    // Обработка полученных уведомлений
    if Auth.auth().canHandleNotification(userInfo) {
      completionHandler(.noData)
      return
    }
  }
}

当我通过 Xcode 在真实手机上运行应用程序时,控制台会显示此消息

UserInfo={NSLocalizedFailureReason=Too many attempts. Underlying error: Не удалось завершить операцию. The server responded with an error: 
 - URL: https://firebaseappcheck.googleapis.com/v1/projects/xxxx/apps/xxxxx:exchangeDeviceCheckToken 
 - HTTP status code: 400 
 - Response body: {
  "error": {
    "code": 400,
    "message": "App not registered: xxxxx",
    "status": "FAILED_PRECONDITION"

我无法使用它。我重新检查了 Firebase 中的所有数据,一切都正确。我需要做什么?

swift firebase swiftui firebase-app-check ios-app-attest
1个回答
0
投票

请务必按照 https://firebase.google.com/docs/app-check/ios/debug-provider

中的说明进行操作
© www.soinside.com 2019 - 2024. All rights reserved.