且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

IOS登录IOS在模拟器上工作,但不在安装了本机应用程序的设备上

更新时间:2023-10-21 08:19:04

这是我在应用程序中使用的,您必须允许登录界面。

This is what I use in my apps, you have to allow the login UI.

- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI completionHandler:(FBSessionStateHandler)handler {

// We pass this permissions array into our request.
// I only request email, but there are many more options.
//
NSArray *permissions = @[@"email", @"basic_info"];

return [FBSession
        openActiveSessionWithReadPermissions:permissions
        allowLoginUI:allowLoginUI
        completionHandler:^(FBSession *session,
                            FBSessionState state,
                            NSError *error) {

            if (handler)
                handler(session, state, error);
        }];

}

这就是你如何使用它

        [self openSessionWithAllowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {

            if (!error && status == FBSessionStateOpen) {
                NSString *token = session.accessTokenData.accessToken;

                // You're logged in!

            } else {

                // Something wrong happened

            }
        }];