简体   繁体   中英

Facebook iOS SDK 3.0 Login Tutorial Issue with FBSession

I am currently trying to put together an app - with the foundation of it being (hopefully) built on the Facebook iOS SDK 3.0 tutorial.

The tutorial I am following is located at: http://developers.facebook.com/docs/tutorials/ios-sdk-tutorial/authenticate/

I have found there to be a few changes throughout the various SDK versions from Facebook when it comes to the final release.

However I do have one final issue before the code will compile:

"No known class method for selector 'sessionOpenWithPermissions:completionHandler:'"

This error refers to the following code:

- (void)openSession
{
    [FBSession sessionOpenWithPermissions:nil completionHandler:
     ^(FBSession *session, FBSessionState state, NSError *error) {
         [self sessionStateChanged:session state:state error:error];
     }];    
}

When looking at the FBSession.h file in Xcode there is no mention of sessionOpenWithPermissions .

Can anyone please help me with regard to this? I am new to Objective-C/Xcode and am learning via trial by fire.

I ran into the same issue, got my code working with the below change.

//REPLACE
[FBSession sessionOpenWithPermissions:nil
                    completionHandler: ^(FBSession *session, FBSessionState state, NSError *error) {
                        [self sessionStateChanged:session state:state error:error];
                    }];

//WITH
[FBSession openActiveSessionWithPermissions:nil
                               allowLoginUI:YES
                          completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
                              [self sessionStateChanged:session state:state error:error];
                          }];

If you alt click on the method you'll get more info on the parameters to pass. openActiveSessionWithPermissions options

It looks like the documentation has a bug. According the API Change log, that class method as been replaced.

FBSession class method sessionOpenWithPermissions:completionHandler: has been removed, instead use the new openActiveSessionWithPermissions:allowLoginUI:completionHandler: class method.

API Change log URL

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM