更新时间:2023-08-30 08:48:58
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
现在我已经更改为以下代码:
然后,它在模拟器和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.