質問

I am using Facebook iOS SDK 3.1.1 and has been successfully integrated a lot of Facebook features. Adhering to 3.1.1, I am logging in using

        [FBSession openActiveSessionWithPermissions:permission
                                       allowLoginUI:bAllowLoginUI
                                  completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
                                  [self sessionStateChanged:session state:state error:error];
        }];

Then I need to send "apprequests", and there is no new method to implement in SDK 3.1, so I've to fallback to the deprecated API using Facebook objects and FBDialog.

However, calling the deprecated dialog function:

[m_pFacebook dialog:@"apprequests"
           andParams:params
         andDelegate:delegate];

results in the FBDialog popping up and prompting the user to login again through the dialog. I need to go directly to the apprequests dialog without needing the user to input their credentials again and I am sure there's a way to do it as I've seen it implemented in Diamond Dash and other games.

I've tried setting the m_pFacebook.accessToken with FBSession.activeSession.accessToken, and I have also make sure that m_pFacebook.session is filled with the FBSession's logged in session

Anyone encountered this problem before?

役に立ちましたか?

解決

After some debugging, figured out that the expirationDate of Facebook *m_pFacebook object has not been updated, therefore the _lastAccessTokenUpdate is still in [NSDate distantPast]. The solution is to call

[m_pFacebook fbDialogLogin:session.accessToken expirationDate:session.expirationDate];

when sessionStateChanged to FBSessionStateOpen

- (void) sessionStateChanged:(FBSession*)session state:(FBSessionState)state error:(NSError*)error {
    switch ( state ) {
        case FBSessionStateOpen:
            [m_pFacebook fbDialogLogin:session.accessToken expirationDate:session.expirationDate];
        break;
    }
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top