1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

FireStore × AppStore で DBにアクセスできずハマった

Posted at

Firestoreに読み書きできない問題が発生

前提

GoogleService-Info.plistはプロジェクト直下のディレクトリに配置済み
AppDelegateはFirebaseの最初の案内に従って設定済み

class AppDelegate: NSObject, UIApplicationDelegate {
  func application(_ application: UIApplication,
                   didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
    let providerFactory = AppCheckDebugProviderFactory()
    AppCheck.setAppCheckProviderFactory(providerFactory)
    FirebaseApp.configure()

    return true
  }
}

@main
struct DeviceFinderIOSApp: App {
  @UIApplicationDelegateAdaptor(AppDelegate.self) var delegate
    var body: some Scene {
        WindowGroup {
            EntrancePage()
        }
    }
}

.p8ファイルをAppCheckに登録済み
スクリーンショット 2024-02-19 23.07.01.png

エラーで詰まった部分

[Firebase/Firestore][I-FST000001] AppCheck failed: 'The operation couldn’t be completed. The server responded with an error: 
 - URL: https://firebaseappcheck.googleapis.com/v1beta/projects/<my-project>/apps/1:<my-app-id>:ios:<id>:exchangeDeviceCheckToken 
 - HTTP status code: 403 
 - Response body: {
  "error": {
    "code": 403,
    "message": "App attestation failed.",
    "status": "PERMISSION_DENIED"
  }
}

解決方法

Firebase公式Use the debug provider in a simulator 1 - 4にてtokenを登録する必要がある。debugビルドの場合は以上のトークンを設定しないと エラーで詰まった部分で表示されるような 403 - Unauthorizedに遭遇する

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?