Has*_*tab 16 facebook objective-c ios facebook-login
我正在尝试使用Facebook功能实现登录,但我收到了以下错误.
登录失败,错误:无法完成操作.(com.facebook.sdk.login错误304.)
这是我的代码
- (void)loginWithFacebook {
NSString *const read_actions = @"email";
[[[FBSDKLoginManager alloc] init]
logInWithReadPermissions:@[read_actions] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error)
{
if (error) {
NSLog(@"Login Failed with error: %@", error.localizedDescription);
}
else if (result.isCancelled)
{
NSLog(@"Login Failed due to Cancel");
}
else
{
if ([result.grantedPermissions containsObject:read_actions]) {
NSLog(@"Permission granted");
}
}
}];
}
Run Code Online (Sandbox Code Playgroud)
Min*_*oni 38
这可能是因为以前的登录令牌没有被清除.所以在登录之前只需注销.
NSString *const read_actions = @"email";
FBSDKLoginManager *loginManager = [[FBSDKLoginManager alloc] init];
[loginManager logOut];
[loginManager logInWithReadPermissions:@[read_actions]
handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
NSLog(@"Login Failed with error: %@", error.localizedDescription);
}
else if (result.isCancelled) {
NSLog(@"Login Failed due to Cancel");
} else {
if ([result.grantedPermissions containsObject:read_actions]) {
NSLog(@"Permission granted");
}
}
}];
Run Code Online (Sandbox Code Playgroud)
我好像在做
[FBSDKAccessToken refreshCurrentAccessToken:^(FBSDKGraphRequestConnection *connection, id result, NSError *error){}
Run Code Online (Sandbox Code Playgroud)
在登录操作期间的后台线程中.我删除了它,它工作得非常好.
小智 5
在登录 api 之前执行登录操作时注销 fblogin 管理器,例如:-
fbLoginManager.logOut()
fbLoginManager.logIn(withReadPermissions: ["public_profile","email"], from: self) { (result, error) -> Void in
//Your code here
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14462 次 |
| 最近记录: |