...
|
...
|
@@ -102,7 +102,21 @@ static dispatch_queue_t persisitingQueue; |
|
|
return _locationManager;
|
|
|
}
|
|
|
|
|
|
#pragma mark - Functions
|
|
|
- (void)setLogStrategy:(YHLogStrategy)strategyNumber
|
|
|
{
|
|
|
NSUserDefaults *strategy = [NSUserDefaults standardUserDefaults];
|
|
|
[strategy setObject: [NSNumber numberWithInteger:strategyNumber] forKey:@"LOGSTRATEGY"];
|
|
|
[strategy synchronize];
|
|
|
}
|
|
|
|
|
|
- (YHLogStrategy)logStrategy
|
|
|
{
|
|
|
NSUserDefaults *strategy = [NSUserDefaults standardUserDefaults];
|
|
|
NSNumber * strategyObj = [strategy objectForKey:@"LOGSTRATEGY"];
|
|
|
return [strategyObj intValue];
|
|
|
}
|
|
|
|
|
|
#pragma mark - Private Method
|
|
|
|
|
|
// 添加网络监测回调block
|
|
|
- (void)startObserverNetworkReachabilityStatus
|
...
|
...
|
@@ -185,6 +199,36 @@ static dispatch_queue_t persisitingQueue; |
|
|
self.session = nil;
|
|
|
}
|
|
|
|
|
|
- (NSString *)timestamp
|
|
|
{
|
|
|
long long now = [[NSDate date] timeIntervalSince1970];
|
|
|
long long int date = (long long int)now;
|
|
|
return [NSString stringWithFormat:@"%lld", date];
|
|
|
}
|
|
|
|
|
|
// 发送本地持久化数据
|
|
|
- (void)uploadDiskData
|
|
|
{
|
|
|
[[YHAssemblyAssistant sharedInstance] uploadDiskData];
|
|
|
}
|
|
|
|
|
|
// 发送本地持久化数据
|
|
|
- (void)tryUploadDiskData
|
|
|
{
|
|
|
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
|
|
NSString *lastUploadTime = [defaults objectForKey:kKeyUserDefaultsLastUploadTimestamp];
|
|
|
NSString *timeStamp = [self timestamp];
|
|
|
NSInteger uploadTimeInterval = [timeStamp integerValue] - [lastUploadTime integerValue];
|
|
|
|
|
|
if (uploadTimeInterval > self.currentInterval) {
|
|
|
[self uploadDiskData];
|
|
|
[defaults setObject:timeStamp forKey:kKeyUserDefaultsLastUploadTimestamp];
|
|
|
[defaults synchronize];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#pragma mark - Public Method
|
|
|
|
|
|
- (void)startWithAppId:(NSString *)appId
|
|
|
{
|
|
|
[self startObserverNetworkReachabilityStatus];
|
...
|
...
|
@@ -281,35 +325,6 @@ static dispatch_queue_t persisitingQueue; |
|
|
}
|
|
|
|
|
|
|
|
|
- (NSString *)timestamp
|
|
|
{
|
|
|
long long now = [[NSDate date] timeIntervalSince1970];
|
|
|
long long int date = (long long int)now;
|
|
|
return [NSString stringWithFormat:@"%lld", date];
|
|
|
}
|
|
|
|
|
|
// 发送本地持久化数据
|
|
|
- (void)uploadDiskData
|
|
|
{
|
|
|
[[YHAssemblyAssistant sharedInstance] uploadDiskData];
|
|
|
}
|
|
|
|
|
|
// 发送本地持久化数据
|
|
|
- (void)tryUploadDiskData
|
|
|
{
|
|
|
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
|
|
NSString *lastUploadTime = [defaults objectForKey:kKeyUserDefaultsLastUploadTimestamp];
|
|
|
NSString *timeStamp = [self timestamp];
|
|
|
NSInteger uploadTimeInterval = [timeStamp integerValue] - [lastUploadTime integerValue];
|
|
|
|
|
|
if (uploadTimeInterval > self.currentInterval) {
|
|
|
[self uploadDiskData];
|
|
|
[defaults setObject:timeStamp forKey:kKeyUserDefaultsLastUploadTimestamp];
|
|
|
[defaults synchronize];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#pragma mark - Location
|
|
|
#pragma mark - CLLocationManagerDelegate
|
|
|
|
|
|
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
|
...
|
...
|
@@ -345,18 +360,4 @@ static dispatch_queue_t persisitingQueue; |
|
|
NSLog(@"%@", errorMsg);
|
|
|
}
|
|
|
|
|
|
|
|
|
- (void)setLogStrategy:(YHLogStrategy)strategyNumber
|
|
|
{
|
|
|
NSUserDefaults *strategy = [NSUserDefaults standardUserDefaults];
|
|
|
[strategy setObject: [NSNumber numberWithInteger:strategyNumber] forKey:@"LOGSTRATEGY"];
|
|
|
[strategy synchronize];
|
|
|
}
|
|
|
|
|
|
- (YHLogStrategy)logStrategy
|
|
|
{
|
|
|
NSUserDefaults *strategy = [NSUserDefaults standardUserDefaults];
|
|
|
NSNumber * strategyObj = [strategy objectForKey:@"LOGSTRATEGY"];
|
|
|
return [strategyObj intValue];
|
|
|
}
|
|
|
@end |
...
|
...
|
|