I am not even sure how to define the problem but here it goes.
I have an application that uses Facebook SDK for user login. I followed the Facebook authorization tut
Swift :-
Example for use both Google+ and Facebook in swift app, both of them require the OpenURL method in the appDelegate.
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?,
annotation: AnyObject?) -> Bool {
println("URL : \(url)")
if(url.scheme!.isEqual("fb1627825840806667")) {
println("Facebook url scheme")
return FBSDKApplicationDelegate.sharedInstance().application(
application,
openURL: url,
sourceApplication: sourceApplication,
annotation: annotation)
} else {
println("Google+ url scheme")
return GIDSignIn.sharedInstance().handleURL(url, sourceApplication: sourceApplication, annotation: annotation)
}
}
For Swift 2.0
//MARK: FACEBOOK , GOOGLE CALLBACK URL METHOD
//google-Firebase signin - IOS 8
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 facebookDidHandle || googleDidHandle
}
//google-Firebase signin - IOS 9
@available(iOS 9.0, *)
func application(application: UIApplication,
openURL url: NSURL, options: [String: AnyObject]) -> Bool {
let facebookDidHandle = FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: options[UIApplicationOpenURLOptionsSourceApplicationKey] as! String, annotation: options[UIApplicationOpenURLOptionsAnnotationKey])
let googleDidHandle = GIDSignIn.sharedInstance().handleURL(url, sourceApplication: options[UIApplicationOpenURLOptionsSourceApplicationKey] as! String, annotation: options[UIApplicationOpenURLOptionsAnnotationKey])
return facebookDidHandle || googleDidHandle
}
I think I found
[url scheme] gives those specific URL schemes
Xcode - multiple URL Schemes
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
NSLog(@"url: %@", [url scheme]);
BOOL callBack;
// Facebook Call back checking.
if ([[url scheme] isEqualToString:@"facebook_url_schema"])
{
callBack = [FBAppCall handleOpenURL:url sourceApplication:sourceApplication];
}
// Instagram call back checking.
else if ([[url scheme] isEqualToString:@"instagram_url_schema"])
{
callBack = [self.instagram handleOpenURL:url];
}
return callBack;
}