Problems migrating from Facebook iOS SDK 2.x to 3.x

We want to upgrade to 3.x so that our users on iOS 6 / iPhone 5 have the most optimized FB experience ... given that I have encountered rewriting FB integration, or is it possible for me to have amortized headers and continue to use API 2.x with 3.1 SDK?

Some of the key methods and requests that we rely on: [ad.facebook authorize: perms], shouldExtendAccessToken, extendAccessTokenIfNeeded, isSessionValid, dialog: @ "feed" and Params: params andDelegate: delegate, "https://graph.facebook.com /me?fields=id.email, first_name & access_token = " , et.al. Some search queries in the examples with examples 3.1 look as if they were all replaced - and I would suggest that this is not just a name change.

I did not find a version from 2.x to 3.x of this Update from 3.0 to 3.1 - if I missed this, please inform.

When you tried to upgrade to 3.0 first, I encountered significant violations (duplicate SBJson headers, not resolving FB headers) when trying to use deprecated APIs, and after compiling it, handleOpenURL seems to be broken and it switches back to FB a second time, then a failure. And I came across messages that indicate that there may be problems with disabling 3.x ARC (we cannot use it since we have C ++).

I did not get 2.x up to 3.1. Perhaps this will go smoothly, but I would like to get some idea from those who walked in front of me to the 2nd long at bat, - thanks so much.

+5
source share
2 answers

. iOS 6 , sdk. . - . :

[ad.facebook authorize: perms]

FBSession *session = [[FBSession alloc] initWithAppID:appId
                                permissions:permissionsArray
                            urlSchemeSuffix:urlSuffix
                         tokenCacheStrategy:nil];

[FBSession setActiveSession:session];
if(allowLoginUI == YES)
{
    [session openWithBehavior:FBSessionLoginBehaviorUseSystemAccountIfPresent completionHandler:handler];
}
else if(session.state == FBSessionStateCreatedTokenLoaded)
{
    [session openWithCompletionHandler:^(FBSession *_session, FBSessionState status, NSError *error) {
        [self _sessionStateChanged:_session state:status error:error];            
    }];
}
[session release];

.
https://developers.facebook.com/docs/howtos/share-appid-across-multiple-apps-ios-sdk/
https://developers.facebook.com/docs/howtos/login-with-facebook-using-ios-sdk/

shouldExtendAccessToken, extendAccessTokenIfNeeded, - , SDK facebook , . , loginUI , FBSessionStateCreatedTokenLoaded, . FBSessionStateCreatedTokenLoaded, :

, , ; , * UX

SessionLoginSample .

isSessionValid -

FBSession.activeSession.isOpen

: @ "feed" Params: params andDelegate: delegate - , facebook, , :

Facebook *facebook = [[Facebook alloc] initWithAppId:FBSession.activeSession.appID andDelegate:nil];
facebook.accessToken = FBSession.activeSession.accessToken;
facebook.expirationDate = FBSession.activeSession.expirationDate;
//... normal code to setup a feed post
[facebook dialog:@"feed" andParams:params andDelegate:self];
[facebook release];

. https://developers.facebook.com/docs/howtos/feed-dialog-using-ios-sdk/

"https://graph.facebook.com/me?fields=id,email,first_name&access_token=",. . .

//[facebook requestWithGraphPath:@"me" andDelegate:self]; would become
[FBRequestConnection startForMeWithCompletionHandler:^
     (FBRequestConnection *connection, id result, NSError *error)   {}];

//[facebook requestWithGraphPath:@"me/albums" andParams:params andHttpMethod:@"POST" andDelegate:self]; would become
  [FBRequestConnection startWithGraphPath:@"me/albums"
                             parameters:params
                             HTTPMethod:@"POST"
                      completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {}];

. https://developers.facebook.com/docs/howtos/batch-requests-ios-sdk/

+9

All Articles