I have implemented login through facebook using facebook SDK for swift. It works as expected on iOS 10.3, but on iOS 11 it shows and additional popup that asks the user to allow sign in through facebook.com.
This adds one more step in the login process that slows down the login process. Is there a way how to to configure the app to allow this by default, thus remove the annoying popup?
I am using facebook-sdk-swift 0.2.0 (FBSDK version is 4.26.0) added through cocoa pods.
Configuration in info.plist
:
<key>FacebookAppID</key>
<string>xxxxxxxxxxxxxxx</string>
<key>FacebookDisplayName</key>
<string>XXXXX</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>akamaihd.net</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>facebook.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>fbcdn.net</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
</dict>
</dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>facebook</string>
<key>CFBundleURLSchemes</key>
<array>
<string>fbxxxxxxxxxxxxxxx</string>
</array>
</dict>
</array>
Code in AppDelegate
:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
return SDKApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
}
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
return SDKApplicationDelegate.shared.application(app, open: url, options: options)
}
LoginController
has a custom login button with this in handler:
let loginManager = LoginManager()
loginManager.loginBehavior = .native
loginManager.logIn([ .publicProfile, .userFriends, .email, .custom("user_location"), .custom("user_education_history"), .custom("user_work_history") ], viewController: self) { loginResult in
}
I created an app from scratch to test it, shared on GitHub. Still does the same.
If you're having trouble logging into your Facebook account from your Facebook app: Make sure that you have the latest version of the Facebook app, or delete the app and then reinstall it. Try logging in from a mobile browser (example: Safari, Chrome).
To start, go to the home screen on your iPhone (Image 1). Click on the dark blue icon with a white “f” on it to access your Facebook account (this is the Facebook application icon). Type in your, previously established, E-mail address and your Facebook password to log into your account (Image 2).
You can use Facebook to stay connected on many devices including iPhone, iPad, and Android. To see what's new with the app and install the latest version, you can go to the Facebook for Mobile page or visit your phone's app store (ex: iTunes App Store, or Google Play Store).
OK, so after several useless experiments I have been able to find a way to achieve what my client wanted. Aforementioned behavior is the result of a newer version of FBSDK. Once I downgraded from FBSDK 4.26.0 to 4.24.0 (Swift SDK version does not matter), the popup stopped showing. So if you are facing the same problem, and your clients (or you) don't want this popup, this might be a solution for you too.
I don't think facebook guys did this by accident, and this popup can allow some new iOS 11 feature. However, I was not able to distinguish any real new functionality - I only noticed that the newer version does not give you a choice if you want to login using native app or safari, but goes directly for the safari login. But since that was a requirement by my client as well, for me the choice was quite natural.
The message is a standard message used by SFAuthenticationSession
to ask the user for permissions to access safari (excerpt from docs):
If an application uses SFAuthenticationSession, users are prompted by a dialog to give explicit consent, allowing the application to access the website's data in Safari.
UPDATE:
Apparently, Safari uses the "CFBundleName" property as the display name for this dialog. This is usually set to ${PRODUCT_NAME} which equals the last portion of your app's bundle identifier, but you can change it to whatever you like. Of course it is advisable to set it to the actual display name of your app.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With