From b4e1288a9b63eb820e9c9489c56aac4bf6b31067 Mon Sep 17 00:00:00 2001 From: Davin <591807572@qq.com> Date: 星期三, 18 十二月 2024 14:34:16 +0800 Subject: [PATCH] feature 图片资源更新 --- Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Global/EZSDK.m | 258 ++++++++++++++------------------------------------- 1 files changed, 70 insertions(+), 188 deletions(-) diff --git a/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Global/EZSDK.m b/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Global/EZSDK.m index de120e6..4438cb0 100644 --- a/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Global/EZSDK.m +++ b/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Global/EZSDK.m @@ -18,27 +18,34 @@ #import "EZPlaybackViewController.h" #import "EZDeviceTableViewController.h" #import "EZHCNetDeviceSDK.h" -#import "AFNetworking.h" -#import <Foundation/Foundation.h> -#import <CommonCrypto/CommonDigest.h> - -#define API_POST_EZ_AddDevice @"/home-wisdom/platform/child/device/add" -#define API_POST_EZ_GetChildToken @"/home-wisdom/platform/childToken" +#import "EZMessagePhotoViewController.h" -#define APP_KEY @"HDL-HOME-APP-TEST" -#define SECRET_KEY @"WeJ8TY88vbakCcnvH8G1tDUqzLWY8yss" @implementation EZSDK + +/// ++ (instancetype)sharedInstance{ + static EZSDK *instance = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + if (!instance) { + instance = [[EZSDK alloc] init]; + } + }); + return instance; +} + +static BOOL isHavelibInit=NO; /** 鍒濆鍖朣DK 浼犲叆鍥藉唴鐗坘ey 鍜屾捣澶栫増globalAppKey */ -+ (BOOL)initLibWithAppKey:(NSString *)appKey globalAppKey:(NSString *)globalAppKey +- (BOOL)initLibWithAppKey:(NSString *)appKey globalAppKey:(NSString *)globalAppKey { - static BOOL isHavelibInit=NO; + if (!isHavelibInit) { // isHavelibInit=YES; // NSLog(@"绗竴娆″垵濮嬪寲钀ょ煶搴�"); @@ -62,16 +69,31 @@ /** 璁剧疆SDK鐨刟ccessToken */ -+(void)setEZAccessToken:(NSString *) accessToken +-(void)setEZAccessToken:(NSString *) accessToken { [[GlobalKit shareKit] setAccessToken:accessToken]; [EZOPENSDK setAccessToken:accessToken]; } - +/** + 璁剧疆HDLSDK鐨刟ccessToken + */ +-(void)setHDlAccessToken:(NSString *) accessToken refreshToken:(NSString *) refreshToken +{ + [[GlobalKit shareKit] setHdlAccessToken:accessToken]; + [[GlobalKit shareKit] setHdlRefreshToken:refreshToken]; +} +/** + 璁剧疆SDK鐨勬渤涓滄帴鍙g殑requestHttpsHost鍜屽钩鍙� 鏍囪瘑锛�1.on+(榛樿) 2.evoyo + */ +-(void)setRequestHttpsHostAndPlatform:(NSString *) requestHttpsHost platform:(int)platform homeId:(NSString *)homeId{ + [[GlobalKit shareKit] setGlobalRequestHttpsHost:requestHttpsHost]; + [[GlobalKit shareKit] setHdlPlatform:platform]; + [[GlobalKit shareKit] setHdlHomeId:homeId]; +} //鑾峰彇褰撳墠灞忓箷鏄剧ず鐨剉iewcontroller (杩欓噷闈㈣幏鍙栫殑鐩稿綋浜巖ootViewController) -+(UINavigationController *)getCurrentVC +-(UINavigationController *)getCurrentVC { UIWindow * window = [[UIApplication sharedApplication] keyWindow]; if (window.windowLevel != UIWindowLevelNormal) @@ -94,7 +116,7 @@ /** 鐩存帴璺宠浆鍒拌悿鐭虫憚鍍忓ご鍒楄〃 */ -+(void)go2EZvizMonitor +-(void)go2EZvizMonitor { // NSLog(@"go2EZvizMonitor"); //鑾峰彇EZMain鐨剆troyboard鏂囦欢 @@ -111,7 +133,7 @@ /** 璺宠浆娣诲姞娣诲姞璁惧 */ -+(void)addEzvizMonitor +-(void)addEzvizMonitor { // NSLog(@"娣诲姞鎽勫儚澶�"); if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) { @@ -129,22 +151,40 @@ /** 鏌ョ湅瑙嗛鐩戞帶鐩存挱 */ -+(void)Play:(NSObject*)deviceInfo +-(void)Play:(EZDeviceInfo*)deviceInfo { UIStoryboard *addDeviceStoryBoard = [UIStoryboard storyboardWithName:@"EZMain" bundle:nil]; EZLivePlayViewController *rootViewController = [addDeviceStoryBoard instantiateViewControllerWithIdentifier:@"EZLivePlayViewController"]; // NSLog(@"play--iphone--rootViewController"); rootViewController.deviceInfo=(EZDeviceInfo *)deviceInfo; NSLog(@"play--iphone--deviceName -%@",rootViewController.deviceInfo.deviceName); - // rootViewController.cameraIndex=0; +// rootViewController.cameraIndex=0; [[self getCurrentVC] setNavigationBarHidden:NO]; [[self getCurrentVC] pushViewController:rootViewController animated:YES]; + + +} + +/// 鎸囧畾搴忓垪鍙锋挱鏀� +/// @param deviceSerial 搴忓垪鍙� +-(void)PlayWithDeviceSerial:(NSString *)deviceSerial{ + //鑾峰彇璁惧鍒楄〃鎺ュ彛 + [EZOpenSDK getDeviceInfo:deviceSerial completion:^(EZDeviceInfo *deviceInfo, NSError *error) { + if(error) + { + NSLog(@"EZ 鏌ヨ璁惧淇℃伅澶辫触"); + return; + } + if (deviceInfo) { + [self Play:deviceInfo]; + } + }]; } /** 鎵撳紑鎽勫儚澶磋缃〉闈� */ -+(void)setting:(NSObject*)deviceInfo +-(void)setting:(EZDeviceInfo*)deviceInfo { UIStoryboard *settingStoryBoard=[UIStoryboard storyboardWithName:@"EZMain" bundle:nil]; EZSettingViewController *settingVC=[settingStoryBoard instantiateViewControllerWithIdentifier:@"EZSettingViewController"]; @@ -156,7 +196,7 @@ /** 鍥炴斁鎾斁鍘嗗彶 */ -+(void)playBackVideo:(NSObject*)deviceInfo +-(void)playBackVideo:(EZDeviceInfo*)deviceInfo { UIStoryboard *playBackStoryBoard=[UIStoryboard storyboardWithName:@"EZMain" bundle:nil]; EZPlaybackViewController *playBackVC=[playBackStoryBoard instantiateViewControllerWithIdentifier:@"EZPlaybackViewController"]; @@ -165,6 +205,17 @@ [[self getCurrentVC] pushViewController:playBackVC animated:YES]; } +//// +//-(void)goToEZMessagePhotoVC:(EZAlarmInfo*)alarmInfo{ +// UIStoryboard *addDeviceStoryBoard = [UIStoryboard storyboardWithName:@"EZMain" bundle:nil]; +// EZMessagePhotoViewController *rootViewController = [addDeviceStoryBoard instantiateViewControllerWithIdentifier:@"EZMessagePhotoViewController"]; +// // NSLog(@"play--iphone--rootViewController"); +// rootViewController.info = alarmInfo; +//// NSLog(@"play--iphone--deviceName -%@",rootViewController.deviceInfo.deviceName); +//// rootViewController.cameraIndex=0; +// [[self getCurrentVC] setNavigationBarHidden:NO]; +// [[self getCurrentVC] pushViewController:rootViewController animated:YES]; +//} //+(void)MonitorPushMessage:(NSString *)MonitorType ID:(NSString *)ID //{ @@ -288,175 +339,6 @@ // } //} -#pragma mark -鎺ュ彛璇锋眰閮ㄥ垎 -/** - * @since 娌充笢鑾峰彇瀛愯处鍙穞oken鐨勬帴鍙� - * - * @param block 鍥炶皟block - */ -+ (NSURLSessionDataTask *)getChildToken:(void (^)(NSString *accessToken))block{ - //1,鍒涘缓浣犲緱璇锋眰url - NSString *URL = @""; - if([GlobalKit shareKit].GlobalRequestHttpsHost == NULL){ - URL = @"https://test-gz.hdlcontrol.com"; - } - URL = [NSString stringWithFormat:@"%@%@", URL, API_POST_EZ_GetChildToken]; - - //2.璁剧疆璇锋眰鍙傛暟 - NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; - parameters = [self GetSignRequestDictionary:parameters]; - - NSURLSessionDataTask*task=nil; - AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]; - AFHTTPResponseSerializer *responseSerializer = [AFHTTPResponseSerializer serializer]; - manager.responseSerializer = responseSerializer; - - NSMutableURLRequest * request = [[AFJSONRequestSerializer serializer] requestWithMethod:@"post" URLString:URL parameters:parameters error:nil]; - [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; - [request setValue:@"application/json" forHTTPHeaderField:@"Accept"]; - [request setValue:GlobalKit.shareKit.hdlAccessToken forHTTPHeaderField:@"Authorization"]; - - [[manager dataTaskWithRequest:request completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) { - - //4.瑙f瀽鎷垮埌鐨勫搷搴旀暟鎹� - NSLog(@"%@",[[NSString alloc]initWithData:responseObject encoding:NSUTF8StringEncoding]); - - if (block) { - NSString * token = @""; - block (token); - } - }]resume]; - return task; - - -} -/** - * @since 娌充笢娣诲姞璁惧鐨勬帴鍙� - * 鏍规嵁璁惧搴忓垪鍙峰拰璁惧楠岃瘉鐮佹坊鍔犺澶囨帴鍙� - * - * @param deviceSerial 璁惧搴忓垪鍙� - * @param verifyCode 璁惧楠岃瘉鐮� - * @param completion 鍥炶皟block锛宔rror涓虹┖鏃惰〃绀烘坊鍔犳垚鍔� - * - * @return operation - */ -+ (NSURLSessionDataTask *)addDeviceByHDL:(NSString *)deviceSerial - verifyCode:(NSString *)verifyCode - completion:(void (^)(NSError *error))completion{ - - //1,鍒涘缓浣犲緱璇锋眰url - NSString *URL = @""; - if([GlobalKit shareKit].GlobalRequestHttpsHost == NULL){ - URL = @"https://test-gz.hdlcontrol.com"; - } - URL = [NSString stringWithFormat:@"%@%@",URL, @"/smart-footstone/region/regionByAccount"]; - - //2.璁剧疆璇锋眰鍙傛暟 - NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; - // [parameters setValue:deviceSerial forKey:@"deviceSerial"]; - // [parameters setValue:verifyCode forKey:@"verifyCode"]; - // parameters[@"deviceSerial"] = deviceSerial; - // parameters[@"verifyCode"] = verifyCode; - parameters[@"account"] = @"18824864143"; - -// parameters = [self GetSignRequestDictionary:parameters]; - - NSURLSessionDataTask*task=nil; - AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]; - AFHTTPResponseSerializer *responseSerializer = [AFHTTPResponseSerializer serializer]; - manager.responseSerializer = responseSerializer; - - NSMutableURLRequest * request = [[AFJSONRequestSerializer serializer] requestWithMethod:@"post" URLString:URL parameters:parameters error:nil]; - [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; - [request setValue:@"application/json" forHTTPHeaderField:@"Accept"]; - - [[manager dataTaskWithRequest:request completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) { - - // //鎷垮埌鍝嶅簲澶翠俊鎭� - // NSHTTPURLResponse *res = (NSHTTPURLResponse *)response; - - //4.瑙f瀽鎷垮埌鐨勫搷搴旀暟鎹� - NSLog(@"%@",[[NSString alloc]initWithData:responseObject encoding:NSUTF8StringEncoding]); - - if (completion) { -// error.code = 105002; - completion (error); - } - }]resume]; - return task; -} -#pragma mark HttpUtil -/** - * 鍩虹鏈嶅姟鐨勬帴鍙i兘瑕佹牎楠宻ign - */ -+(NSMutableDictionary *)GetSignRequestDictionary:(NSMutableDictionary *)params{ - if(params == NULL){ - params =[NSMutableDictionary dictionary]; - } - UInt64 recordTime = [[NSDate date] timeIntervalSince1970]*1000; - [params setValue:APP_KEY forKey:@"appKey"]; - [params setValue:[NSString stringWithFormat:@"%llu",recordTime] forKey:@"timestamp"]; - //1.瀵筀EY鍗囧簭 - NSArray *keyArray = [params allKeys]; - NSArray *sortKeyArray = [keyArray sortedArrayUsingComparator:^NSComparisonResult(id _Nonnull obj1, id _Nonnull obj2) { - return [obj1 compare:obj2 options:NSNumericSearch]; - }]; - //2.2 鎷兼帴鎸塙RL閿�煎 - NSString *newString = @""; - for(NSString *key in sortKeyArray){ - if(params[key] != NULL){ - NSString *valueStr = params[key]; - //妫�娴嬪綋鍓嶅弬鏁版槸鍚﹂渶瑕佸弬涓庢牎楠� - if([self IfValueNeedSign:valueStr]){ - newString = [newString stringByAppendingString:[NSString stringWithFormat:@"%@=%@&", key,valueStr]]; - } - } - } - //2.3 鎷兼帴SECRET_KEY - newString = [newString substringToIndex:[newString length] - 1]; - newString = [newString stringByAppendingString: SECRET_KEY]; - //2.4 MD5杞崲+杞皬鍐� - if(newString == nil || newString == NULL){ - newString = @""; - } - NSString* signstr = [self signMD5Encrypt:newString]; - [params setValue:signstr forKey:@"sign"]; - - return params; -} - -/** - MD5杞崲+杞皬鍐� - */ -+ (NSString*)signMD5Encrypt:(NSString *)str -{ - const char *cStr = [str UTF8String]; - unsigned char digest[CC_MD5_DIGEST_LENGTH]; - CC_MD5( cStr, strlen(cStr),digest ); - NSMutableString *result = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2]; - for(int i = 0; i < CC_MD5_DIGEST_LENGTH; i++) - [result appendFormat:@"%02x", digest[i]]; - return result; - - -} - -/// <summary> -/// 鍒ゆ柇褰撳墠鍊兼槸鍚﹂渶瑕佸弬涓庣鍚嶏紝淇濇寔璺熶簯绔竴鑷� -/// 绌哄瓧绗︿覆涓嶅弬涓� -/// 鏁扮粍,闆嗗悎,瀵硅薄涓嶅弬涓� -/// </summary> -/// <param name="valueStr"></param> -/// <returns></returns> -+(bool)IfValueNeedSign:(NSString *)valueStr{ - if (( (valueStr == nil || [valueStr isKindOfClass:[NSNull class]] || valueStr.length == 0))//鍒ょ┖瀛楃 - || ([[valueStr substringToIndex:1] isEqual:@"{"])//鍒ゆ柇鏄惁涓哄璞� - || ([[valueStr substringToIndex:1] isEqual:@"["])//鍒ゆ柇鏄惁涓烘暟缁� - ) { - return false; - } - return true; -} @end -- Gitblit v1.8.0