gpt4 book ai didi

ios - 串行调度队列不等待

转载 作者:行者123 更新时间:2023-11-28 19:32:43 24 4
gpt4 key购买 nike

我需要使用我的应用程序登录 Facebook,获取一些数据,完成后,还要登录 Firebase。我正在为此使用调度队列,但它不起作用。我的 block 根本不等待彼此完成。

这是我的代码:

dispatch_queue_t loginQueue = dispatch_queue_create("com.balazsvincze.loginQueue", DISPATCH_QUEUE_SERIAL);


//Log in to Facebook
dispatch_async(loginQueue, ^{
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logInWithReadPermissions: @[@"public_profile",@"user_friends"] fromViewController:viewController handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {

if(!error){
NSLog(@"Logged into Facebook");
self.facebookUserID = [[FBSDKAccessToken currentAccessToken] userID];

//Load my profile
[FBSDKProfile loadCurrentProfileWithCompletion:^(FBSDKProfile *profile, NSError *error){
if(!error){
self.name = profile.name;
}

else{
NSLog(@"Could not load profile: %@",error);
completionResult(NO);
return;
}

}];
}

else{
NSLog(@"Could not login: %@",error);
completionResult(NO);
return;
}

}];
});

//Log in to Firebase
dispatch_async(loginQueue, ^{
FIRAuthCredential *credential = [FIRFacebookAuthProvider credentialWithAccessToken:[FBSDKAccessToken currentAccessToken].tokenString];

[[FIRAuth auth] signInWithCredential:credential completion:^(FIRUser *user, NSError *error) {

if(!error){
NSLog(@"Logged into Firebase");
self.firebaseUserID = user.uid;
}

else{
NSLog(@"Could not login: %@",error);
completionResult(NO);
return;
}
}];
});

有什么想法吗?谢谢!

最佳答案

在 Facebook 的完成处理程序中调用 Firebase 登录,一切都会按预期工作

关于ios - 串行调度队列不等待,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42170546/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com