处理openURL:使用Facebook和Google [英] Handling openURL: with Facebook and Google
问题描述
我的应用中的用户可以使用2种服务登录:Facebook或Google
user in my app can login using 2 services : Facebook or Google
一切正常,但是,在:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation: (id)annotation {
...
}
我应该决定拨打Facebook回拨或Google回调
i should decide to call the Facebook callback or Google callback
如果用户拥有应用程序,它很容易,而不是由sourceApplication
决定但是当没有(没有本地Facebook帐户链接,没有FB应用程序,没有GooglePlus应用程序),它链接到浏览器:(我不知道它是来自Facebook还是谷歌
if the user has the apps, its easy, than i decide by the sourceApplication but when not (no native Facebook account linked in, no FB app, no GooglePlus app), it links to the browser :( and i dont know if it is comming from Facebook or Google
有没有办法如何决定调用什么?喜欢
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation: (id)annotation {
// how to decide?
if (facebook) {
return [FBSession.activeSession handleOpenURL:url];
} else if (google) {
return [GPPURLHandler handleURL:url sourceApplication:sourceApplication annotation:annotation];
}
}
推荐答案
我们不需要明确需要检查URL,下面的代码就是这样: -
We don't need to Explicitly need to check the URL, below code does it :-
- (BOOL)application: (UIApplication *)application openURL: (NSURL *)url sourceApplication: (NSString *)sourceApplication annotation: (id)annotation
{
if ([GPPURLHandler handleURL:url sourceApplication:sourceApplication annotation:annotation]) {
return YES;
}else if([FBAppCall handleOpenURL:url sourceApplication:sourceApplication]){
return YES;
}
return NO;
}
这篇关于处理openURL:使用Facebook和Google的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!