解析API - Facebook登录无法在iPhone设备上工作 [英] Parse API - Facebook login not working on the iPhone device
问题描述
当我点击使用Facebook按钮登录时,在IOS simultor上它的工作正常。获取PFUser对象。然后如果我在iPhone设备上运行相同的代码,获取PFUser对象为空。没有错误。
代码:
func loginWithFacebook()
{
print与Facebook)
允许权限= [public_profile]
PFFacebookUtils.logInInBackgroundWithReadPermissions(权限,块:{
(用户:PFUser?,错误:NSError?) - > b $ b print(###############)
if let error = error {
print(error)
} else {
如果let user = user {
print(user)
}
}
})
}
IDE:xcode 7
语言:Swift2
Facebook SDK:4.6.0
解析:1.8。 4
设备:iPhone 5s
我已经验证.plist具有所需的所有密钥。还验证了拼写错误的捆绑标识符。一切都好看Facebook应用程式已启用。
任何帮助?
AppDelegate.swift,我有以下代码:
func应用程序(app:UIApplication,openURL url:NSURL,options:[String :AnyObject]) - > Bool {
return FBSDKApplicationDelegate.sharedInstance()。application(app,openURL:url,sourceApplication:options [UIApplicationOpenURLOptionsSourceApplicationKey] as!String,
annotation:options [UIApplicationOpenURLOptionsOpenInPlaceKey]!)
}
根据 UIApplicationDelegate 中的注释,我们应该使用应用程序: openURL:options :,但仍然不起作用。
@available(iOS,介绍= 4.2,已弃用= 9.0,消息=请使用应用程序:openURL:options:)
可选的public func应用程序(应用程序:UIApplication,openURL url:NSURL,sourceApplication:String?注释:AnyObject) - > Bool
现在我已经更改为以下代码:
$ b $应用程序:UIApplication,
openURL url:NSURL,
sourceApplication:String?
注释:AnyObject) - > Bool {
return FBSDKApplicationDelegate.sharedInstance()。application(
application,
openURL:url,
sourceApplication:sourceApplication,
annotation:annotation)
}
然后,它在模拟器和iPhone设备上开始工作正常。
When I click on login with Facebook button, on the IOS simultor its working fine. Getting PFUser object.Then If I run the same code on the iPhone device, getting PFUser object as null. No error.
Code:
func loginWithFacebook()
{
print("login with facebook")
let permissions = ["public_profile"]
PFFacebookUtils.logInInBackgroundWithReadPermissions(permissions, block: {
(user: PFUser?, error: NSError?) -> Void in
print("################")
if let error = error {
print(error)
} else {
if let user = user {
print(user)
}
}
})
}
IDE : xcode 7 Language : Swift2 Facebook SDK : 4.6.0 Parse: 1.8.4 device: iPhone 5s I have verified .plist is having all keys which are required. Also verified the bundle identifier for typo mistakes. All look good. Facebook app is active.
Any help?
In the AppDelegate.swift, I have the following code:
func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(app, openURL: url, sourceApplication: options["UIApplicationOpenURLOptionsSourceApplicationKey"] as! String,
annotation: options["UIApplicationOpenURLOptionsOpenInPlaceKey"]!)
}
As per comments in the UIApplicationDelegate, we should use application:openURL:options:, but still it is not working.
@available(iOS, introduced=4.2, deprecated=9.0, message="Please use application:openURL:options:")
optional public func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool
Now I have changed to the following code:
func application(application: UIApplication,
openURL url: NSURL,
sourceApplication: String?,
annotation: AnyObject) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(
application,
openURL: url,
sourceApplication: sourceApplication,
annotation: annotation)
}
Then, it started working fine on both simulator and iPhone device.
这篇关于解析API - Facebook登录无法在iPhone设备上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!