Facebook login + Firebase + Xcode 8 & Swift 3. ERROR - facebook

Xcode keeps complaining about an ambigous reference I've made in the AppDelegate. I'm trying to integrate Facebook Login with Firebase in my Xcode project using this tutorial.
Error:
Ambiguous reference to member
'application(_:didFinishLaunchingWithOptions:)'
Code:
import UIKit
import CoreData
import Firebase
import FBSDKLoginKit
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
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
}
private func application(_ app: UIApplication, open url: URL, options: UIApplicationOpenURLOptionsKey) -> Bool {
var handled = FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: options[UIApplicationOpenURLOptionsSourceApplicationKey], annotation: options[UIApplicationOpenURLOptionsAnnotationKey]) // Error happens here
// Add any custom logic here.
return handled
}
I'm not sure what what this error means (still new to iOS programming). I've highlighted where it happens in the code with a comment.

import UIKit
import Firebase
import CoreData
import FBSDKCoreKit
import FBSDKLoginKit
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FIRApp.configure()
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
return true
}
func application(_ application: UIApplication, open url: URL, _: NSURL, sourceApplication: String, annotation: AnyObject) -> Bool {
let handled: Bool = FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)
return handled
}

Related

Identify application restart by camera and audio permission change swift

I have a video calling application now issue is that if the user declines the permission and once the user grants the camera access permission then the iOS application restarts then how I can know the application restart due to permission change?
Is there any method called from appdelegate before restart or after restart?
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
}
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return orientationLock
}
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
}
func applicationDidEnterBackground(_ application: UIApplication) {
}
func applicationDidBecomeActive(_ application: UIApplication) {
}
func applicationWillTerminate(_ application: UIApplication) {
}
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: #escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
}

Thread 1: "-[UITableViewController loadView] loaded the \"Bf3-ih-lsC-view-YnG-aC-da7\" nib but didn't get a UITableView."

import UIKit
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Model.shared.loadXMLFile(date: nil)
Model.shared.parseXML()
return true
}
// MARK: UISceneSession Lifecycle
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
}
}
When you create a UITableViewController in your storyboard, its main view must be a UITableView. This error often happens when some other controller type is changed to a UITableViewController but with its old main view still in place.

GIDSignIn.sharedInstance : sharedInstance not a function?

In this code, when I type GIDSignIn.sharedInstance, for some reason sharedInstance is not a function, which means I can't acces clientID. I cannot find a solution for this anywhere.
import UIKit
import GoogleSignIn
#main
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
GIDSignIn.sharedInstance().clientID = "clientID"
return true
}
In latest version of GoogleSignIn SDK. Removed this method.
Now in new follow this link or below code.
https://developers.google.com/identity/sign-in/ios/sign-in
#IBAction func clkLoginWithGmail(_ sender: UIButton) {
let signInConfig = GIDConfiguration.init(clientID: "clientID-XYZ")
GIDSignIn.sharedInstance.signIn(with: signInConfig, presenting: self) { user, error in
}
}

Setter for 'statusBarStyle' was deprecated in iOS 9.0: Use -[UIViewController preferredStatusBarStyle]

How do I rewrite the code snippet according to this;
Setter for 'statusBarStyle' was deprecated in iOS 9.0: Use -[UIViewController preferredStatusBarStyle]
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions:
[UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
UIApplication.shared.statusBarStyle = .lightContent
return true
}
This is the new method for status bar styles
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}

What is use of FBSDKApplicationDelegate during Facebook Login?

In AppDelegate
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)
}
func applicationDidBecomeActive(application: UIApplication) {
FBSDKAppEvents.activateApp()
}
Even I am not using these methods,Login is working fine
and in my logout method
FBSDKAccessToken.setCurrentAccessToken(nil)
FBSDKProfile.setCurrentProfile(nil)
loginView.logOut()
Then what is use of these methods in AppDelegate class?
Generally FBSDKApplicationDelegate post process the results from Facebook Login or Facebook Dialogs (or any action that requires switching over to the native Facebook app or Safari). More explaination could be found on official doc