萤石云 iOSSDK,移植跨平台相关工程
EZSDK/EZSDK/EZSDK.m
@@ -18,21 +18,34 @@
#import "EZPlaybackViewController.h"
#import "EZDeviceTableViewController.h"
#import "EZHCNetDeviceSDK.h"
#import "EZMessagePhotoViewController.h"
#import "HDLEZVisitorRecordViewController.h"
#import "HDLEZDeviceMsgListViewController.h"
@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;
/**
 初始化SDK
 传入国内版key 和海外版globalAppKey
 */
+ (BOOL)initLibWithAppKey:(NSString *)appKey globalAppKey:(NSString *)globalAppKey
- (BOOL)initLibWithAppKey:(NSString *)appKey globalAppKey:(NSString *)globalAppKey
{
    static BOOL isHavelibInit=NO;
    if (!isHavelibInit) {
        [EZOPENSDK setDebugLogEnable:YES];
        //        isHavelibInit=YES;
        //        NSLog(@"第一次初始化萤石库");
        if (!LanguageIsChinese) {
@@ -41,13 +54,15 @@
            NSLog(@"海外版key--%@",globalAppKey);
        }else{
            isHavelibInit = [EZOpenSDK initLibWithAppKey:appKey];
            [[GlobalKit shareKit] setHdlAppKey:appKey];
            NSLog(@"国内版key--%@", appKey);
        }
        [EZHCNetDeviceSDK initSDK];
        [EZOPENSDK enableP2P:YES];
        [EZOPENSDK setDebugLogEnable:YES];
//        [EZOPENSDK setDebugLogEnable:YES];
        NSLog(@"EZOpenSDK Version = %@", [EZOPENSDK getVersion]);
//        NSLog(@"EZOpenSDK treamToken= %@", );
    }
    return isHavelibInit;
}
@@ -55,7 +70,7 @@
/**
 设置SDK的accessToken
 */
+(void)setEZAccessToken:(NSString *) accessToken
-(void)setEZAccessToken:(NSString *) accessToken
{
    [[GlobalKit shareKit] setAccessToken:accessToken];
    [EZOPENSDK setAccessToken:accessToken];
@@ -64,14 +79,22 @@
/**
 设置HDLSDK的accessToken
 */
+(void)setHDlAccessToken:(NSString *) accessToken refreshToken:(NSString *) refreshToken
-(void)setHDlAccessToken:(NSString *) accessToken refreshToken:(NSString *) refreshToken
{
    [[GlobalKit shareKit] setHdlAccessToken:accessToken];
    [[GlobalKit shareKit] setHdlRefreshToken:refreshToken];
}
/**
 设置SDK的河东接口的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];
}
//获取当前屏幕显示的viewcontroller   (这里面获取的相当于rootViewController)
+(UINavigationController *)getCurrentVC
-(UINavigationController *)getCurrentVC
{
    UIWindow * window = [[UIApplication sharedApplication] keyWindow];
    if (window.windowLevel != UIWindowLevelNormal)
@@ -94,57 +117,129 @@
/**
 直接跳转到萤石摄像头列表
 */
+(void)go2EZvizMonitor
-(void)go2EZvizMonitor
{
    //    NSLog(@"go2EZvizMonitor");
//    [GlobalKit shareKit].deviceType=HDLEZDeviceType_Default;
//    //    NSLog(@"go2EZvizMonitor");
//    //获取EZMain的stroyboard文件
//    UIStoryboard *ezMainStoryboard = [UIStoryboard storyboardWithName:@"EZMain" bundle:nil];
//    //获取EZMain.storyboard的实例ViewController--获取摄像头列表
//    EZDeviceTableViewController *instanceVC = [ezMainStoryboard instantiateViewControllerWithIdentifier:@"EZCameraList"];
//    //push摄像头列表的viewController
//    [[self getCurrentVC] setNavigationBarHidden:NO];
//    //        NSLog(@"willpush********");
//    [[self getCurrentVC] pushViewController:instanceVC animated:YES];
//    //        NSLog(@"had pushed********");
    [self toEZDeviceListViewWithFilterTypes:@[@""]];
}
/**
 直接跳转到萤石摄像头列表(筛掉门锁设备)
 @param filterTepes 过滤型号数组
 */
- (void)toEZDeviceListViewWithFilterTypes:(NSArray*)filterTepes{
    [GlobalKit shareKit].deviceType=HDLEZDeviceType_Default;
    //获取EZMain的stroyboard文件
    UIStoryboard *ezMainStoryboard = [UIStoryboard storyboardWithName:@"EZMain" bundle:nil];
    //获取EZMain.storyboard的实例ViewController--获取摄像头列表
    EZDeviceTableViewController *instanceVC = [ezMainStoryboard instantiateViewControllerWithIdentifier:@"EZCameraList"];
    instanceVC.filterTypes=filterTepes;
    //push摄像头列表的viewController
    [[self getCurrentVC] setNavigationBarHidden:NO];
    //        NSLog(@"willpush********");
    [[self getCurrentVC] pushViewController:instanceVC animated:YES];
    //        NSLog(@"had pushed********");
}
/**
 跳转添加添加设备
 */
+(void)addEzvizMonitor
-(void)addEzvizMonitor
{
//    //    NSLog(@"添加摄像头");
//    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
//        UIStoryboard *addDeviceStoryBoard = [UIStoryboard storyboardWithName:@"AddDevice" bundle:nil];
//        EZAddByQRCodeViewController *rootViewController = [addDeviceStoryBoard instantiateViewControllerWithIdentifier:@"AddByQRCode"];
//        [[self getCurrentVC] setNavigationBarHidden:NO];
//        [[self getCurrentVC] pushViewController:rootViewController animated:YES];
//    } else {
//        //        [UIView dd_showMessage:@"iOS 7.0以下扫码功能请自行实现"];
//        NSLog(@"iOS 7.0以下扫码功能请自行实现");
//    }
    [self addEzvizMonitorWithDeviceType:@""];
}
/**
 跳转添加添加设备
 @param deviceType 设备类型
 */
- (void)addEzvizMonitorWithDeviceType:(NSString *)deviceType{
    HDLEZDeviceType type=[deviceType isEqualToString:HDLEZ_DOOR_SPK] ? HDLEZDeviceType_Door : HDLEZDeviceType_Default;
    //    NSLog(@"添加摄像头");
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
        UIStoryboard *addDeviceStoryBoard = [UIStoryboard storyboardWithName:@"AddDevice" bundle:nil];
        EZAddByQRCodeViewController *rootViewController = [addDeviceStoryBoard instantiateViewControllerWithIdentifier:@"AddByQRCode"];
        rootViewController.deviceType=type;
        [[self getCurrentVC] setNavigationBarHidden:NO];
        [[self getCurrentVC] pushViewController:rootViewController animated:YES];
    } else {
        //        [UIView dd_showMessage:@"iOS 7.0以下扫码功能请自行实现"];
        NSLog(@"iOS 7.0以下扫码功能请自行实现");
    }
}
/**
 查看视频监控直播
 */
+(void)Play:(NSObject*)deviceInfo
-(void)Play:(EZDeviceInfo*)deviceInfo
{
    [GlobalKit shareKit].deviceType=HDLEZDeviceType_Default;
    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];
        }
    }];
}
/**
 根据序列号进入门锁视频
 @param deviceSerial 序列号
 @param deviceId 设备id
 @param deviceType 设备spk(用于区分是否为门锁)
 */
-(void)PlayWithDeviceSerial:(NSString *)deviceSerial deviceId:(NSString*)deviceId deviceType:(NSString *)deviceType{
    [GlobalKit shareKit].deviceType=[deviceType isEqualToString:HDLEZ_DOOR_SPK] ? HDLEZDeviceType_Door : HDLEZDeviceType_Default;
    UIStoryboard *ezMainStoryBoard = [UIStoryboard storyboardWithName:@"EZMain" bundle:nil];
    EZLivePlayViewController *vc = [ezMainStoryBoard instantiateViewControllerWithIdentifier:@"EZLivePlayViewController"];
    vc.deviceId=deviceId;
    vc.deviceSerial=deviceSerial;
    [[self getCurrentVC] setNavigationBarHidden:NO];
    [[self getCurrentVC] pushViewController:vc animated:YES];
}
/**
 打开摄像头设置页面
 */
+(void)setting:(NSObject*)deviceInfo
-(void)setting:(EZDeviceInfo*)deviceInfo
{
    UIStoryboard *settingStoryBoard=[UIStoryboard storyboardWithName:@"EZMain" bundle:nil];
    EZSettingViewController *settingVC=[settingStoryBoard instantiateViewControllerWithIdentifier:@"EZSettingViewController"];
@@ -156,7 +251,7 @@
/**
 回放播放历史
 */
+(void)playBackVideo:(NSObject*)deviceInfo
-(void)playBackVideo:(EZDeviceInfo*)deviceInfo
{
    UIStoryboard *playBackStoryBoard=[UIStoryboard storyboardWithName:@"EZMain" bundle:nil];
    EZPlaybackViewController *playBackVC=[playBackStoryBoard instantiateViewControllerWithIdentifier:@"EZPlaybackViewController"];
@@ -165,7 +260,38 @@
    [[self getCurrentVC] pushViewController:playBackVC animated:YES];
}
/**临时密码页
 @param deviceId 设备id
 */
- (void)toTemPassView:(NSString*)deviceId{
    HDLEZVisitorRecordViewController *vc=[[HDLEZVisitorRecordViewController alloc] init];
    vc.deviceId=deviceId;
    [[self getCurrentVC] setNavigationBarHidden:YES];
    [[self getCurrentVC] pushViewController:vc animated:YES];
}
/**设备历史记录页
 @param deviceId 设备id
 */
- (void)toDeviceMsgListView:(NSString*)deviceId{
    HDLEZDeviceMsgListViewController *vc=[[HDLEZDeviceMsgListViewController alloc] init];
    vc.deviceId=deviceId;
    [[self getCurrentVC] setNavigationBarHidden:YES];
    [[self getCurrentVC] pushViewController:vc 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
//{
//    [CommonList login];