Facebook-unity-sdk not using iOS native SSO
Asked Answered
T

2

8

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.

Tacita answered 26/11, 2014 at 12:8 Comment(1)
How are you calling FB.Login? Is your app configured to have more than one FB App ID?Milkweed
J
1

In Facebook SDK 7.2 change shareDialogMode in Unity itself in MobileFacebook.cs enter image description here

Johst answered 9/12, 2015 at 16:13 Comment(1)
Im so glad they moved it :)Tacita
D
1

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;
Diocese answered 3/2, 2015 at 9:27 Comment(2)
This is a correct answer anymore, Facebook moved this to C# classesJohst
Good to know - my answer was a only working workaround at the time that question was asked - so it is correct for that FB SDK version.Diocese
J
1

In Facebook SDK 7.2 change shareDialogMode in Unity itself in MobileFacebook.cs enter image description here

Johst answered 9/12, 2015 at 16:13 Comment(1)
Im so glad they moved it :)Tacita

© 2022 - 2024 — McMap. All rights reserved.