快速应用程序切换iOS 11 Facebook登录
当前,我的facebook登录执行以下操作:快速应用程序切换iOS 11 Facebook登录,ios,swift,facebook,Ios,Swift,Facebook,当前,我的facebook登录执行以下操作: 点击“使用fb登录”按钮 请求获得使用“facebook.com”登录的权限 询问是否在Safari View控制器中使用应用程序或通过电子邮件或电话登录 如果选择应用程序:请求打开Facebook应用程序 请求允许fb应用使用您的登录 返回应用程序 这些步骤对我来说太多了。我想做一些类似优步应用的事情,它的facebook登录流是: 点击“使用fb登录”按钮 请求打开Facebook应用程序 请求允许fb应用使用您的帐户登录 返回应用程序 优步的流
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..
}
在myInfo.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>
Facebook SDK版本:4.27.1
使用FBSDKCoreKit(4.27.1)
FBSDKLoginKit(4.27.1)
FBSDKShareKit(4.27.1)
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
}