在iOS 8上登录Facebook;应用程序没有';登录切换后无法工作
我正在使用最新的FBSDKLoginKit(4.10.1)让我的用户通过Facebook进行身份验证。它在iOS 9上运行得非常好,但在iOS 8上却不行。当用户进行身份验证时,应用程序将切换到本机facebook应用程序或safari进行登录。登录后,应用程序将切换回我的应用程序,但随后什么也没有发生。未执行处理程序块。完全相同的代码可以在iOS 9上运行,但不能在iOS 8上运行。我注意到,当我的应用程序切换到safari进行身份验证时,xcode的调试器与模拟器分离;所以我不能发现任何错误。这在iOS 9上不会发生 这是我的登录代码:在iOS 8上登录Facebook;应用程序没有';登录切换后无法工作,ios,swift,facebook,facebook-login,fbsdk,Ios,Swift,Facebook,Facebook Login,Fbsdk,我正在使用最新的FBSDKLoginKit(4.10.1)让我的用户通过Facebook进行身份验证。它在iOS 9上运行得非常好,但在iOS 8上却不行。当用户进行身份验证时,应用程序将切换到本机facebook应用程序或safari进行登录。登录后,应用程序将切换回我的应用程序,但随后什么也没有发生。未执行处理程序块。完全相同的代码可以在iOS 9上运行,但不能在iOS 8上运行。我注意到,当我的应用程序切换到safari进行身份验证时,xcode的调试器与模拟器分离;所以我不能发现任何错误
@IBAction func login(sender: AnyObject) {
let facebookLogin = FBSDKLoginManager()
facebookLogin.logInWithReadPermissions(["public_profile", "email", "user_friends"], fromViewController: self, handler: {
(facebookResult, facebookError) -> Void in
// some logic which isn't executed
})
}
这是我的信息列表:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb190918247921312</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>5</string>
<key>FacebookAppID</key>
<string>190918247921312</string>
<key>FacebookDisplayName</key>
<string>RegelBaas</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<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>UIAppFonts</key>
<array>
<string>Stackyard_PERSONAL_USE.ttf</string>
</array>
<key>UIApplicationExitsOnSuspend</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fbapi20130214</string>
<string>fbapi20130410</string>
<string>fbapi20130702</string>
<string>fbapi20131010</string>
<string>fbapi20131219</string>
<string>fbapi20140410</string>
<string>fbapi20140116</string>
<string>fbapi20150313</string>
<string>fbapi20150629</string>
<string>fbauth</string>
<string>fbauth2</string>
<string>fb-messenger-api20140430</string>
</array>
</dict>
</plist>
我猜我的appdelegate有问题,因为我想我的应用程序无法识别从safari/FB本机到我的应用程序的返回开关。奇怪的是,在iOS 9中,一切都很好
- “在iOS 9上工作”是指它可以在iOS 9上的设备上运行。我正在使用iOSSDK9.2进行编译
您找到这个问题的解决方案了吗?是的,我从plist中删除了
UIApplicationExitsOnSuspend
。这一行使我的应用程序每次切换到Safari和Safari时都“重置”。这就是调试器也被分离的原因。我有同样的问题,但我在plist中没有这样的键。还有其他人有解决办法吗?它在ios9和iOS10上工作,但在iOS8上工作
//
// AppDelegate.swift
// RegelBaas
//
// Created by J. Weijland on 12-12-15.
// Copyright © 2015 J. Weijland. All rights reserved.
//
import UIKit
import FBSDKCoreKit
import FBSDKLoginKit
import Batch
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Styling
UINavigationBar.appearance().barTintColor = UIColor(red: 1.0, green: (102/255), blue: (102/255), alpha: 1)
UINavigationBar.appearance().tintColor = UIColor.whiteColor()
FBSDKApplicationDelegate.sharedInstance()
.application(application, didFinishLaunchingWithOptions: launchOptions)
return true
}
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool
{
return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
}
func applicationDidBecomeActive(application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
FBSDKAppEvents.activateApp()
}
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject])
{
}
}