通过应用程序使用FB中未验证的用户帐户登录Facebook [英] Facebook login via app with unverified user account in FB

查看:123
本文介绍了通过应用程序使用FB中未验证的用户帐户登录Facebook的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用facebook-ios-sdk-3.10,将使用此SDK登录并从FB获取用户详细信息.

I'm using facebook-ios-sdk-3.10, Using this SDK I'll login and fetch user details from FB Its working fine for me.

这是我正在使用的代码

- (IBAction)fbLogin_click:(id)sender
{
    if (AppDelegate.fbsession.state != FBSessionStateCreated) {
        // Create a new, logged out session.
        NSArray *permissions = [NSArray arrayWithObjects:@"offline_access", @"email", @"publish_stream", @"read_stream",@"read_friendlists",@"manage_friendlists",@"friends_about_me",@"publish_actions", nil];

        // create a session object, with defaults accross the board, except that we provide a custom
        // instance of FBSessionTokenCachingStrategy
        AppDelegate.fbsession = [[FBSession alloc] initWithAppID:nil
                                                   permissions:permissions
                                               urlSchemeSuffix:nil
                                            tokenCacheStrategy:nil]; 
    }


    FBSessionLoginBehavior behavior = FBSessionLoginBehaviorForcingWebView; 
    if (AppDelegate.fbsession.state != FBSessionStateCreatedTokenLoaded) {

        // even though we had a cached token, we need to login to make the session usable
        [AppDelegate.fbsession openWithBehavior:behavior completionHandler:^(FBSession *session,
                                                                           FBSessionState status,
                                                                           NSError *error) {
            if (error)
            {
                NSLog(@"Error");
            }

            [self GetFBUserDetails];
        }];      
    }
} 

-(void) GetFBUserDetails
{
    if (AppDelegate.fbsession.isOpen)
    {
        [HUD show:YES];
        // fetch profile info such as name, id, etc. for the open session
        FBRequest *me = [[FBRequest alloc] initWithSession:AppDelegate.fbsession graphPath:@"me"];

        self.pendingRequest= me;

        [me startWithCompletionHandler:^(FBRequestConnection *connection,
                                         NSDictionary<FBGraphUser> *user,
                                         NSError *error) {
            // because we have a cached copy of the connection, we can check
            // to see if this is the connection we care about; a prematurely
            // cancelled connection will short-circuit here
            if (me != self.pendingRequest) {
                return;
            }

            self.pendingRequest = nil;
            //            self.pendingLoginForSlot = -1;

            // we interpret an error in the initial fetch as a reason to
            // fail the user switch, and leave the application without an
            // active user (similar to initial state)
            if (error) {

                return;
            }

            [AppDelegate.fbsession closeAndClearTokenInformation];
            [FBSession.activeSession close];
            [FBSession.activeSession  closeAndClearTokenInformation];
            FBSession.activeSession=nil;

            [self FacebookCustomerRegister:user];
        }];
    }
}

在这种情况下,某些用户创建Facebook帐户而不是通过电子邮件创建他的帐户,当他尝试通过我的应用程序登录时,单击登录"按钮后显示空白屏幕,则没有进一步的操作.我如何通知用户您尚未验证您的FB帐户",并且该帐户不返回我的应用程序.我如何从那里获取响应?请参阅屏幕简短内容.

In such case some user create Facebook account and not very his account through email, when he try to login via my app it shows empty screen after click login button, there is no action further. how can I notify the user "You not yet verify your FB account" and it not return to my app. how can I fetch the response from there ? refer screen short.

我提供了登录详细信息,单击登录按钮后,SDK对此无响应后将显示空白屏幕,并且不返回到应用程序.

I give login details, after click login button that blank screen will appear after this no response from SDK and not return to App.

有人可以帮我吗?

推荐答案

将此代码添加到您的AppDelegate

add this code to your AppDelegate

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation
{
    return [FBSession.activeSession handleOpenURL:url];
} 

了解更多信息: https://developers.facebook.com/docs/ios/login -教程

这篇关于通过应用程序使用FB中未验证的用户帐户登录Facebook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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