处理 openURL:使用 Facebook 和 Google [英] Handling openURL: with Facebook and Google

查看:30
本文介绍了处理 openURL:使用 Facebook 和 Google的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中的用户可以使用 2 种服务登录:Facebook 或 Google

user in my app can login using 2 services : Facebook or Google

一切正常,但是,在 :

everything works fine, however, in the :

- (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 check the URL, the code below 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆