gpt4 book ai didi

ios - Firebase 身份验证错误 : 'data parameter is nil' calling getIDTokenForcingRefresh

转载 作者:可可西里 更新时间:2023-11-01 01:57:54 29 4
gpt4 key购买 nike

我正在使用适用于 iOS 的 Firebase UI 通过 google 或 facebook 登录我的应用。我刚刚将 pod 更新到这个版本:

Installing FBSDKCoreKit 4.31.1 (was 4.31.0)
Installing FBSDKLoginKit 4.31.1 (was 4.31.0)
Installing Fabric 1.7.6 (was 1.7.5)
Installing Firebase 4.12.0 (was 4.9.0)
Installing FirebaseAnalytics 4.1.0 (was 4.0.9)
Installing FirebaseAuth 4.6.0 (was 4.4.3)
Installing FirebaseCore 4.0.19 (was 4.0.15)
Installing FirebaseInstanceID 2.0.10 (was 2.0.9)
Installing FirebaseMessaging 2.2.0 (was 2.1.0)
Installing FirebaseUI 4.5.5 (was 4.5.1)
Installing GTMSessionFetcher 1.1.15 (was 1.1.14)

但是现在调用 getIDTokenForcingRefresh 时出现错误。这是错误:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'data parameter is nil'

GTMSessionFetcher 的这一部分

- (void)invokeFetchCallbacksOnCallbackQueueWithData:(GTM_NULLABLE NSData *)data
error:(GTM_NULLABLE NSError *)error {
// Callbacks will be released in the method stopFetchReleasingCallbacks:
GTMSessionFetcherCompletionHandler handler;
@synchronized(self) {
GTMSessionMonitorSynchronized(self);

handler = _completionHandler;

if (handler) {
[self invokeOnCallbackQueueUnlessStopped:^{
handler(data, error); // <-- Error appends here (data is nil)

// Post a notification, primarily to allow code to collect responses for
// testing.
//
// The observing code is not likely on the fetcher's callback
// queue, so this posts explicitly to the main queue.
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
if (data) {
userInfo[kGTMSessionFetcherCompletionDataKey] = data;
}
if (error) {
userInfo[kGTMSessionFetcherCompletionErrorKey] = error;
}
[self postNotificationOnMainThreadWithName:kGTMSessionFetcherCompletionInvokedNotification
userInfo:userInfo
requireAsync:NO];
}];
}
} // @synchronized(self)
}

这是我的代码:

func authUI(_ authUI: FUIAuth, didSignInWith authDataResult: AuthDataResult?, error: Error?) {
if let error = error {
print(error)
return
}
if let authDataResultUser = authDataResult?.user {
authDataResultUser.getIDTokenForcingRefresh(true) { idToken, error in
if error != nil {
print()
return
}
// .....
}
}
}

最佳答案

这是 Firebase iOS SDK 的错误,现在已修复。根据 here,此修复程序将作为 4.12.1 发布.链接还包含发布前的解决方法说明。

或者,如果您想要您的 Pod:

我能够在我的项目中成功使用以下版本。我在我的 Podfile 中查找所有特定版本的 Firebase 库时遇到了一些麻烦,不得不改用 .lock 文件。我能够在我的项目中成功使用以下版本。如果您运行 pod install,Cocoapods 将解析不在您的 Podfile.lock 中的任何依赖项。根据 Cocoapods docs ,

For pods listed in the Podfile.lock, it downloads the explicit version listed in the Podfile.lock without trying to check if a newer version is available

我的建议是尝试将 Podfile.lock 中对 Firebase 的引用替换为以下内容,直到 Firebase SDK 团队解决此问题:

PODS:
- Firebase/Auth (4.8.2):
- Firebase/Core
- FirebaseAuth (= 4.4.2)
- Firebase/Core (4.8.2):
- FirebaseAnalytics (= 4.0.9)
- FirebaseCore (= 4.0.14)
- Firebase/Database (4.8.2):
- Firebase/Core
- FirebaseDatabase (= 4.1.4)
- Firebase/DynamicLinks (4.8.2):
- Firebase/Core
- FirebaseDynamicLinks (= 2.3.2)
- Firebase/Firestore (4.8.2):
- Firebase/Core
- FirebaseFirestore (= 0.10.0)
- Firebase/Messaging (4.8.2):
- Firebase/Core
- FirebaseMessaging (= 2.0.8)
- Firebase/Performance (4.8.2):
- Firebase/Core
- FirebasePerformance (= 1.1.1)
- Firebase/Storage (4.8.2):
- Firebase/Core
- FirebaseStorage (= 2.1.2)
- FirebaseAnalytics (4.0.9):
- FirebaseCore (~> 4.0)
- FirebaseInstanceID (~> 2.0)
- "GoogleToolboxForMac/NSData+zlib (~> 2.1)"
- nanopb (~> 0.3)
- FirebaseAuth (4.4.2):
- FirebaseAnalytics (~> 4.0)
- "GoogleToolboxForMac/NSDictionary+URLArguments (~> 2.1)"
- GTMSessionFetcher/Core (~> 1.1)
- FirebaseCore (4.0.14):
- "GoogleToolboxForMac/NSData+zlib (~> 2.1)"
- FirebaseDatabase (4.1.4):
- FirebaseAnalytics (~> 4.0)
- FirebaseCore (~> 4.0)
- leveldb-library (~> 1.18)
- FirebaseDynamicLinks (2.3.2):
- FirebaseAnalytics (~> 4.0)
- FirebaseFirestore (0.10.0):
- FirebaseAnalytics (~> 4.0)
- FirebaseCore (~> 4.0)
- gRPC-ProtoRPC (~> 1.0)
- leveldb-library (~> 1.18)
- Protobuf (~> 3.1)
- FirebaseInstanceID (2.0.8):
- FirebaseCore (~> 4.0)
- FirebaseMessaging (2.0.8):
- FirebaseAnalytics (~> 4.0)
- FirebaseCore (~> 4.0)
- FirebaseInstanceID (~> 2.0)
- GoogleToolboxForMac/Logger (~> 2.1)
- Protobuf (~> 3.1)
- FirebasePerformance (1.1.1):
- FirebaseAnalytics (~> 4.0)
- FirebaseInstanceID (~> 2.0)
- FirebaseSwizzlingUtilities (~> 1.0)
- GoogleToolboxForMac/Logger (~> 2.1)
- "GoogleToolboxForMac/NSData+zlib (~> 2.1)"
- GTMSessionFetcher/Core (~> 1.1)
- Protobuf (~> 3.1)
- FirebaseStorage (2.1.2):
- FirebaseAnalytics (~> 4.0)
- FirebaseCore (~> 4.0)
- GTMSessionFetcher/Core (~> 1.1)
- FirebaseSwizzlingUtilities (1.0.0)
- FirebaseUI (4.5.1):
- FirebaseUI/All (= 4.5.1)
- FirebaseUI/All (4.5.1):
- FirebaseUI/Auth
- FirebaseUI/Database
- FirebaseUI/Facebook
- FirebaseUI/Firestore
- FirebaseUI/Google
- FirebaseUI/Phone
- FirebaseUI/Storage
- FirebaseUI/Twitter
- FirebaseUI/Auth (4.5.1):
- Firebase/Auth (~> 4.2)
- FirebaseUI/Database (4.5.1):
- Firebase/Database (~> 4.0)
- FirebaseUI/Facebook (4.5.1):
- FBSDKLoginKit (~> 4.0)
- FirebaseUI/Auth
- FirebaseUI/Firestore (4.5.1):
- Firebase/Firestore
- FirebaseUI/Google (4.5.1):
- FirebaseUI/Auth
- GoogleSignIn (~> 4.0)
- FirebaseUI/Phone (4.5.1):
- FirebaseUI/Auth
- FirebaseUI/Storage (4.5.1):
- Firebase/Storage (~> 4.0)
- SDWebImage (~> 4.0)
- FirebaseUI/Twitter (4.5.1):
- FirebaseUI/Auth
- TwitterKit (~> 3.0)

关于ios - Firebase 身份验证错误 : 'data parameter is nil' calling getIDTokenForcingRefresh,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49771555/

29 4 0