//
|
// ViewController.m
|
// EZOpenSDKDemo
|
//
|
// Created by DeJohn Dong on 15/10/27.
|
// Copyright © 2015年 Ezviz. All rights reserved.
|
//
|
|
#import "ViewController.h"
|
#import "EZSupportViewController.h"
|
#import "DDKit.h"
|
#import "EZSDK.h"
|
#import "MBProgressHUD.h"
|
#import "EZCameraInfo.h"
|
|
@interface ViewController ()
|
@property (weak, nonatomic) IBOutlet UIButton *ddnsDemoBtn;
|
|
@end
|
|
@implementation ViewController
|
|
- (void)viewDidLoad {
|
[super viewDidLoad];
|
|
#ifdef EZVIZ_GLOBAL_DEMO
|
self.ddnsDemoBtn.hidden = NO;
|
#else
|
self.ddnsDemoBtn.hidden = YES;
|
#endif
|
// Do any additional setup after loading the view, typically from a nib.
|
|
|
}
|
|
- (void)didReceiveMemoryWarning {
|
[super didReceiveMemoryWarning];
|
// Dispose of any resources that can be recreated.
|
|
}
|
|
#pragma mark - Action Methods
|
|
- (IBAction)go2CameraList:(id)sender
|
{
|
// //获取EZMain的stroyboard文件
|
// UIStoryboard *ezMainStoryboard = [UIStoryboard storyboardWithName:@"EZMain" bundle:nil];
|
// //获取EZMain.storyboard的实例ViewController--获取摄像头列表
|
// UIViewController *instanceVC = [ezMainStoryboard instantiateViewControllerWithIdentifier:@"EZCameraList"];
|
// //push摄像头列表的viewController
|
// [self.navigationController pushViewController:instanceVC animated:YES];
|
|
// [[GlobalKit shareKit] setAccessToken:@"ra.b48ex6o495x0etj76a0a3huh1x91ymvw-8oi8f811ry-15pqyvo-dyuk9nyz4"];
|
// /**
|
// * 下面代码功能与以上的注释方法相同
|
// */
|
// [self performSegueWithIdentifier:@"go2CameraList" sender:nil];
|
|
[[EZSDK sharedInstance] setHDlAccessToken:@"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJqdGkiOiIyYTAwZGRmOTNjMGY0YzlhYjljNjU2M2VhMDJjZjhmMyIsImNvbXBhbnlJZCI6IjAiLCJyb2xlIjoiIiwiaGVhZGVyUHJlZml4IjoiQmVhcmVyICIsInVzZXJBY2NvdW50Ijoid3hyIiwidGVuYW50SWQiOiIyMCIsInVzZXJUeXBlIjoiVVNFUl9DIiwidG9rZW5UeXBlIjoiYWNjZXNzX3Rva2VuIiwidXNlck5hbWUiOiJrYWVkZSIsIm9wZW5BcHBsaWNhdGlvbklkIjoiMCIsInVzZXJJZCI6IjEzOTIwMzU1NjgyMDQ0MjMxNjkiLCJleHAiOjE2MjU2NjA0NjQsIm5iZiI6MTYyNTY1MzI2NH0.I4YfZQqm1p1SwJQbNWyUEOWXCqpYCWQdmAMOR-xlOMJ0pYFh3_nyjPBiWypTTMgy5nTpj7IqUM1bHwHWGsDEInF4Bl6trxrgOE39Toj-aY1UJcViYhx7e3E3ChrlXptVfKtk3cVEtDlFkMdHdHiJi-6OZox4KOz_AallI8lFIlo" refreshToken:@"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJqdGkiOiI1ZjdmOGFkY2I3MGU0NzYwOWE0NTcxOTZmOTAyOTY1OSIsImNvbXBhbnlJZCI6IjAiLCJoZWFkZXJQcmVmaXgiOiJCZWFyZXIgIiwidGVuYW50SWQiOiIyMCIsInRva2VuVHlwZSI6InJlZnJlc2hfdG9rZW4iLCJvcGVuQXBwbGljYXRpb25JZCI6IjAiLCJ1c2VySWQiOiIxMzkyMDM1NTY4MjA0NDIzMTY5IiwiZXhwIjoxNjI2MjU4MDY0LCJuYmYiOjE2MjU2NTMyNjR9.DB1pGaM6xtpQiP_KvaAHbWDZtxjLXZwJCgFfrp_XA0bnV8wMC8SE7K_uoP79c97WGqcmpHJVY-x8NCVJneGpIKN2oSCvX0Sn0uAttqni4zbVjmErC2AmpONJwWY27GYjHk4LFri03p38D-5zlULFo3ITtN3Il2aJOjVOpyNCcuI"];
|
|
|
[[EZSDK sharedInstance] setRequestHttpsHostAndPlatform:@"https://test-gz.hdlcontrol.com" platform:1 homeId:@"1396717478877241345"];
|
|
|
|
__weak MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
hud.labelText = NSLocalizedString(@"ad_adding_msg", @"正在添加,请稍候...");
|
[EZHttpUtil.sharedManager getChildToken:^(NSString *accessToken) {
|
[hud hide:YES];
|
if(accessToken != NULL && ![accessToken isEqual:@""]){
|
[[EZSDK sharedInstance] setEZAccessToken:accessToken];
|
/**
|
* 下面代码功能与以上的注释方法相同
|
*/
|
[self performSegueWithIdentifier:@"go2CameraList" sender:nil];
|
|
}
|
}];
|
}
|
|
|
|
- (IBAction)logout:(id)sender
|
{
|
|
return;
|
// [[GlobalKit shareKit] setAccessToken:@"ra.a5bfkhhx7ycscsj41if7l0cf9ytfhv5q-9keuxvphmn-1fvjt6p-jugtyy8sr"];
|
[[EZSDK sharedInstance] setHDlAccessToken:@"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJqdGkiOiI2Zjk1ZTEwZWIwNjA0ZjNiYTdmNTc0ZGUyM2QxYmNmZiIsImNvbXBhbnlJZCI6IjAiLCJyb2xlIjoiIiwiaGVhZGVyUHJlZml4IjoiQmVhcmVyICIsInVzZXJBY2NvdW50Ijoid3hyIiwidGVuYW50SWQiOiIyMCIsInVzZXJUeXBlIjoiVVNFUl9DIiwidG9rZW5UeXBlIjoiYWNjZXNzX3Rva2VuIiwidXNlck5hbWUiOiJrYWVkZSIsIm9wZW5BcHBsaWNhdGlvbklkIjoiMCIsInVzZXJJZCI6IjEzOTIwMzU1NjgyMDQ0MjMxNjkiLCJleHAiOjE2MjU3MTY3NjAsIm5iZiI6MTYyNTcwOTU2MH0.C6w0mb0YiNhqQfLPscXiNVh_DOsbza_fubUbn_T-W04L3R7egi7-Gv_iifdfvh4XTU10rEdVl6FLXKxt3JJvo2x_sjBQLkWRQINMVl1qLOz9cMew79_aykXOwl8mdroYs9SKBd90qyM2lZaA91sD4H0HMVVyc_D2TEcG4XJzSBM" refreshToken:@"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJqdGkiOiI1M2FlMzg3NDhmNjU0MzE1OTM0MTQ0OWQyYmQ0NjE0NiIsImNvbXBhbnlJZCI6IjAiLCJoZWFkZXJQcmVmaXgiOiJCZWFyZXIgIiwidGVuYW50SWQiOiIyMCIsInRva2VuVHlwZSI6InJlZnJlc2hfdG9rZW4iLCJvcGVuQXBwbGljYXRpb25JZCI6IjAiLCJ1c2VySWQiOiIxMzkyMDM1NTY4MjA0NDIzMTY5IiwiZXhwIjoxNjI2MzE0MzYwLCJuYmYiOjE2MjU3MDk1NjB9.AZlG8jO8lFDcj5dfoY0rZsDfglGdeyLuSImzMw1enHWfAacjkIof0vXQ_qJG9Q-6qxyXXbPu_xrd0DhkGNFeHJ4WFL0iiYgDP51sJuUdKrQklUCSC6T7ZjIW0GSVmvOW4GCw0s6L51bVT_rkdrusVD4rDnOtJwWqXTUfyNanmlk"];
|
|
|
[[EZSDK sharedInstance] setRequestHttpsHostAndPlatform:@"https://test-gz.hdlcontrol.com" platform:1 homeId:@"1396717478877241345"];
|
|
|
__weak MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
hud.labelText = NSLocalizedString(@"ad_adding_msg", @"请稍候...");
|
[EZHttpUtil.sharedManager getChildToken:^(NSString *accessToken) {
|
[hud hide:YES];
|
if(accessToken != NULL && ![accessToken isEqual:@""]){
|
NSLog(@"accessToken HDL:%@",accessToken);
|
[[EZSDK sharedInstance] setEZAccessToken:accessToken];
|
|
// [[EZSDK sharedInstance] PlayWithDeviceSerial:@"F44133728"];
|
|
EZAlarmInfo *info = [[EZAlarmInfo alloc] init];
|
info.alarmName = @"人体检测";
|
info.alarmPicUrl = @"https://i.ys7.com/streamer/alarm/url/get?fileId=20210707204930-F41014762-1-00000-2-1&deviceSerialNo=F41014762&cn=1&isEncrypted=0&ct=1&lc=90&bn=1_hikalarm";
|
[[EZSDK sharedInstance] goToEZMessagePhotoVC:info];
|
|
}
|
}];
|
|
// [EZOPENSDK logout:^(NSError *error) {
|
// }];
|
|
|
}
|
|
-(void)getEzDeviceInfo:(NSString *)deviceSerial{
|
|
//获取设备列表接口
|
[EZOpenSDK getDeviceInfo:deviceSerial completion:^(EZDeviceInfo *deviceInfo, NSError *error) {
|
if(error)
|
{
|
return;
|
}
|
if (deviceInfo) {
|
[[EZSDK sharedInstance] Play:deviceInfo];
|
}
|
|
}];
|
|
// [EZOPENSDK :deviceSerial];
|
}
|
|
- (void)handleTheError:(NSError *)error
|
{
|
if (!error)
|
{
|
// [self performSegueWithIdentifier:@"go2WifiResult" sender:nil];
|
return;
|
}
|
if (error.code == 105002)
|
{
|
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 == 105000)
|
{
|
[UIView dd_showMessage:NSLocalizedString(@"ad_already_added",@"您已添加过此设备")];
|
}
|
else if (error.code == 105001)
|
{
|
[UIView dd_showMessage:NSLocalizedString(@"ad_added_by_others",@"此设备已被别人添加")];
|
}
|
else
|
{
|
[UIView dd_showMessage:NSLocalizedString(@"wifi_add_fail",@"添加失败")];
|
}
|
}
|
|
|
- (IBAction)goAPI:(id)sender
|
{
|
|
|
// [EZOPENSDK gotoEzvizAppPage:EZPageAlarmList appType:EZEzvizInternational];
|
// [self performSegueWithIdentifier:@"go2DemoAPI" sender:nil];
|
}
|
|
- (IBAction)addQQGroup:(id)sender
|
{
|
NSString *urlStr = [NSString stringWithFormat:@"mqqapi://card/show_pslcard?src_type=internal&version=1&uin=%@&key=%@&card_type=group&source=external", @"511147309",@"626a9c0f72a1d877a6dc7f286db0098375436993cd22c323f5934566acc3ca8c"];
|
NSURL *url = [NSURL URLWithString:urlStr];
|
if([[UIApplication sharedApplication] canOpenURL:url]){
|
[[UIApplication sharedApplication] openURL:url];
|
}
|
}
|
|
- (IBAction) ezvizLogin:(id)sender
|
{
|
[EZOPENSDK ezvizLoginWithAppType:EZEzvizInternational];
|
}
|
|
- (IBAction)supportBtnClick:(id)sender
|
{
|
[self enterSupport];
|
}
|
|
- (void)enterSupport
|
{
|
EZSupportViewController *vc = [[EZSupportViewController alloc] init];
|
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
|
[self presentViewController:nav animated:YES completion:nil];
|
}
|
|
@end
|