Comment utiliser à la fois google + et facebook login dans le même appdelegate.swift

Mon application utilise google + signin et dans mon appdelegate.swift j'ai:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. var configureError: NSError? GGLContext.sharedInstance().configureWithError(&configureError) assert(configureError == nil, "Error configuring Google services: \(configureError)") GIDSignIn.sharedInstance().delegate = self return true } func application(application: UIApplication, openURL url: NSURL, sourceApplication: Ssortingng?, annotation: AnyObject) -> Bool { return GIDSignIn.sharedInstance().handleURL(url, sourceApplication: sourceApplication, annotation: annotation) } 

Maintenant, je voudrais aussi insert le login facebook, mais je dois append dans appdelegate.swift ce code:

 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: Ssortingng?, annotation: AnyObject?) -> Bool { return FBSDKApplicationDelegate.sharedInstance().application( application, openURL: url, sourceApplication: sourceApplication, annotation: annotation) } 

Mais cette erreur de return parce que les fonctions 'application' existent déjà, comment puis-je effectuer à la fois google + et facebook même appdelegate.swift Merci.

Votre application doit gérer les liens facebook and google, puis renvoyer true si l'un or l'autre peut gérer le lien donné.

 func application(application: UIApplication, openURL url: NSURL, sourceApplication: Ssortingng?, annotation: AnyObject) -> Bool { let googleDidHandle = GIDSignIn.sharedInstance().handleURL(url, sourceApplication: sourceApplication, annotation: annotation) let facebookDidHandle = FBSDKApplicationDelegate.sharedInstance().application( application, openURL: url, sourceApplication: sourceApplication, annotation: annotation) return googleDidHandle || facebookDidHandle } 

Et dans didFinishLaunching :

 func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. var configureError: NSError? GGLContext.sharedInstance().configureWithError(&configureError) assert(configureError == nil, "Error configuring Google services: \(configureError)") GIDSignIn.sharedInstance().delegate = self return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions) } 

Dans Swift 3, besoin de faire de cette façon:

Remplacer et implémenter la méthode suivante:

  func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool { let sourceApplication = options[UIApplicationOpenURLOptionsKey.sourceApplication] as? Ssortingng let annotation = options[UIApplicationOpenURLOptionsKey.annotation] let googleHandler = GIDSignIn.sharedInstance().handle( url, sourceApplication: sourceApplication, annotation: annotation ) let facebookHandler = FBSDKApplicationDelegate.sharedInstance().application ( app, open: url, sourceApplication: sourceApplication, annotation: annotation ) return googleHandler || facebookHandler } 

Alors:

 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { PFFacebookUtils.initializeFacebook(applicationLaunchOptions: launchOptions) FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions) var configureError: NSError? GGLContext.sharedInstance().configureWithError(&configureError) assert(configureError == nil, "Error configuring Google services: \(Ssortingng(describing: configureError))") return true }