使用Facebook应用程序时Facebook登录回调不起作用-Swift [英] Facebook login callback not working when using Facebook app - Swift

查看:93
本文介绍了使用Facebook应用程序时Facebook登录回调不起作用-Swift的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在App Store上拥有功能完善的应用程序已有一年多了,其中以Facebook注册为特色,并且一切正常.但是,几天前,我收到用户的抱怨很少,他们说Facebook登录导致该应用滞留在登录屏幕上.我已经调查了这种行为,并且当您使用Facebook应用进行身份验证时,单击登录按钮后来自Facebook的回调似乎不起作用.通过Safari可以正常工作.我已经将Cocoapod库更新为最新版本,并且在AppDelegate中,我具有以下内容:

  func应用程序(_应用程序:UIApplication,didFinishLaunchingWithOptions launchOptions:[UIApplicationLaunchOptionsKey:任何]?)->布尔{FBSDKApplicationDelegate.sharedInstance().application(应用程序,didFinishLaunchingWithOptions:launchOptions)返回真}func application(_ app:UIApplication,打开url:URL,选项:[UIApplicationOpenURLOptionsKey:Any] = [:])->布尔{返回FBSDKApplicationDelegate.sharedInstance().application(应用程序,打开:URL作为URL!,sourceApplication:选项[UIApplicationOpenURLOptionsKey.sourceApplication] as!字符串,注释:选项[UIApplicationOpenURLOptionsKey.annotation])}func applicationDidBecomeActive(_应用程序:UIApplication){FBSDKAppEvents.activateApp()} 

我所有的Plist文件都整齐了,Facebook没有暂停我的应用程序或类似的东西,当我尝试使用Safari登录时,它再次起作用.iOS版本为11,我使用的是Swift3.

解决方案

我认为您已经通过Facebook登录,这可能会导致一些问题最好是使用pod使用Facebook sdk的最新更新,或下载facebook框架的最新版本

  pod'FacebookCore'pod'FacebookLogin'pod'FacebookShare' 

请参阅facebook

并与此同时检查plist信息

 < key> CFBundleURLTypes</key>< array>< dict>< key> CFBundleURLSchemes</key>< array>< string> fb {您的应用程序ID}</string></array></dict></array>< key> FacebookAppID</key>< string> {您的应用程序ID}</string>< key> FacebookDisplayName</key>< string> {您的应用名称}</string>< key> LSApplicationQueriesSchemes</key>< array>< string> fbapi</string>< string> fb-messenger-share-api</string>< string> fbauth2</string>< string> fbshareextension</string></array> 

I had a perfectly functional application on the app store for over a year which featured Facebook signup and it all worked without any problems. However, few days ago I got few complaints from users who say that Facebook login causes the app to get stuck on login screen. I've investigated the behaviour and it seems that the callback from Facebook after clicking on login button does not work when you use Facebook app to authenticate. Going through Safari works. I've updated my Cocoapod libs to the latest version and in my AppDelegate I have the following:

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 {
    return FBSDKApplicationDelegate.sharedInstance().application(app, open: url as URL!, sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as! String, annotation: options[UIApplicationOpenURLOptionsKey.annotation])
}

func applicationDidBecomeActive(_ application: UIApplication) {
    FBSDKAppEvents.activateApp()
}

All my Plist files are in order, Facebook didn't suspend my app or anything similar, and again it works when I try to sign in using Safari. Version of iOS is 11 and i'm using Swift 3.

解决方案

I think you've done a log in via Facebook and this may cause some problems It is best to use the latest update for Facebook sdk using pod or download facebook framework latest version

pod 'FacebookCore'
pod 'FacebookLogin'
pod 'FacebookShare'

see facebook LoginBehavior

based on last update for facebook sdk It should appear this way

And check plist info same this

<key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleURLSchemes</key>
    <array>
      <string>fb{your-app-id}</string>
    </array>
  </dict>
</array>
<key>FacebookAppID</key>
<string>{your-app-id}</string>
<key>FacebookDisplayName</key>
<string>{your-app-name}</string>
<key>LSApplicationQueriesSchemes</key>
<array>
  <string>fbapi</string>
  <string>fb-messenger-share-api</string>
  <string>fbauth2</string>
  <string>fbshareextension</string>
</array>

这篇关于使用Facebook应用程序时Facebook登录回调不起作用-Swift的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆