//
|
// AppDelegate.m
|
// HDLEZDemo
|
//
|
// Created by 陈启扬 on 2023/3/2.
|
//
|
|
#import "AppDelegate.h"
|
#import "EZSDK.h"
|
#import <CoreLocation/CoreLocation.h>
|
|
@interface AppDelegate ()<CLLocationManagerDelegate>
|
@property (nonatomic, strong) CLLocationManager *locationmanager;
|
|
@end
|
|
@implementation AppDelegate
|
|
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
|
// //设置window
|
// self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
|
// Override point for customization after application launch.
|
[[EZSDK sharedInstance] initLibWithAppKey:@"1aa98a90489b4838b966b57018b4b04b" globalAppKey:@"1aa98a90489b4838b966b57018b4b04b"];
|
// [[EZSDK sharedInstance] initLibWithAppKey:@"941b1b72b6294998acfd36c14931b675" globalAppKey:@"941b1b72b6294998acfd36c14931b675"];
|
[[EZSDK sharedInstance] setHDlAccessToken:@"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJqdGkiOiIyOTRkNmI1ZGIyZTE0OTBiOGVjZGZjMGE1YmZkMzM0MCIsImNvbXBhbnlJZCI6IjAiLCJyb2xlIjoiIiwiaGVhZGVyUHJlZml4IjoiQmVhcmVyICIsInVzZXJBY2NvdW50Ijoid3hyIiwidGVuYW50SWQiOiIyMCIsInVzZXJUeXBlIjoiVVNFUl9DIiwidG9rZW5UeXBlIjoiYWNjZXNzX3Rva2VuIiwidXNlck5hbWUiOiJ3eHIiLCJ1c2VyRGF0YVJpZ2h0IjoiMSIsIm9wZW5BcHBsaWNhdGlvbklkIjoiMCIsInVzZXJJZCI6IjEzOTIwMzU1NjgyMDQ0MjMxNjkiLCJleHAiOjE2ODg3Mjg5MTQsIm5iZiI6MTY4ODcyMTcxNH0.M-Q-M1o0FFIxdU8jjoFP3kHJn9YCtDGa1QDfmEd71fpxP_MfXKLITfZ08OL4ORpgLGM6pKvWHduG-WrR6qJqDiUkL-xFV10pdXXN2OXN6uBRL06Ab5uo3ybOn1YDJTd_LY6HuZxblnckmXNcCCoDEfGqIpTTl00HcEw2E4uexoM" refreshToken:@"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJqdGkiOiI1NGRhMzk1ZGE0ZGM0YzgwODYyNGMyY2JlYWZiMjFmNiIsImNvbXBhbnlJZCI6IjAiLCJoZWFkZXJQcmVmaXgiOiJCZWFyZXIgIiwidGVuYW50SWQiOiIyMCIsInRva2VuVHlwZSI6InJlZnJlc2hfdG9rZW4iLCJvcGVuQXBwbGljYXRpb25JZCI6IjAiLCJ1c2VySWQiOiIxMzkyMDM1NTY4MjA0NDIzMTY5IiwiZXhwIjoxNjg5MzI2NTE0LCJuYmYiOjE2ODg3MjE3MTR9.FPQUh_0HyO-TYzNhm1gnr8Gpbe2q3LMXkvJR10wZvk1NwYpsU7x4ekBMWYBL_PZ9BT_pEQ_0GzZRIkPQsZ-NgZtx2NmJ9CcE_qTwtyi9JLnpFsYDWn7sWSSpwDYJYmfT04Oqfu466Pgthibc59HZcZo629CjN7FkJCV5Wv3lL5k"];
|
[[EZSDK sharedInstance] setRequestHttpsHostAndPlatform:@"https://test-gz.hdlcontrol.com" platform:1 homeId:@"1547099040465408002"];
|
// [[EZSDK sharedInstance] setRequestHttpsHostAndPlatform:@"https://nearest.hdlcontrol.com" platform:1 homeId:@"1546324800135176193"];
|
[[EZSDK sharedInstance] setEZAccessToken:@"ra.5b950z7g0d00zrtl62938p9mcq6fr7yj-1e833bz5oi-1lfptjs-2hswa4ysz"];
|
// [[EZSDK sharedInstance] setEZAccessToken:@"ra.3hkirwcadrpfmaa89wep99io3wto4yds-7zptb10d20-1wxg4f3-ygiojudee"];
|
|
|
//定位权限
|
_locationmanager = [[CLLocationManager alloc]init];
|
_locationmanager.delegate = self;
|
[_locationmanager requestWhenInUseAuthorization];
|
[_locationmanager startUpdatingLocation];
|
|
return YES;
|
}
|
|
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {
|
// if (status == kCLAuthorizationStatusAuthorizedWhenInUse || status == kCLAuthorizationStatusAuthorizedAlways) {
|
// [self performSegueWithIdentifier:@"go2WifiInfo" sender:nil];
|
// }
|
}
|
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations{
|
[_locationmanager stopUpdatingLocation];
|
}
|
|
#pragma mark - UISceneSession lifecycle
|
|
|
//- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options {
|
// // Called when a new scene session is being created.
|
// // Use this method to select a configuration to create the new scene with.
|
// return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role];
|
//}
|
//
|
//
|
//- (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet<UISceneSession *> *)sceneSessions {
|
// // Called when the user discards a scene session.
|
// // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
|
// // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
|
//}
|
|
|
#pragma mark - Core Data stack
|
|
@synthesize persistentContainer = _persistentContainer;
|
|
- (NSPersistentContainer *)persistentContainer {
|
// The persistent container for the application. This implementation creates and returns a container, having loaded the store for the application to it.
|
@synchronized (self) {
|
if (_persistentContainer == nil) {
|
_persistentContainer = [[NSPersistentContainer alloc] initWithName:@"HDLEZDemo"];
|
[_persistentContainer loadPersistentStoresWithCompletionHandler:^(NSPersistentStoreDescription *storeDescription, NSError *error) {
|
if (error != nil) {
|
// Replace this implementation with code to handle the error appropriately.
|
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
|
|
/*
|
Typical reasons for an error here include:
|
* The parent directory does not exist, cannot be created, or disallows writing.
|
* The persistent store is not accessible, due to permissions or data protection when the device is locked.
|
* The device is out of space.
|
* The store could not be migrated to the current model version.
|
Check the error message to determine what the actual problem was.
|
*/
|
NSLog(@"Unresolved error %@, %@", error, error.userInfo);
|
abort();
|
}
|
}];
|
}
|
}
|
|
return _persistentContainer;
|
}
|
|
#pragma mark - Core Data Saving support
|
|
- (void)saveContext {
|
NSManagedObjectContext *context = self.persistentContainer.viewContext;
|
NSError *error = nil;
|
if ([context hasChanges] && ![context save:&error]) {
|
// Replace this implementation with code to handle the error appropriately.
|
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
|
NSLog(@"Unresolved error %@, %@", error, error.userInfo);
|
abort();
|
}
|
}
|
|
@end
|