将两个login系统集成到一个应用程序

我正在尝试将Facebook和Foursquarelogin系统整合到我的应用程序中。 不过,我不知道如何编辑myapp.plist下的URLtypes和URLscheme。 我应该只是在URLscheme下添加一个新项目或创build一个新的URLtypes?

截图

这是Facebooklogin的图像。

看起来你只是想创build一个自定义的URLscheme。 要做到这一点,做这样的事情:

例

然后,发送到设备上的myapp://whatever-url所有URL请求都将被导入到您的应用程序中。 您可以使用以下方法在应用程序的应用程序委托文件中标识它们。 我假设你在URL中获取数据(比如令牌),并且你需要检索这些信息,所以你需要parsing这个URL。

 //Handles URL schemes specified in the info.plist file - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { //Get the URL in string format NSString *urlString = [url absoluteString]; //See if the URL contains part of the URL we're expecting (ie this is the base URL with data like a token appended to it) if ([urlString rangeOfString:@"myapp://url_one"].location != NSNotFound) { //Parse the URL //Reference: http://stackoverflow.com/questions/8756683/best-way-to-parse-url-string-to-get-values-for-keys NSMutableDictionary *queryStringDictionary = [[NSMutableDictionary alloc] init]; NSArray *urlComponents = [urlString componentsSeparatedByString:@"&"]; for (NSString *keyValuePair in urlComponents) { NSArray *pairComponents = [keyValuePair componentsSeparatedByString:@"="]; NSString *key = [pairComponents objectAtIndex:0]; NSString *value = [pairComponents objectAtIndex:1]; //Make sure this is URL decoded //Add the value to an array, dictionary, etc. for usage later here } } return TRUE; } 

myapp可以从字面上做任何你想要的。 这里的目的是发送一个URL,只会引导用户到您的应用程序。 所以,这一定是独一无二的。 例如,不要使用fb因为这是由Facebook应用程序使用的。