2

I'm struggling with an upgrade to SDK 4.0 for iOS. I got the login setup and working just fine as well as app invites (which was the main objective to the upgrade).

Two issues remain:

Previously I could resume the current session on app start with [FBSession openActiveSessionWithReadPermissions:allowLoginUI:completionHandler]. That method is not available anymore and if I call [FBSDKAccessToken currentAccessToken] I get nil. Is this by design or am I missing some steps? To be clear, the user logs in and gets an accessToken. After restart of the app the token is lost and I need to login again with an app switch to Facebook. I'd like to avoid the app switch if possible.

The app invite dialog is presented just fine but it fails when sending the request. I'm using a test user with the iOS simulator. I cannot see any error message to track the issue. Could there be some limitations with the simulator or test user?

Daniel
  • 43
  • 3
  • Hey @Daniel, in order to track for app invite response, I recommend conforming to `FBSDKAppInviteDialogDelegate` then implement two delegate method in there. If there was problem during the process you should see it in `appInviteDialog:didFailWithError:`. You can also see [my note](http://stackoverflow.com/questions/29383395/facebook-app-invites-ios-sdk-v4-0-configuration-and-states/29385325#29385325) on this case. – Vinh Nguyen Apr 03 '15 at 01:00

2 Answers2

4

You should try adding in your AppDelegate didFinishLaunchingWithOptions :

return [[FBSDKApplicationDelegate sharedInstance] application:application
                                    didFinishLaunchingWithOptions:launchOptions];

This would get u [FBSDKAccessToken currentAccessToken] when user is logged in.

Refer to : https://developers.facebook.com/docs/ios/getting-started#startcoding

Dheeraj Singh
  • 5,143
  • 25
  • 33
  • Fantastic! It solved my problem with the login. Can't believe I missed it when it was right there in the docs. Thanks! – Daniel Apr 02 '15 at 10:39
  • Any idea on the app invite issue? I should probably have split them up in two separate questions. – Daniel Apr 02 '15 at 10:41
0

Regarding the app invite dialog, saw similar behaviour but could bypass it by alloc new instance and initiating it, something like this:

    FBSDKAppInviteDialog* dialog = [[FBSDKAppInviteDialog alloc] init];
    if ([dialog canShow]){
        [dialog setContent:content];
        [dialog setDelegate:self];
        [dialog show];
}

probably a bug

Quentin Hayot
  • 7,786
  • 6
  • 45
  • 62
gal
  • 31
  • 3