How to Use Both Google+ and Facebook Login in Same Appdelegate.Swift

How to use both google+ and facebook login in same appdelegate.swift

Your application should handle facebook and google links, then return true if one or the other can handle the given link.

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, 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
}

And in 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)

}

how can I integrate facebook login to my ios app when I already have google sign in in appDelegate.swift?

Just add both facebook and google codes in the same function.

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)

// Google sign in code
// ...

return true
}

The return value (true/false) does not really matter. See this topic for explanation.

iOS: Using both Facebook and Google, Google Plus sign in

Here you will have to check [url scheme] before returning. Example code is below.

-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation 
{
NSLog("%@", [url scheme]);

if([[url scheme] isEqualToString:FACEBOOK_SCHEME])
{

return [FBAppCall handleOpenURL:url sourceApplication:sourceApplication];

}
else if([[url scheme] isEqualToString:GOOGLE_PLUS_SCHEME])
{

return [GPPURLHandler handleURL:url sourceApplication:sourceApplication annotation:annotation];

}
}

Hope it will solve your problem..

Is it possible to support both Facebook Login and Google Plus login in the same iOS app?

Since u are added the Google plus, every thing is same for adding the FB login

enter image description here


- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{

return ([FBSession.activeSession handleOpenURL:url] || [GPPURLHandler handleURL:url sourceApplication:sourceApplication annotation:annotation]);

}


hope this Helps :)

Google Sign-in conflicts with Facebook login

Ok folks, eventually I've figured it out.
The trick which worked for me is to initialise Google Sign-In SDK before the Facebook SDK.

now my AppDelegate looks like this:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

// Initialize google sign-in
var configureError: NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
assert(configureError == nil, "Error configuring Google services: \(configureError)")

// init FB SDK
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)

return true
}

Facebook and Google sign in with Swift

This solution works for me

func application(application: UIApplication,
openURL url: NSURL, options: [String: AnyObject]) -> Bool {

return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: options[UIApplicationOpenURLOptionsSourceApplicationKey] as! String, annotation: nil) ||
GIDSignIn.sharedInstance().handleURL(url,
sourceApplication: options[UIApplicationOpenURLOptionsSourceApplicationKey] as? String,
annotation: options[UIApplicationOpenURLOptionsAnnotationKey] as? String)
}

iOS Facebook and Google login at the same time?



Related Topics



Leave a reply



Submit