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 tutorial. I am not 100% sure how it works but this part in my "AppDelegate.m" seems important.
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
return [FBSession.activeSession handleOpenURL:url];
}
So far so good. Now I want to implement a similar login for instagram so that the user can access their photos. I run this example without a problem (https://github.com/crino/instagram-ios-sdk). When I tried to import this into my project I got stuck. Because in instagram project there is also a function in the AppDelegate (IGAppDelegate)
-(BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
return [self.instagram handleOpenURL:url];
}
Now I cant use this function (since it is a duplicate of Facebook one) Is there a way to combine these two function for facebook and instagram (maybe with an "if" for different URLs). Or am I lost
PS: I noticed that when I call my facebook login app the url is something like
fb4333597123414933://authorize/#access_token=BAAGKI2vHLxUBANbDegkrdoc4GJWUZC2clqLAzxz8IxEBZBdEyjrD2oTaGZA0g2AbSGWgvEhONKM6xJWzLCALGUBguqUpor6kXu9ZBewusNZCUe6BOXYvX&expires_in=5166254
in instagram it is like:
igfd725621c5e44198a5b8ad3f7a0ffa09://authorize#access_token=354172840.fd72562.bf6b3611632d4d00b6cef660ea9d9b6f
- (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;
}
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)
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With