在iOS(Facebook和Instagram)中处理不同的URL方案 [英] Handling different URL Schemes in iOS (Facebook and Instagram)

查看:168
本文介绍了在iOS(Facebook和Instagram)中处理不同的URL方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我甚至不确定如何定义问题,但现在就这样了。

I am not even sure how to define the problem but here it goes.

我有一个使用Facebook SDK进行用户登录的应用程序。我按照Facebook授权教程。我不是100%确定它是如何工作的,但我的AppDelegate.m中的这一部分似乎很重要。

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];
}

到目前为止一切顺利。现在我想为instagram实现类似的登录,以便用户可以访问他们的照片。我运行这个例子没有问题( https://github.com/crino/instagram-ios-sdk ) 。当我试图将它导入我的项目时,我遇到了困难。因为在Instagram项目中,AppDelegate中还有一个函数(IGAppDelegate)

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];
}

现在我无法使用此功能(因为它是Facebook的副本)
有没有办法将这两个功能合并到facebook和Instagram上(对于不同的URL可能带有if)。或者我输了

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:我注意到当我打电话给我的facebook登录应用程序时,网址就像

PS: I noticed that when I call my facebook login app the url is something like

fb4333597123414933 ://授权/#的access_token = BAAGKI2vHLxUBANbDegkrdoc4GJWUZC2clqLAzxz8IxEBZBdEyjrD2oTaGZA0g2AbSGWgvEhONKM6xJWzLCALGUBguqUpor6kXu9ZBewusNZCUe6BOXYvX&安培; expires_in = 5166254

fb4333597123414933://authorize/#access_token=BAAGKI2vHLxUBANbDegkrdoc4GJWUZC2clqLAzxz8IxEBZBdEyjrD2oTaGZA0g2AbSGWgvEhONKM6xJWzLCALGUBguqUpor6kXu9ZBewusNZCUe6BOXYvX&expires_in=5166254

在的Instagram它是这样的:

in instagram it is like:

igfd725621c5e44198a5b8ad3f7a0ffa09 :// authorize#access_token=354172840.fd72562.bf6b3611632d4d00b6cef660ea9d9b6f

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;![enter image description here][1]
    }

这篇关于在iOS(Facebook和Instagram)中处理不同的URL方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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