AOne iOS SDK接入文档 3.1.获取idtoken 3.1.1.获取方式一(跳转到浏览器) 1. 拼接跳转到浏览器的地址。 2. 配置app的URL types,URL Schemes配置上ctyunaone。 3. 通过web界面完成anoeid的认证,并接收回调数据。 4. 解析回调成功后的idtoken。 3.1.2拼接跳转链接 1. 需要拿到跳转页面的地址,如参考代码中的address。(联系零信任对接人员获取) 2. 需要拿到租户id,如参考代码中的pollid。(联系零信任对接人员获取) 3. 需要拿到认证地址的key,如参考代码中的key。(联系零信任对接人员获取) 参考demo / address:认证页面域名比如 pollid:认证的租户id比如 fsiofjiosfjoaisf key:认证地址的key比如 fjioregjoiertgjo / (NSString)jointUrl:(NSString)address Pollid:(NSString)pollid Key:(NSString)key{ return [NSString stringWithFormat:@"%@/%@/app/%@",address,pollid,key]; } 3.1.3.URLtypes配置参考 特别注意scheme本文全部以"ctyunaone"表示,具体在接入的时候,这个scheme以真实配置的为准(重要),配置方式可参考配置文档: 3.1.4.跳转到web,并接收回调数据 { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:thirdUrl] options:@{} completionHandler:nil]; } (BOOL)application:(UIApplication )app openURL:(NSURL )url options:(NSDictionary )options { return [self handleOpenURL:url]; } //解析url (NSDictionary)parseQueryParameters:(NSURL )url { NSMutableDictionary queryParameters [NSMutableDictionary dictionary]; NSURLComponents urlComponents [NSURLComponents componentsWithURL:url resolvingAgainstBaseURL:NO]; NSArray queryItems urlComponents.queryItems; for (NSURLQueryItem queryItem in queryItems) { if (queryItem.value) { queryParameters[queryItem.name] queryItem.value; } } return [queryParameters copy]; // 返回不可变字典 } //处理回调url (BOOL)handleOpenURL:(NSURL)url { NSLog(@"URL end with 'aa': %@", url.absoluteString); if ([url.absoluteString hasPrefix:@"ctyunaone://aoneid"]) { // 在这里处理以 "aa" 开头的 URL NSDictionary queryDic [self parseQueryParameters:url]; NSLog(@"URL starts with 'aa': %@", url.absoluteString); // 发送通知 NSDictionary userInfo @{@"url": url, @"query": queryDic}; // 可选的用户信息 [[NSNotificationCenter defaultCenter] postNotificationName:@"AoneidLoginNotification" object:nil userInfo:userInfo]; NSLog(@"Notification sent: %@", userInfo); return YES; // 返回 YES 表示成功处理 } // 处理其他 URL return NO; // 返回 NO 表示未处理该 URL }