FB SDK - safari doesn't dismiss - ios

When user tries to auth in app using facebook, safari window doesnt disappear after user grants permissions inside it. Safari reloads page and remains blank, not dismissing and not returning user to app
My appDelegate methods are following
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
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)
}
Where can be the problem ?

Related

IOS Swift using Facebook Login instead of FBSDKLoginKit AppDelegate.swift code

Previously dealing with FBSDKLoginKit, I had to use certain code for my appDelegate.swift for the facebook login to work that are shown below:
import FBSDKLoginKit
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let fbLaunch = FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
return fbLaunch
}
func applicationWillResignActive(_ application: UIApplication) {
FBSDKAppEvents.activateApp()
}
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)
}
Now that I switched to FacebookLogin, whats their code for the above?
Found the answer, had to google around with specific keywords and I think it may be slightly outdated (from 2016) but the answer is in link below:
https://github.com/facebook/facebook-sdk-swift/blob/master/Samples/Catalog/Sources/AppDelegate.swift
It runs on my xcode after compilation

Implementation of application:openURL:sourceApplication:annotation

I started working on the app before the release of Xcode8 and and then switched over , When I try to log into the app using Facebook login I get the following error
Implementation of application:openURL:sourceApplication:annotation: not found. Please add the handler into your App Delegate. Class: GhostGab.AppDelegate
I checked all the settings and they seemed fine . Any help will be appreciated
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FIRApp.configure()
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
return true
}
func application(application: UIApplication, openURL url: URL, sourceApplication: String?, annotation: AnyObject) -> Bool {
let facebookDidHandle = FBSDKApplicationDelegate.sharedInstance().application(
application,
open: url,
sourceApplication: sourceApplication,
annotation: annotation)
// Add any custom logic here.
return facebookDidHandle
}
Your function definition:
func application(application: UIApplication, openURL url: URL, sourceApplication: String?, annotation: AnyObject) -> Bool {
}
Should be replaced by:
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
}
There's an underscore for the first parameter and Any in place of AnyObject for the last parameter type.
That's why you're getting the error:
Implementation of application:openURL:sourceApplication:annotation

Use of unresolved identifier sourceApplication Facebook SDK

The following code to implement FB login into my app
func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
However I keep getting two error messages both similar,
"Use of unresolved identifier 'annotation'
"Use of unresolved identifier 'sourceApplication'
I'm not exactly sure what's causing this error but I have a feeling its a bit of code that's been deprecated. Does anyone know what the current alternative is?
appdelegate.swift
I´m using this code in my app delegate and works perfect
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
}
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
}
You have a variable name mismatch:
You declare your UIApplication as app in the first line, but try to reference it by sourceApplication in your return statement. Replace sourceApplication with app. Same with annotation, change that to options:
func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: app, annotation: options)

FacebookSDK not able to login, giving blank white screen after authorization.

Added URL Type , LSApplicationQueriesSchemes and other settings.
Tried every possible solution, Not able to debug. Please help with this
I solved this by implementing BOTH of these functions, even though facebook's developer website only lists one:
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
}
func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool {
let shouldOpen :Bool = FBSDKApplicationDelegate.sharedInstance().application(
app,
openURL: url,
sourceApplication: options["UIApplicationOpenURLOptionsSourceApplicationKey"] as! String,
annotation: nil)
return shouldOpen
}
For anyone fighting this for swift3 + ios10, make sure your appdelegate looks like:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
}
func applicationWillResignActive(_ application: UIApplication) {
FBSDKAppEvents.activateApp()
}
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)
}
source
If this is helpful for anyone - I had the Facebook login button on a detached controller (specifically within a custom view that presented a separate View Controller). Once I placed the button inside the parent view controller, things worked instantly.

XCode 6.4 Swift - Implementation of Facebook Login Error

I was following this tutorial to implement a Facebook login. I did the exact same thing and checked twice, but get an error while compiling that he doesn't get.
In my AppDelegate.swift:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
{
// Override point for customization after application launch.
return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
}
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool
{
return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
}
and I get this error for the second function: Definition conflicts with previous value, expected declaration.
I hope somebody understands the error here, thanks.

Resources