Problems with fbDidLogin never called iOS

前端 未结 6 1474
死守一世寂寞
死守一世寂寞 2021-01-22 02:18

I\'m having problems with my app saving the access_token. The problem is, when an iPhone hasn\'t the Facebook app installed, safari will handle this and there is no problem. But

相关标签:
6条回答
  • 2021-01-22 02:57

    Double check your controller reference in the handleOpenURL: method on your app delegate. I get the feeling that it may be setting to nil in the background, so Facebook never receives the response.

    0 讨论(0)
  • 2021-01-22 02:59

    That's what it does now. It bails out to the Facebook app if it's installed, or to Safari if it's not. You can explicitly use the dialog interface, but the simplest sample code supplied with the library does its auth business by leaving your app, then coming back after the FB app has handled auth. It works okay, and once you have your head around it (and have it configured properly to return to you), it's fine.

    To prevent re-authentication on each session, request the permission token "offline_access".

    0 讨论(0)
  • 2021-01-22 03:04

    I just had this problem and believe I may have found your solution. When you create the app on facebook you must edit your app settings to allow for native ios app. The ios bundle id selected must match EXACTLY to your bundle ID in the app you are creating. Facebook states that they check this prior to authorizing your app. Funny thing is if you remove the facebook app from the device and then try to authenticate it uses the web browser and seemingly bipasses this "security" completely. This is why Jos solution "works". Facebook doesn't send an error message back so it was a lot of fun to track down. I figured I'd throw this answer out there in hopes to save some future devs some trouble. I hope this helps.

    0 讨论(0)
  • I've found a workaround, which imo is better the using the Facebook app. In the Facebook.m file i've changed this:

      [self authorizeWithFBAppAuth:YES safariAuth:YES];
    

    to this

      [self authorizeWithFBAppAuth:NO safariAuth:YES]; 
    

    In this case users don't leave the app, and everything is handled within the popup without using the Facebook app.

    0 讨论(0)
  • 2021-01-22 03:19

    Have you disabled multi-task on your app via Info.plist? The Facebook SDK makes the (undocumented assumption) that your app supports multi-task.

    By that I mean you have a "Application does not run in background" (UIApplicationExitsOnSuspend) set to YES.

    If that is the case, you're going to have to use login via an in-app browser for which I will update my post and provide a code sample.

    0 讨论(0)
  • 2021-01-22 03:19

    The lines: [self authorizeWithFBAppAuth:YES safariAuth:YES];

    being changed to

    [self authorizeWithFBAppAuth:NO safariAuth:YES];

    is possible only when we have access to Facebook.m (since that's where one would have to make a change)

    In case we're using Facebook's latest static library, we don't get access to the the .m file. In that case how would we be able to achieve the same functionality?

    0 讨论(0)
提交回复
热议问题