Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Base.lproj/AddDevice.storyboard
@@ -141,6 +141,7 @@ <constraints> <constraint firstAttribute="height" constant="40" id="vLh-9U-8RO"/> </constraints> <color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <fontDescription key="fontDescription" type="system" pointSize="14"/> <textInputTraits key="textInputTraits" keyboardType="alphabet"/> <connections> @@ -165,6 +166,7 @@ <constraints> <constraint firstAttribute="height" constant="40" id="DjM-dg-5en"/> </constraints> <color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <fontDescription key="fontDescription" type="system" pointSize="14"/> <textInputTraits key="textInputTraits" keyboardType="alphabet"/> <connections> @@ -450,6 +452,7 @@ <constraints> <constraint firstAttribute="height" constant="34" id="FPO-BB-N1L"/> </constraints> <color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <fontDescription key="fontDescription" type="system" pointSize="14"/> <textInputTraits key="textInputTraits" secureTextEntry="YES"/> </textField> @@ -912,7 +915,7 @@ <inferredMetricsTieBreakers> <segue reference="9TP-S2-hhI"/> <segue reference="MFl-yy-ZsP"/> <segue reference="VYk-37-nb6"/> <segue reference="ikM-Zn-H8f"/> </inferredMetricsTieBreakers> <resources> <image name="addDevice_success" width="320" height="185"/> Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Base.lproj/EZMain.storyboard
@@ -2025,10 +2025,11 @@ <subviews> <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="请输入设备名称" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="r1W-d8-Rg7"> <rect key="frame" x="0.0" y="94" width="375" height="40"/> <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <constraints> <constraint firstAttribute="height" constant="40" id="NLX-OK-XZ7"/> </constraints> <color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <fontDescription key="fontDescription" type="system" pointSize="14"/> <textInputTraits key="textInputTraits"/> </textField> Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Global/EZHttpUtil.h
@@ -14,13 +14,16 @@ /// 河东接口网络请求工具类 @interface EZHttpUtil : NSObject /// sharedManager + (id)sharedManager; #pragma mark -接口 /** * @since 河东获取子账号token的接口 * * @param block 回调block */ + (void)getChildToken:(void (^)(NSString *accessToken))block; - (void)getChildToken:(void (^)(NSString *accessToken))block; /** * @since 河东添加设备的接口 @@ -31,7 +34,7 @@ * @param completion 回调block,error为空时表示添加成功 * */ + (void)addDeviceByHDL:(NSString *)deviceSerial - (void)addDeviceByHDL:(NSString *)deviceSerial verifyCode:(NSString *)verifyCode completion:(void (^)(ResponseData *responseData))completion; @@ -43,7 +46,7 @@ * @param completion 回调block,error为空时表示添加成功 * */ + (void)deleteDeviceByHDL:(NSString *)deviceSerial completion:(void (^)(ResponseData *responseData))completion; - (void)deleteDeviceByHDL:(NSString *)deviceSerial completion:(void (^)(ResponseData *responseData))completion; @end Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Global/EZHttpUtil.m
@@ -24,20 +24,29 @@ #define SECRET_KEY @"WeJ8TY88vbakCcnvH8G1tDUqzLWY8yss" #define TIME_OUT 15.0f @implementation EZHttpUtil #pragma mark -接口请求部分 /// sharedManager + (id)sharedManager { static dispatch_once_t once; static id instance; dispatch_once(&once, ^{ instance = [self new]; }); return instance; } /** * @since 河东获取子账号token的接口 * * @param block 回调block */ + (void)getChildToken:(void (^)(NSString *accessToken))block{ - (void)getChildToken:(void (^)(NSString *accessToken))block{ //2.设置请求参数 NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; @@ -65,7 +74,7 @@ * @param completion 回调block,error为空时表示添加成功 * */ + (void)addDeviceByHDL:(NSString *)deviceSerial - (void)addDeviceByHDL:(NSString *)deviceSerial verifyCode:(NSString *)verifyCode completion:(void (^)(ResponseData *responseData))completion{ @@ -92,7 +101,7 @@ * @param completion 回调block,error为空时表示添加成功 * */ + (void)deleteDeviceByHDL:(NSString *)deviceSerial completion:(void (^)(ResponseData *responseData))completion{ - (void)deleteDeviceByHDL:(NSString *)deviceSerial completion:(void (^)(ResponseData *responseData))completion{ //1.设置请求参数 NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; [parameters setValue:deviceSerial forKey:@"deviceSerial"]; @@ -111,7 +120,7 @@ /// 刷新token /// @param block 结果 + (void)refreshHDLToken:(void (^)(BOOL isSuccess))block{ - (void)refreshHDLToken:(void (^)(BOOL isSuccess))block{ //1.设置请求参数 NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; @@ -148,7 +157,7 @@ /// @param apiPath 接口地址 /// @param parameters 请求参数 /// @param completion 请求响应参数 + (void)requestHttpsPost:(NSString *)apiPath - (void)requestHttpsPost:(NSString *)apiPath parameters:(NSMutableDictionary *)parameters completion:(void (^)(ResponseData *responseData))completion{ @@ -176,7 +185,7 @@ /// @param apiPath 接口地址 /// @param parameters 请求参数 /// @param completion 请求响应参数 + (void)requestHttpsBase:(NSString *)apiPath - (void)requestHttpsBase:(NSString *)apiPath parameters:(NSMutableDictionary *)parameters completion:(void (^)(ResponseData *responseData))completion{ @@ -194,7 +203,7 @@ //3.request NSMutableURLRequest * request = [[AFJSONRequestSerializer serializer] requestWithMethod:@"post" URLString:URL parameters:parameters error:nil]; request.timeoutInterval = 10.0f; request.timeoutInterval = TIME_OUT; [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; [request setValue:@"application/json" forHTTPHeaderField:@"Accept"]; [request setValue:GlobalKit.shareKit.hdlAccessToken forHTTPHeaderField:@"Authorization"]; @@ -223,7 +232,7 @@ /** * 基础服务的接口都要校验sign */ +(NSMutableDictionary *)GetSignRequestDictionary:(NSMutableDictionary *)params{ -(NSMutableDictionary *)GetSignRequestDictionary:(NSMutableDictionary *)params{ if(params == NULL){ params =[NSMutableDictionary dictionary]; } @@ -262,7 +271,7 @@ /// 字符串判空 /// @param valueStr 传入判断字符 + (BOOL)stringIsNullOrEmpty:(NSString *)valueStr - (BOOL)stringIsNullOrEmpty:(NSString *)valueStr { if((valueStr == nil || [valueStr isKindOfClass:[NSNull class]] || valueStr.length == 0)){ return YES; @@ -275,7 +284,7 @@ /** MD5转换+转小写 */ + (NSString*)signMD5Encrypt:(NSString *)str - (NSString*)signMD5Encrypt:(NSString *)str { const char *cStr = [str UTF8String]; unsigned char digest[CC_MD5_DIGEST_LENGTH]; @@ -295,7 +304,7 @@ /// </summary> /// <param name="valueStr"></param> /// <returns></returns> +(bool)IfValueNeedSign:(NSString *)valueStr{ -(bool)IfValueNeedSign:(NSString *)valueStr{ if (( [self stringIsNullOrEmpty:valueStr])//判空字符 || ([[valueStr substringToIndex:1] isEqual:@"{"])//判断是否为对象 || ([[valueStr substringToIndex:1] isEqual:@"["])//判断是否为数组 Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Info.plist
@@ -53,9 +53,9 @@ <key>NSLocalNetworkUsageDescription</key> <string>用于wifi配网</string> <key>NSLocationAlwaysAndWhenInUseUsageDescription</key> <string>$(PRODUCT_NAME) App needs Location permission to configure device's network.</string> <string>$(PRODUCT_NAME) App needs Location permission to configure device's network.</string> <key>NSLocationAlwaysUsageDescription</key> <string>$(PRODUCT_NAME) App needs Location permission to configure device's network.</string> <string>$(PRODUCT_NAME) App needs Location permission to configure device's network.</string> <key>NSLocationWhenInUseUsageDescription</key> <string>$(PRODUCT_NAME) App needs Location permission so that you can select location information when posting videos publicly.</string> <key>NSMicrophoneUsageDescription</key> @@ -84,7 +84,5 @@ <array> <string>UIInterfaceOrientationPortrait</string> </array> <key>UIUserInterfaceStyle</key> <string>Light</string> </dict> </plist> Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/UIViewControllers/EZAPConfigResultViewController.m
@@ -136,18 +136,33 @@ } else { [EZOpenSDK addDevice:[GlobalKit shareKit].deviceSerialNo // [EZOpenSDK addDevice:[GlobalKit shareKit].deviceSerialNo // verifyCode:[GlobalKit shareKit].deviceVerifyCode // completion:^(NSError *error) { // if (error) // { // [self addErrorProcessWithError:error]; // } // else // { // [self successProcess]; // } // }]; [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo verifyCode:[GlobalKit shareKit].deviceVerifyCode completion:^(NSError *error) { if (error) completion:^(ResponseData *responseData) { if (!responseData.success) { [self addErrorProcessWithError:error]; [self addErrorProcessWithError:responseData]; } else { [self successProcess]; } }]; } }]; } @@ -181,18 +196,42 @@ [self.view makeToast:msg duration:2.0 position:@"center"]; } - (void) addErrorProcessWithError:(NSError *) error //- (void) addErrorProcessWithError:(NSError *) error //{ // NSString *msg = nil; // if (error.code == 120010) // { // msg = NSLocalizedString(@"device_verify_code_wrong", @"验证码错误"); // } // else if (error.code == 120020) // { // msg = NSLocalizedString(@"ad_already_added", @"您已添加过此设备"); // } // else if (error.code == 120022) // { // msg = NSLocalizedString(@"ad_added_by_others", @"此设备已被别人添加"); // } // else // { // msg = NSLocalizedString(@"wifi_add_fail", @"添加失败"); // } // // [self.view makeToast:msg duration:2.0 position:@"center"]; // self.msgLabel.hidden = YES; //} - (void) addErrorProcessWithError:(ResponseData *)responseData { NSString *msg = nil; if (error.code == 120010) if ([responseData.code isEqual: @"20010"]) { msg = NSLocalizedString(@"device_verify_code_wrong", @"验证码错误"); } else if (error.code == 120020) else if ([responseData.code isEqual: @"20017"]) { msg = NSLocalizedString(@"ad_already_added", @"您已添加过此设备"); } else if (error.code == 120022) else if ([responseData.code isEqual: @"20013"]) { msg = NSLocalizedString(@"ad_added_by_others", @"此设备已被别人添加"); } Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/UIViewControllers/EZDeviceResultViewController.m
@@ -90,7 +90,7 @@ // [self handleTheError:error]; // }]; [EZHttpUtil addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo verifyCode:[GlobalKit shareKit].deviceVerifyCode completion:^(ResponseData *responseData) { [hud hide:YES]; @@ -127,7 +127,7 @@ // [hud hide:YES]; // [self handleTheError:error]; // }]; [EZHttpUtil addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo verifyCode:[GlobalKit shareKit].deviceVerifyCode completion:^(ResponseData *responseData) { [hud hide:YES]; Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/UIViewControllers/EZSettingViewController.m
@@ -377,7 +377,7 @@ // } // }]; [EZHttpUtil deleteDeviceByHDL:self.deviceInfo.deviceSerial completion:^(ResponseData *responseData) { [EZHttpUtil.sharedManager deleteDeviceByHDL:self.deviceInfo.deviceSerial completion:^(ResponseData *responseData) { if(responseData.success) { [hud hide:YES]; Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/UIViewControllers/EZWifiConfigViewController.m
@@ -107,10 +107,17 @@ self.enState = STATE_PLAT; [self createTimerWithTimeOut:30]; [GlobalKit shareKit].deviceVerifyCode = [alertView textFieldAtIndex:0].text; [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo // [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo // verifyCode:[GlobalKit shareKit].deviceVerifyCode // completion:^(NSError *error) { // [self handleTheError:error]; // }]; //2021-03-03 添加设备的方法都修改成河东的接口方法 [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo verifyCode:[GlobalKit shareKit].deviceVerifyCode completion:^(NSError *error) { [self handleTheError:error]; completion:^(ResponseData *responseData) { // [hud hide:YES]; [self handleTheError:responseData]; }]; } else if (alertView.tag == 0xbb && buttonIndex == 1) @@ -158,10 +165,15 @@ [weakSelf createTimerWithTimeOut:30]; if([GlobalKit shareKit].deviceVerifyCode != nil) { [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo // [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo // verifyCode:[GlobalKit shareKit].deviceVerifyCode // completion:^(NSError *error) { // [weakSelf handleTheError:error]; // }]; [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo verifyCode:[GlobalKit shareKit].deviceVerifyCode completion:^(NSError *error) { [weakSelf handleTheError:error]; completion:^(ResponseData *responseData) { [weakSelf handleTheError:responseData]; }]; } else @@ -241,18 +253,33 @@ { if ([GlobalKit shareKit].deviceVerifyCode != nil) { [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo // [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo // verifyCode:[GlobalKit shareKit].deviceVerifyCode // completion:^(NSError *error) { // if (!error) // { // [self handleTheError:error]; // } // else // { // [self showFailedView]; // } // }]; [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo verifyCode:[GlobalKit shareKit].deviceVerifyCode completion:^(NSError *error) { if (!error) completion:^(ResponseData *responseData) { if (responseData.success) { [self handleTheError:error]; [self handleTheError:responseData]; } else { [self showFailedView]; } }]; } else { @@ -683,11 +710,50 @@ self.failedTipsView.hidden = NO; } - (void)handleTheError:(NSError *)error //- (void)handleTheError:(NSError *)error //{ // [EZOPENSDK stopConfigWifi]; // // if (!error) // { // if ([_countTimer isValid]) // { // [_countTimer invalidate]; // _countTimer = nil; // } // _enState = STATE_SUCC; // [self showTipsView]; // return; // } // // if (error.code == 120010) // { // UIAlertView *retryAlertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"device_verify_code_wrong", @"验证码错误") // message:nil delegate:self // cancelButtonTitle:NSLocalizedString(@"cancel", @"取消") // otherButtonTitles:NSLocalizedString(@"retry", @"重试"), nil]; // retryAlertView.tag = 0xbb; // [retryAlertView show]; // } // else if (error.code == 120020) // { // [UIView dd_showMessage:NSLocalizedString(@"ad_already_added", @"您已添加过此设备")]; // } // else if (error.code == 120022) // { // [UIView dd_showMessage:NSLocalizedString(@"ad_added_by_others", @"此设备已被别人添加")]; // } // else // { // [UIView dd_showMessage:NSLocalizedString(@"wifi_add_fail", @"添加失败")]; // } //} - (void)handleTheError:(ResponseData *)responseData { [EZOPENSDK stopConfigWifi]; if (!error) if (responseData.success) { if ([_countTimer isValid]) { @@ -699,7 +765,7 @@ return; } if (error.code == 120010) if ([responseData.code isEqual: @"20010"]) { UIAlertView *retryAlertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"device_verify_code_wrong", @"验证码错误") message:nil delegate:self @@ -708,11 +774,11 @@ retryAlertView.tag = 0xbb; [retryAlertView show]; } else if (error.code == 120020) else if ([responseData.code isEqual: @"20017"]) { [UIView dd_showMessage:NSLocalizedString(@"ad_already_added", @"您已添加过此设备")]; } else if (error.code == 120022) else if ([responseData.code isEqual: @"20013"]) { [UIView dd_showMessage:NSLocalizedString(@"ad_added_by_others", @"此设备已被别人添加")]; } @@ -721,7 +787,6 @@ [UIView dd_showMessage:NSLocalizedString(@"wifi_add_fail", @"添加失败")]; } } #pragma mark - Action Methods - (void)completionButtonClicked:(id)sender Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/ViewController.m
@@ -55,15 +55,15 @@ // */ // [self performSegueWithIdentifier:@"go2CameraList" sender:nil]; [EZSDK setHDlAccessToken:@"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJqdGkiOiJmZDgyMDY0ZmJmMGE0YTdmOWFhMmVhOTA0Y2FmNDY3MyIsInJvbGUiOiIiLCJoZWFkZXJQcmVmaXgiOiJCZWFyZXIgIiwidXNlckFjY291bnQiOiIxODgyNDg2NDE0MyIsInRlbmFudElkIjoiMjAiLCJ1c2VyVHlwZSI6IlVTRVJfQyIsInRva2VuVHlwZSI6ImFjY2Vzc190b2tlbiIsInVzZXJOYW1lIjoiTEUwMDAiLCJhcHBsaWNhdGlvbklkIjoiMCIsInVzZXJJZCI6IjEzMjg4ODYyNzMwMDM4NTU4NzQiLCJleHAiOjE2MTQ1OTc5MzQsIm5iZiI6MTYxNDU5MDczNH0.e-ghYGplCF5lrMDwNd38RcbCjC79G729-iOMn3ozaEfmuZA_f5ElMvoyUf0Vm64IJMdwScuXPnSzJa2UQPyXNyZJRhpJDR4GKXI7X9VHqWJyrkc-_CJO0puLfB64K3SvKASD-PSHwzRggrmfn5G7GZ1gf-piK1grYurUIT-KaaE" refreshToken:@"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJqdGkiOiJlYzRiOTg4MTgxNWI0ZWJjYTEyNTU0ODNmNjg3NjgyMyIsImhlYWRlclByZWZpeCI6IkJlYXJlciAiLCJ0ZW5hbnRJZCI6IjIwIiwidG9rZW5UeXBlIjoicmVmcmVzaF90b2tlbiIsImFwcGxpY2F0aW9uSWQiOiIwIiwidXNlcklkIjoiMTMyODg4NjI3MzAwMzg1NTg3NCIsImV4cCI6MTYxNTI1NjMxMCwibmJmIjoxNjE0NjUxNTEwfQ.CgpIhgGb4U-NB3EvveBg6mBgLKi0H_zdA_RgPhDREmMeVyAH58H4guzutIi2EO7Dw8bkR2PB9n6jP4MQQNaHclN1EaahNQtZ4rHipLrBY0oT35Uz4vw5yXaWAyLG6_FW2Ky4wpqLbSjv9x24yc5cuKNaknruf73V6bNIDnGaEr0"]; [EZSDK setHDlAccessToken:@"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJqdGkiOiI4ZmIxNDBlYzMzYTM0OGU2YjgyYjg5MmJhNDc4NzljMiIsInJvbGUiOiIiLCJoZWFkZXJQcmVmaXgiOiJCZWFyZXIgIiwidXNlckFjY291bnQiOiIxODgyNDg2NDE0MyIsInRlbmFudElkIjoiMjAiLCJ1c2VyVHlwZSI6IlVTRVJfQyIsInRva2VuVHlwZSI6ImFjY2Vzc190b2tlbiIsInVzZXJOYW1lIjoiTEUwMDAiLCJhcHBsaWNhdGlvbklkIjoiMCIsInVzZXJJZCI6IjEzMjg4ODYyNzMwMDM4NTU4NzQiLCJleHAiOjE2MTQ5MTc0NzYsIm5iZiI6MTYxNDkxMDI3Nn0.RUKrm2BARWbdwmhj6KKlqalYCXUQ7hIRJBT-5LbPM2EUs2eLNFnwSxx3CGTgN94l3-5WW00srhzvcx6la4IAMfR1kh8-vzr4bXcXOs-wXifxIyt36Y3j9wodzEUWnR0w-42XlQb3jjlz9LiaFKWAHoXaOsmb3Uf6UsoWdqFlnSc" refreshToken:@"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJqdGkiOiJhZTU1NjBmOTRlNzY0Mzk5ODFlY2MzZDZkZGQ3NDNhYiIsImhlYWRlclByZWZpeCI6IkJlYXJlciAiLCJ0ZW5hbnRJZCI6IjIwIiwidG9rZW5UeXBlIjoicmVmcmVzaF90b2tlbiIsImFwcGxpY2F0aW9uSWQiOiIwIiwidXNlcklkIjoiMTMyODg4NjI3MzAwMzg1NTg3NCIsImV4cCI6MTYxNTUxNTA3NiwibmJmIjoxNjE0OTEwMjc2fQ.YTb0I1t9SKJpoQmdGDyzOIB6mVNQ94AteekAgs15bFsx_LVsj9xOoiURGVfHpthqpCcvL4MxYAYqLjDQHqsf_FbT0KKujqCOjTfnVB-EkqKm5yCmq827NEbq3ZukBcGs0fxGxRQJPzkDyd0AerzkwERYZqryoooNGsOeMN6vC_k"]; [EZSDK setRequestHttpsHost:@"https://nearest.hdlcontrol.com"]; // [EZSDK setRequestHttpsHost:@"https://nearest.hdlcontrol.com"]; __weak MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; hud.labelText = NSLocalizedString(@"ad_adding_msg", @"正在添加,请稍候..."); [EZHttpUtil getChildToken:^(NSString *accessToken) { [EZHttpUtil.sharedManager getChildToken:^(NSString *accessToken) { [hud hide:YES]; if(accessToken != NULL && ![accessToken isEqual:@""]){ [[GlobalKit shareKit] setAccessToken:accessToken]; EZSDK.IOS/EZSDK.IOS/Library/libEZSDK.aBinary files differ
EZSDK.IOS/EZSDK.IOS/Properties/AssemblyInfo.cs
@@ -25,7 +25,7 @@ // The form "{Major}.{Minor}.*" will automatically update the build and revision, // and "{Major}.{Minor}.{Build}.*" will update just the revision. [assembly: AssemblyVersion("1.0.8")] [assembly: AssemblyVersion("1.1.0")] // The following attributes are used to specify the signing key for the assembly, // if desired. See the Mono documentation for more information about signing. EZSDK/EZSDK/EZ/Global/EZHttpUtil.h
@@ -14,13 +14,16 @@ /// 河东接口网络请求工具类 @interface EZHttpUtil : NSObject /// sharedManager + (id)sharedManager; #pragma mark -接口 /** * @since 河东获取子账号token的接口 * * @param block 回调block */ + (void)getChildToken:(void (^)(NSString *accessToken))block; - (void)getChildToken:(void (^)(NSString *accessToken))block; /** * @since 河东添加设备的接口 @@ -31,7 +34,7 @@ * @param completion 回调block,error为空时表示添加成功 * */ + (void)addDeviceByHDL:(NSString *)deviceSerial - (void)addDeviceByHDL:(NSString *)deviceSerial verifyCode:(NSString *)verifyCode completion:(void (^)(ResponseData *responseData))completion; @@ -43,7 +46,7 @@ * @param completion 回调block,error为空时表示添加成功 * */ + (void)deleteDeviceByHDL:(NSString *)deviceSerial completion:(void (^)(ResponseData *responseData))completion; - (void)deleteDeviceByHDL:(NSString *)deviceSerial completion:(void (^)(ResponseData *responseData))completion; @end EZSDK/EZSDK/EZ/Global/EZHttpUtil.m
@@ -24,20 +24,29 @@ #define SECRET_KEY @"WeJ8TY88vbakCcnvH8G1tDUqzLWY8yss" #define TIME_OUT 15.0f @implementation EZHttpUtil #pragma mark -接口请求部分 /// sharedManager + (id)sharedManager { static dispatch_once_t once; static id instance; dispatch_once(&once, ^{ instance = [self new]; }); return instance; } /** * @since 河东获取子账号token的接口 * * @param block 回调block */ + (void)getChildToken:(void (^)(NSString *accessToken))block{ - (void)getChildToken:(void (^)(NSString *accessToken))block{ //2.设置请求参数 NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; @@ -65,7 +74,7 @@ * @param completion 回调block,error为空时表示添加成功 * */ + (void)addDeviceByHDL:(NSString *)deviceSerial - (void)addDeviceByHDL:(NSString *)deviceSerial verifyCode:(NSString *)verifyCode completion:(void (^)(ResponseData *responseData))completion{ @@ -92,7 +101,7 @@ * @param completion 回调block,error为空时表示添加成功 * */ + (void)deleteDeviceByHDL:(NSString *)deviceSerial completion:(void (^)(ResponseData *responseData))completion{ - (void)deleteDeviceByHDL:(NSString *)deviceSerial completion:(void (^)(ResponseData *responseData))completion{ //1.设置请求参数 NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; [parameters setValue:deviceSerial forKey:@"deviceSerial"]; @@ -111,7 +120,7 @@ /// 刷新token /// @param block 结果 + (void)refreshHDLToken:(void (^)(BOOL isSuccess))block{ - (void)refreshHDLToken:(void (^)(BOOL isSuccess))block{ //1.设置请求参数 NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; @@ -148,7 +157,7 @@ /// @param apiPath 接口地址 /// @param parameters 请求参数 /// @param completion 请求响应参数 + (void)requestHttpsPost:(NSString *)apiPath - (void)requestHttpsPost:(NSString *)apiPath parameters:(NSMutableDictionary *)parameters completion:(void (^)(ResponseData *responseData))completion{ @@ -176,7 +185,7 @@ /// @param apiPath 接口地址 /// @param parameters 请求参数 /// @param completion 请求响应参数 + (void)requestHttpsBase:(NSString *)apiPath - (void)requestHttpsBase:(NSString *)apiPath parameters:(NSMutableDictionary *)parameters completion:(void (^)(ResponseData *responseData))completion{ @@ -194,7 +203,7 @@ //3.request NSMutableURLRequest * request = [[AFJSONRequestSerializer serializer] requestWithMethod:@"post" URLString:URL parameters:parameters error:nil]; request.timeoutInterval = 10.0f; request.timeoutInterval = TIME_OUT; [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; [request setValue:@"application/json" forHTTPHeaderField:@"Accept"]; [request setValue:GlobalKit.shareKit.hdlAccessToken forHTTPHeaderField:@"Authorization"]; @@ -223,7 +232,7 @@ /** * 基础服务的接口都要校验sign */ +(NSMutableDictionary *)GetSignRequestDictionary:(NSMutableDictionary *)params{ -(NSMutableDictionary *)GetSignRequestDictionary:(NSMutableDictionary *)params{ if(params == NULL){ params =[NSMutableDictionary dictionary]; } @@ -262,7 +271,7 @@ /// 字符串判空 /// @param valueStr 传入判断字符 + (BOOL)stringIsNullOrEmpty:(NSString *)valueStr - (BOOL)stringIsNullOrEmpty:(NSString *)valueStr { if((valueStr == nil || [valueStr isKindOfClass:[NSNull class]] || valueStr.length == 0)){ return YES; @@ -275,7 +284,7 @@ /** MD5转换+转小写 */ + (NSString*)signMD5Encrypt:(NSString *)str - (NSString*)signMD5Encrypt:(NSString *)str { const char *cStr = [str UTF8String]; unsigned char digest[CC_MD5_DIGEST_LENGTH]; @@ -295,7 +304,7 @@ /// </summary> /// <param name="valueStr"></param> /// <returns></returns> +(bool)IfValueNeedSign:(NSString *)valueStr{ -(bool)IfValueNeedSign:(NSString *)valueStr{ if (( [self stringIsNullOrEmpty:valueStr])//判空字符 || ([[valueStr substringToIndex:1] isEqual:@"{"])//判断是否为对象 || ([[valueStr substringToIndex:1] isEqual:@"["])//判断是否为数组 EZSDK/EZSDK/EZ/UIViewControllers/EZAPConfigResultViewController.m
@@ -136,18 +136,33 @@ } else { [EZOpenSDK addDevice:[GlobalKit shareKit].deviceSerialNo // [EZOpenSDK addDevice:[GlobalKit shareKit].deviceSerialNo // verifyCode:[GlobalKit shareKit].deviceVerifyCode // completion:^(NSError *error) { // if (error) // { // [self addErrorProcessWithError:error]; // } // else // { // [self successProcess]; // } // }]; [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo verifyCode:[GlobalKit shareKit].deviceVerifyCode completion:^(NSError *error) { if (error) completion:^(ResponseData *responseData) { if (!responseData.success) { [self addErrorProcessWithError:error]; [self addErrorProcessWithError:responseData]; } else { [self successProcess]; } }]; } }]; } @@ -181,18 +196,42 @@ [self.view makeToast:msg duration:2.0 position:@"center"]; } - (void) addErrorProcessWithError:(NSError *) error //- (void) addErrorProcessWithError:(NSError *) error //{ // NSString *msg = nil; // if (error.code == 120010) // { // msg = NSLocalizedString(@"device_verify_code_wrong", @"验证码错误"); // } // else if (error.code == 120020) // { // msg = NSLocalizedString(@"ad_already_added", @"您已添加过此设备"); // } // else if (error.code == 120022) // { // msg = NSLocalizedString(@"ad_added_by_others", @"此设备已被别人添加"); // } // else // { // msg = NSLocalizedString(@"wifi_add_fail", @"添加失败"); // } // // [self.view makeToast:msg duration:2.0 position:@"center"]; // self.msgLabel.hidden = YES; //} - (void) addErrorProcessWithError:(ResponseData *)responseData { NSString *msg = nil; if (error.code == 120010) if ([responseData.code isEqual: @"20010"]) { msg = NSLocalizedString(@"device_verify_code_wrong", @"验证码错误"); } else if (error.code == 120020) else if ([responseData.code isEqual: @"20017"]) { msg = NSLocalizedString(@"ad_already_added", @"您已添加过此设备"); } else if (error.code == 120022) else if ([responseData.code isEqual: @"20013"]) { msg = NSLocalizedString(@"ad_added_by_others", @"此设备已被别人添加"); } EZSDK/EZSDK/EZ/UIViewControllers/EZDeviceResultViewController.m
@@ -90,7 +90,7 @@ // [self handleTheError:error]; // }]; [EZHttpUtil addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo verifyCode:[GlobalKit shareKit].deviceVerifyCode completion:^(ResponseData *responseData) { [hud hide:YES]; @@ -127,7 +127,7 @@ // [hud hide:YES]; // [self handleTheError:error]; // }]; [EZHttpUtil addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo verifyCode:[GlobalKit shareKit].deviceVerifyCode completion:^(ResponseData *responseData) { [hud hide:YES]; EZSDK/EZSDK/EZ/UIViewControllers/EZSettingViewController.m
@@ -377,7 +377,7 @@ // } // }]; [EZHttpUtil deleteDeviceByHDL:self.deviceInfo.deviceSerial completion:^(ResponseData *responseData) { [EZHttpUtil.sharedManager deleteDeviceByHDL:self.deviceInfo.deviceSerial completion:^(ResponseData *responseData) { if(responseData.success) { [hud hide:YES]; EZSDK/EZSDK/EZ/UIViewControllers/EZWifiConfigViewController.m
@@ -107,10 +107,17 @@ self.enState = STATE_PLAT; [self createTimerWithTimeOut:30]; [GlobalKit shareKit].deviceVerifyCode = [alertView textFieldAtIndex:0].text; [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo // [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo // verifyCode:[GlobalKit shareKit].deviceVerifyCode // completion:^(NSError *error) { // [self handleTheError:error]; // }]; //2021-03-03 添加设备的方法都修改成河东的接口方法 [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo verifyCode:[GlobalKit shareKit].deviceVerifyCode completion:^(NSError *error) { [self handleTheError:error]; completion:^(ResponseData *responseData) { // [hud hide:YES]; [self handleTheError:responseData]; }]; } else if (alertView.tag == 0xbb && buttonIndex == 1) @@ -158,10 +165,15 @@ [weakSelf createTimerWithTimeOut:30]; if([GlobalKit shareKit].deviceVerifyCode != nil) { [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo // [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo // verifyCode:[GlobalKit shareKit].deviceVerifyCode // completion:^(NSError *error) { // [weakSelf handleTheError:error]; // }]; [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo verifyCode:[GlobalKit shareKit].deviceVerifyCode completion:^(NSError *error) { [weakSelf handleTheError:error]; completion:^(ResponseData *responseData) { [weakSelf handleTheError:responseData]; }]; } else @@ -241,18 +253,33 @@ { if ([GlobalKit shareKit].deviceVerifyCode != nil) { [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo // [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo // verifyCode:[GlobalKit shareKit].deviceVerifyCode // completion:^(NSError *error) { // if (!error) // { // [self handleTheError:error]; // } // else // { // [self showFailedView]; // } // }]; [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo verifyCode:[GlobalKit shareKit].deviceVerifyCode completion:^(NSError *error) { if (!error) completion:^(ResponseData *responseData) { if (responseData.success) { [self handleTheError:error]; [self handleTheError:responseData]; } else { [self showFailedView]; } }]; } else { @@ -683,11 +710,50 @@ self.failedTipsView.hidden = NO; } - (void)handleTheError:(NSError *)error //- (void)handleTheError:(NSError *)error //{ // [EZOPENSDK stopConfigWifi]; // // if (!error) // { // if ([_countTimer isValid]) // { // [_countTimer invalidate]; // _countTimer = nil; // } // _enState = STATE_SUCC; // [self showTipsView]; // return; // } // // if (error.code == 120010) // { // UIAlertView *retryAlertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"device_verify_code_wrong", @"验证码错误") // message:nil delegate:self // cancelButtonTitle:NSLocalizedString(@"cancel", @"取消") // otherButtonTitles:NSLocalizedString(@"retry", @"重试"), nil]; // retryAlertView.tag = 0xbb; // [retryAlertView show]; // } // else if (error.code == 120020) // { // [UIView dd_showMessage:NSLocalizedString(@"ad_already_added", @"您已添加过此设备")]; // } // else if (error.code == 120022) // { // [UIView dd_showMessage:NSLocalizedString(@"ad_added_by_others", @"此设备已被别人添加")]; // } // else // { // [UIView dd_showMessage:NSLocalizedString(@"wifi_add_fail", @"添加失败")]; // } //} - (void)handleTheError:(ResponseData *)responseData { [EZOPENSDK stopConfigWifi]; if (!error) if (responseData.success) { if ([_countTimer isValid]) { @@ -699,7 +765,7 @@ return; } if (error.code == 120010) if ([responseData.code isEqual: @"20010"]) { UIAlertView *retryAlertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"device_verify_code_wrong", @"验证码错误") message:nil delegate:self @@ -708,11 +774,11 @@ retryAlertView.tag = 0xbb; [retryAlertView show]; } else if (error.code == 120020) else if ([responseData.code isEqual: @"20017"]) { [UIView dd_showMessage:NSLocalizedString(@"ad_already_added", @"您已添加过此设备")]; } else if (error.code == 120022) else if ([responseData.code isEqual: @"20013"]) { [UIView dd_showMessage:NSLocalizedString(@"ad_added_by_others", @"此设备已被别人添加")]; } @@ -721,7 +787,6 @@ [UIView dd_showMessage:NSLocalizedString(@"wifi_add_fail", @"添加失败")]; } } #pragma mark - Action Methods - (void)completionButtonClicked:(id)sender