在我的应用程序中,当我点击Facebook登录它进入Safari浏览器时,我创建了Facebook集成,如何在不通过Safari网络浏览器输入的情况下将其更改为对话框登录?

提前致谢 .

[FBSession.activeSession closeAndClearTokenInformation]; if(FBSession.activeSession.accessTokenData.loginType!= FBSessionLoginTypeFacebookApplication / || FBSession.activeSession.accessTokenData.loginType!= FBSessionLoginTypeSystemAccount /){[HUD hide:YES]; HUD = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES]; HUD.labelText = @“登录”; [FBSession openActiveSessionWithReadPermissions:@ [@“basic_info”,@“email”,@“user_location”,@“user_birthday”,@“user_hometown,user_friends”]
allowLoginUI:YES
completionHandler:^(FBSession * session,FBSessionState状态,NSError *错误){

switch(state){
case FBSessionStateOpen:{

[FBSession setActiveSession:session];
[self checkSessionState:state];
[[FBRequest requestForMe] startWithCompletionHandler:^(FBRequestConnection

  • connection,NSDictionary * user,NSError * error){if(error){[HUD hide:YES]; NSLog(@“错误报告:%@”,错误); } else {[HUD hide:YES]; NSString * userLocation = [NSString stringWithFormat:@“%@ \ n \ n”,user.location [@“name”]];
    NSArray * foo = [userLocation componentsSeparatedByString:@“,”];
    NSString * strCity = [foo objectAtIndex:0];
    NSString * strState = [foo objectAtIndex:1];

NSString * linkURL = [NSString stringWithFormat:@“http://carzillaapp.com/”];
NSString * pictureURL = @“http://www.friendsmash.com/images/logo_large.jpg”;
// NSString * pictureURL = @“”;

//准备本机共享对话框参数
FBShareDialogParams * shareParams = [[FBShareDialogParams alloc] init];
shareParams.link = [NSURL URLWithString:linkURL];
shareParams.name = @“下载和结帐CarZilla App!”;
shareParams.caption = @“在线汽车展厅!”;
shareParams.picture = [NSURL URLWithString:pictureURL];
shareParams.description =
[NSString stringWithFormat:@“那里有新车和旧车!”];

if([FBDialogs canPresentShareDialogWithParams:shareParams]){

[FBDialogs presentShareDialogWithParams:shareParams
clientState:无
handler:^(FBAppCall * call,NSDictionary * results,NSError * error){
if(error){
NSLog(@“错误发布故事 . ”);
} else if(results [@“completionGesture”] &&
[results [@“completionGesture”] isEqualToString:@“cancel”]){NSLog(@“User canceled story publishing . ”); } else {NSLog(@“Story published . ”); }}; } else {

//准备Web对话框参数
NSDictionary * params = @ {
@“name”:shareParams.name,
@“caption”:shareParams.caption,
@“description”:shareParams.description,
@“picture”:pictureURL,
@“link”:linkURL
};

//调用对话框
[FBWebDialogs presentFeedDialogModallyWithSession:nil
参数:PARAMS
处理:
^(FBWebDialogResult结果,NSURL * resultURL,NSError *错误){
if(error){
NSLog(@“错误发布故事 . ”);
} else {
if(result == FBWebDialogResultDialogNotCompleted){
NSLog(@“用户取消故事发布 . ”);
} else {
NSLog(@“故事发布 . ”);
}
}}];
}

NSDictionary * params = @ {
@“name”:shareParams.name,
@“caption”:shareParams.caption,
@“description”:shareParams.description,
@“picture”:pictureURL,
@“link”:linkURL
};

[FBWebDialogs presentRequestsDialogModallyWithSession:nil
消息:[NSString stringWithFormat:@“Checkout CarZilla App!”]
Headers :@“邀请”
参数:PARAMS
handler:^(FBWebDialogResult结果,NSURL * resultURL,NSError *错误)
{if(error){//案例A:启动对话框或发送请求时出错 . NSLog(@“发送请求时出错 . ”); } else {if(result == FBWebDialogResultDialogNotCompleted){//案例B:用户点击了“x”图标NSLog(@“用户取消请求 . ”); } else {NSLog(@“Request Sent . ”); }}}; SignUpViewController * faceblogin = [[SignUpViewController alloc] init];
faceblogin.firstName = [NSString stringWithFormat:@“%@”,user.first_name];
faceblogin.lastName = user.last_name;
faceblogin.email = [user objectForKey:@“email”];
faceblogin.city = strCity;
faceblogin.state = strState;
faceblogin.fblogin = YES;
fbFailure = YES;
fbMsg = YES;
faceblogin.accountType = @“个人买家/卖家”;
//faceblogin.isPhoneno = YES;
[self presentViewController:faceblogin animated:YES completion:nil];
}
}];
打破;
}
案件FBSessionStateClosed:{
[HUD隐藏:是];
NSLog(@“facebook values”);

}
case FBSessionStateClosedLoginFailed:{
[HUD隐藏:是];
if((!fbFailure && fbMsg)|| error.code == 2){
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@“错误”消息:@“不幸的是,我们
无法使用你的Facebook凭证登录你 . “delegate:nil cancelButtonTitle:@”Ok“otherButtonTitles:nil,nil]; fbMsg = NO; [alert show];} [FBSession.activeSession closeAndClearTokenInformation]; break;}默认:break;}}];} else {

的NSLog(@ “账户”); }