gpt4 book ai didi

ios - 将两个登录系统集成到应用程序中

转载 作者:行者123 更新时间:2023-11-28 21:59:27 27 4
gpt4 key购买 nike

我正在尝试将 Facebook 和 Foursquare 登录系统集成到我的应用程序中。但是,我不知道如何在 myapp.plist 下编辑 URL 类型和 URL 方案。我应该只在 URL 架构下添加一个新项目还是创建一个新的 URL 类型?

Screenshot

这是 Facebook 登录的图像。

最佳答案

您似乎只是在尝试创建自定义 URL 方案。为此,请执行以下操作:

Example

然后,所有发送到设备上 myapp://whatever-url 的 URL 请求都将定向到您的应用程序。您可以使用以下方法在应用程序的应用程序委托(delegate)文件中识别它们。我假设您正在获取通过 URL 发送回给您的数据(如 token )并且您需要检索该信息,因此您需要解析 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,该 URL 只会将用户定向到您的应用。所以,这必须是独一无二的。例如,不要使用 fb,因为它已被 Facebook 应用程序使用。

关于ios - 将两个登录系统集成到应用程序中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25459925/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com