目前我的facebook登录会执行以下操作:
对我来说,这些步骤太多了。我想做一些像优步应用程序,它的Facebook登录流程是:
有一篇文章说这是Fast App Switch登录的方式,这是我想要的应用程序,如果安装了facebook应用程序,我希望登录直接完成到应用程序。
我在登录按钮操作时使用了此代码而没有运气:
let fbLoginManager = FBSDKLoginManager()
fbLoginManager.loginBehavior = .native
fbLoginManager.logIn(withReadPermissions: ["public_profile", "email"], from: self) { (result, error) in
let credential = FacebookAuthProvider.credential(withAccessToken: accessToken.tokenString)
// Perform login by calling Firebase APIs..
}
在我的 Info.plist :
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fbXXXXXXXX</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>XXXXXXXX</string>
<key>FacebookDisplayName</key>
<string>My Beautiful App</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
在我的 AppDelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions:launchOptions)
return true
}
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
let handled = FBSDKApplicationDelegate.sharedInstance().application(app, open: url, options: options)
return handled
}
Facebook SDK版本: 4.27.1
使用FBSDKCoreKit(4.27.1) FBSDKLoginKit(4.27.1) FBSDKShareKit(4.27.1)