简体   繁体   中英

Facebook-unity-sdk not using iOS native SSO

I'm working with Unity 4.6 and Facebook Unity SDK 6.0.

On Android things appear swell, but on iOS I don't seem to be utilizing the native Facebook SSO. It constantly reverts to the browser-based login, which really gives off a unprofessional vibe.

I've tested this on ten different devices, all using both Developer certificates.

And I've gone through the following checklist:

  • XCode on running recieves no errors or logs that should indicate anything wrong, yet still uses the old "browserbased" login solution.
  • This also applies when i use the example scene contained in the SDK.
  • The app is enabled for SSO in Facebook Developer console, and the bundle IDs match.
  • The FBXXXXXXXXX URL sceme is in the info.plist and appears just fine in XCode.
  • The FacebookAppID key in the info.pList is also set, and uses the numerical facebook app id.
  • In facebook, the app is open to the general public, has the contact email required, and the iOS bundle is configured.

I've tried with both developer, admin and "stranger" accounts, and not a single one could get the native iOS facebook login.

Have anyone met this ? Most similar cases I could find are over a year old and does not really apply to this.

To get native facebook login on iOS, locate the file FbUnityInterface.mm (Assets/Facebook/Editor/iOS) and find the method -(void)login:(const char *)scope .

In this method replace:

[self.session openWithBehavior:FBSessionLoginBehaviorWithFallbackToWebView]

with this:

[self.session openWithBehavior:FBSessionLoginBehaviorUseSystemAccountIfPresent]

Facebook Unity SDK by defaults doesn't use native iOS logging behavior, which is kind of strange.

There are a few more FBSessionLoginType behaviors, described in FBSession.h which could be found in the FacebookSDK as well:

typedef enum {
    /*! Attempt Facebook Login, ask user for credentials if necessary */
    FBSessionLoginBehaviorWithFallbackToWebView      = 0,
    /*! Attempt Facebook Login, no direct request for credentials will be made */
    FBSessionLoginBehaviorWithNoFallbackToWebView    = 1,
    /*! Only attempt WebView Login; ask user for credentials */
    FBSessionLoginBehaviorForcingWebView             = 2,
    /*! Attempt Facebook Login, prefering system account and falling back to fast app switch if necessary */
    FBSessionLoginBehaviorUseSystemAccountIfPresent  = 3,
    /*! Attempt only to login with Safari */
    FBSessionLoginBehaviorForcingSafari = 4,
} FBSessionLoginBehavior;

In Facebook SDK 7.2 change shareDialogMode in Unity itself in MobileFacebook.cs 在此处输入图片说明

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