在iOS iOS中使用会话处理取消按钮 [英] Handle cancel button in facebook iOS using session

查看:117
本文介绍了在iOS iOS中使用会话处理取消按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  [FBSession setActiveSession:[[FBSession alloc] initWithPermissions :[NSArray arrayWithObjects:@publish_actions,read_stream,user_hometown,user_birthday,email,nil]]]; 

[[FBSession activeSession] openWithBehavior:FBSessionLoginBehaviorForcingWebView completionHandler:
^(FBSession * session,FBSessionState状态,NSError *错误)
{
if(state == FBSessionStateOpen )
{
//使用用户的详细信息并在Facebook上发布
}
}];

现在这对我来说很好。但是如果用户在登录Facebook之前按下关闭/取消按钮怎么办?如果用户按下取消按钮,我需要执行一组语句。我该怎么做
任何帮助将不胜感激。

解决方案

尝试这个




  [FBSession setActiveSession:[[FBSession alloc] initWithPermissions:[NSArray arrayWithObjects:@publish_actions,read_stream ,user_hometown,user_birthday,email,nil]]]; 

[[FBSession activeSession] openWithBehavior:FBSessionLoginBehaviorForcingWebView completionHandler:
^(FBSession * session,FBSessionState状态,NSError *错误)
{
if(state == FBSessionStateOpen )
{
//使用用户的细节并在Facebook上发布
}
else if(state == FBSessionStateClosed)
{
//如果用户不认证
}
else if(steate == FBSessionStateClosedLoginFailed)
{

}

}];



I tried to search this but couldn't find anything useful.

[FBSession setActiveSession:[[FBSession alloc] initWithPermissions:[NSArray arrayWithObjects:@"publish_actions,read_stream,user_hometown,user_birthday,email", nil]]];

    [[FBSession activeSession] openWithBehavior:FBSessionLoginBehaviorForcingWebView completionHandler:
    ^(FBSession *session,FBSessionState state,NSError *error)
    {
        if(state == FBSessionStateOpen)
       {
             // use user's detail and post on Facebook
       }
    }];

Now this works fine for me. But what if user presses close/cancel button before logging into Facebook. I need to execute set of statements if user pressed cancel button. How can i do this. Any help would be appreciated.

解决方案

try this


 [FBSession setActiveSession:[[FBSession alloc] initWithPermissions:[NSArray arrayWithObjects:@"publish_actions,read_stream,user_hometown,user_birthday,email", nil]]];

[[FBSession activeSession] openWithBehavior:FBSessionLoginBehaviorForcingWebView completionHandler:
^(FBSession *session,FBSessionState state,NSError *error)
{
    if(state == FBSessionStateOpen)
   {
         // use user's detail and post on Facebook
   }
   else if(state == FBSessionStateClosed)
  {
       // if user not authenticated
   }
   else if(steate == FBSessionStateClosedLoginFailed)
  {

  }

}];


这篇关于在iOS iOS中使用会话处理取消按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆