# 吉利问卷SDK iOS Product **Repository Path**: node100/geely-survey-sdk-ios ## Basic Information - **Project Name**: 吉利问卷SDK iOS Product - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-07-04 - **Last Updated**: 2025-04-24 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 吉利问卷SDK iOS #### 介绍 吉利问卷SDK #### 安装教程 pod 'geely-survey-ios',:git=>'https://gitee.com/node100/geely-survey-sdk-ios.git' #### 使用说明 1. 初始化 初始化SurveyConfig配置对象 ``` //网关SDK Key (未使用则传空) NSString *netAppKey; //网关SDK密钥 (未使用则传空) NSString *netAppSecret; // oauthCode NSString *appCode; // App主题,适配4个App 0-领克 1-吉利 2-银河 3-几何 AppKey app; // 网络请求host NSString *host; ``` 调用初始化API ``` SurveyConfig config = { @"204642743", // netAppKey @"ZL9jHDvzs1ehK2fL5boo9SAlBNffCm5a", // netAppSecret @"123", // oauthCode LINK, // AppKey @"dev-api-geely.diact.com" // 网络请求host }; [[CemSurveyManager sharedInstance] initWithConfig:config result:nil]; ``` 2. 普通问券view获取 ``` // 获取view类型问券 // pointKey: 点位Key // complete:完成回调,成功返回对应视图 // closed:视图关闭回调 // failure:失败返回错误code或者网络请求失败error - (void)createSurveyWithPointKey:(NSString *)pointKey complete:(void (^)(BOOL success, UIView *surveyView))result onSizeChange:(void (^)(CGSize size))sizeChange onSubmit:(void (^)(void))submit onClosed:(void (^)(UIView *surveyView))closed failure:(nullable void (^)(NSError *error))failure; ``` 使用示例 ``` [[CemSurveyManager sharedInstance] createSurveyWithPointKey:self.pointKey complete:^(BOOL success, UIView * _Nonnull surveyView) { if (success) { dispatch_async(dispatch_get_main_queue(), ^{ surveyView.frame = CGRectMake(20, 220, surveyView.frame.size.width, surveyView.frame.size.height); [self.view addSubview:surveyView]; }); } } onSizeChange:^(CGSize size) { NSLog(@"size>>>>>w=%f h=%f", size.width, size.height); } onSubmit:^{ NSLog(@"onSubmit===>>"); } onClosed:^(UIView * _Nonnull surveyView) { NSLog(@"onClosed===>>"); } failure:^(NSError * _Nonnull error) { NSLog(@"error:%@", error); }]; ``` 3.弹窗view获取 ``` // 获取弹窗类型问券 // pointKey: 点位Key // complete:完成回调,成功返回对应视图 // closed:视图关闭回调 // failure:失败返回错误code或者网络请求失败error - (void)createSurveyDialogWithPointKey:(NSString *)pointKey complete:(void (^)(BOOL success, UIViewController *surveyView))result onSizeChange:(void (^)(CGSize size))sizeChange onSubmit:(void (^)(void))submit onClosed:(void (^)(UIViewController *surveyView))closed failure:(nullable void (^)(NSError *error))failure; ``` 使用示例 ``` [[CemSurveyManager sharedInstance] createSurveyDialogWithPointKey:self.pointKey complete:^(BOOL success, UIViewController * _Nonnull surveyView) { if (success) { dispatch_async(dispatch_get_main_queue(), ^{ [self presentViewController:surveyView animated:YES completion:nil]; }); } } onSizeChange:^(CGSize size) { NSLog(@"size>>>>>w=%f h=%f", size.width, size.height); } onSubmit:^{ NSLog(@"onSubmit===>>"); } onClosed:^(UIViewController * _Nonnull surveyView) { NSLog(@"onClosed===>>"); } failure:^(NSError * _Nonnull error) { NSLog(@"error:%@", error); }]; ``` 4.设置网络请求的customParams ``` // 设置网络请求的customParams // customParams: 传入的customParams值(必须字典类型) // result: 字典count为0返回失败 - (void)setGetSurveyCustomParams: (NSDictionary *) customParams result:(nullable void (^)(BOOL success))result; ``` 使用示例 ``` NSDictionary *dic = @{@"name": @"John",@"age": @30, @"city": @"New York"}; [[CemSurveyManager sharedInstance] setGetSurveyCustomParams:dic result:^(BOOL success) { if (success) { NSLog(@"set CustomParams success"); }else { NSLog(@"set CustomParams fail"); } }]; ``` #### 问题处理 1.报错 ``` Sandbox: rsync.samba(36566) deny(1) file-write-create /Frameworks/Masonry.framework/_CodeSignature ``` 解决方案: 前往Build Settings,搜索User Script Sandboxing为NO 2 由于权限问题导致HTTP请求无法建立连接 解决方案: 目前苹果公司认为HTTP方式交互是不安全的,默认不允许APP使用HTTP与服务器进行交互,默认推荐客户端使用HTTPS和服务器交互数据。如果需要使用HTTP方式发送请求,需要修改项目下的info.plist文件。需要将下面这段配置复制到info.plist的标签内: ``` NSAppTransportSecurity NSAllowsArbitraryLoads ```