私はfacebook SDKとiOS開発者の新人です。ユーザーがfacebookにログインするときにアプリに問題があり、同じアカウントfbを使用してログインすると、アプリには常に次のログインダイアログが表示されます。
fbアカウントが初めてログインしたときにのみアプリにそのダイアログを表示したいのですが、その方法がわかりません。コードは次のとおりです。
- (void)sessionStateChanged:(FBSession *)session state:(FBSessionState) state error:(NSError *)error {
switch (state) {
case FBSessionStateOpen:
if (!error) {
mainViewController *mainView = [self.storyboard instantiateViewControllerWithIdentifier:@"mainView"];
[self.navigationController pushViewController:mainView animated:YES];
// We have a valid session
NSLog(@"User session found");
}
break;
case FBSessionStateClosed:
case FBSessionStateClosedLoginFailed:
[FBSession.activeSession closeAndClearTokenInformation];
break;
default:
break;
}
[[NSNotificationCenter defaultCenter]
postNotificationName:FBSessionStateChangedNotification
object:session];
if (error) {
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"Error"
message:error.localizedDescription
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
}
- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
NSArray *permissions = [[NSArray alloc] initWithObjects:
@"email",
@"user_likes",
nil];
return [FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:allowLoginUI
completionHandler:^(FBSession *session,
FBSessionState state,
NSError *error) {
[self sessionStateChanged:session
state:state
error:error];
}];
}
- (IBAction)authLogin:(id)sender {
[self openSessionWithAllowLoginUI:YES];
}
私はfb sdk 3.2とios simulator 6.1を使用しています