|
@@ -102,7 +102,21 @@ static dispatch_queue_t persisitingQueue; |
|
@@ -102,7 +102,21 @@ static dispatch_queue_t persisitingQueue; |
102
|
return _locationManager;
|
102
|
return _locationManager;
|
103
|
}
|
103
|
}
|
104
|
|
104
|
|
105
|
-#pragma mark - Functions
|
105
|
+- (void)setLogStrategy:(YHLogStrategy)strategyNumber
|
|
|
106
|
+{
|
|
|
107
|
+ NSUserDefaults *strategy = [NSUserDefaults standardUserDefaults];
|
|
|
108
|
+ [strategy setObject: [NSNumber numberWithInteger:strategyNumber] forKey:@"LOGSTRATEGY"];
|
|
|
109
|
+ [strategy synchronize];
|
|
|
110
|
+}
|
|
|
111
|
+
|
|
|
112
|
+- (YHLogStrategy)logStrategy
|
|
|
113
|
+{
|
|
|
114
|
+ NSUserDefaults *strategy = [NSUserDefaults standardUserDefaults];
|
|
|
115
|
+ NSNumber * strategyObj = [strategy objectForKey:@"LOGSTRATEGY"];
|
|
|
116
|
+ return [strategyObj intValue];
|
|
|
117
|
+}
|
|
|
118
|
+
|
|
|
119
|
+#pragma mark - Private Method
|
106
|
|
120
|
|
107
|
// 添加网络监测回调block
|
121
|
// 添加网络监测回调block
|
108
|
- (void)startObserverNetworkReachabilityStatus
|
122
|
- (void)startObserverNetworkReachabilityStatus
|
|
@@ -185,6 +199,36 @@ static dispatch_queue_t persisitingQueue; |
|
@@ -185,6 +199,36 @@ static dispatch_queue_t persisitingQueue; |
185
|
self.session = nil;
|
199
|
self.session = nil;
|
186
|
}
|
200
|
}
|
187
|
|
201
|
|
|
|
202
|
+- (NSString *)timestamp
|
|
|
203
|
+{
|
|
|
204
|
+ long long now = [[NSDate date] timeIntervalSince1970];
|
|
|
205
|
+ long long int date = (long long int)now;
|
|
|
206
|
+ return [NSString stringWithFormat:@"%lld", date];
|
|
|
207
|
+}
|
|
|
208
|
+
|
|
|
209
|
+// 发送本地持久化数据
|
|
|
210
|
+- (void)uploadDiskData
|
|
|
211
|
+{
|
|
|
212
|
+ [[YHAssemblyAssistant sharedInstance] uploadDiskData];
|
|
|
213
|
+}
|
|
|
214
|
+
|
|
|
215
|
+// 发送本地持久化数据
|
|
|
216
|
+- (void)tryUploadDiskData
|
|
|
217
|
+{
|
|
|
218
|
+ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
|
|
219
|
+ NSString *lastUploadTime = [defaults objectForKey:kKeyUserDefaultsLastUploadTimestamp];
|
|
|
220
|
+ NSString *timeStamp = [self timestamp];
|
|
|
221
|
+ NSInteger uploadTimeInterval = [timeStamp integerValue] - [lastUploadTime integerValue];
|
|
|
222
|
+
|
|
|
223
|
+ if (uploadTimeInterval > self.currentInterval) {
|
|
|
224
|
+ [self uploadDiskData];
|
|
|
225
|
+ [defaults setObject:timeStamp forKey:kKeyUserDefaultsLastUploadTimestamp];
|
|
|
226
|
+ [defaults synchronize];
|
|
|
227
|
+ }
|
|
|
228
|
+}
|
|
|
229
|
+
|
|
|
230
|
+#pragma mark - Public Method
|
|
|
231
|
+
|
188
|
- (void)startWithAppId:(NSString *)appId
|
232
|
- (void)startWithAppId:(NSString *)appId
|
189
|
{
|
233
|
{
|
190
|
[self startObserverNetworkReachabilityStatus];
|
234
|
[self startObserverNetworkReachabilityStatus];
|
|
@@ -281,35 +325,6 @@ static dispatch_queue_t persisitingQueue; |
|
@@ -281,35 +325,6 @@ static dispatch_queue_t persisitingQueue; |
281
|
}
|
325
|
}
|
282
|
|
326
|
|
283
|
|
327
|
|
284
|
-- (NSString *)timestamp
|
|
|
285
|
-{
|
|
|
286
|
- long long now = [[NSDate date] timeIntervalSince1970];
|
|
|
287
|
- long long int date = (long long int)now;
|
|
|
288
|
- return [NSString stringWithFormat:@"%lld", date];
|
|
|
289
|
-}
|
|
|
290
|
-
|
|
|
291
|
-// 发送本地持久化数据
|
|
|
292
|
-- (void)uploadDiskData
|
|
|
293
|
-{
|
|
|
294
|
- [[YHAssemblyAssistant sharedInstance] uploadDiskData];
|
|
|
295
|
-}
|
|
|
296
|
-
|
|
|
297
|
-// 发送本地持久化数据
|
|
|
298
|
-- (void)tryUploadDiskData
|
|
|
299
|
-{
|
|
|
300
|
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
|
|
301
|
- NSString *lastUploadTime = [defaults objectForKey:kKeyUserDefaultsLastUploadTimestamp];
|
|
|
302
|
- NSString *timeStamp = [self timestamp];
|
|
|
303
|
- NSInteger uploadTimeInterval = [timeStamp integerValue] - [lastUploadTime integerValue];
|
|
|
304
|
-
|
|
|
305
|
- if (uploadTimeInterval > self.currentInterval) {
|
|
|
306
|
- [self uploadDiskData];
|
|
|
307
|
- [defaults setObject:timeStamp forKey:kKeyUserDefaultsLastUploadTimestamp];
|
|
|
308
|
- [defaults synchronize];
|
|
|
309
|
- }
|
|
|
310
|
-}
|
|
|
311
|
-
|
|
|
312
|
-#pragma mark - Location
|
|
|
313
|
#pragma mark - CLLocationManagerDelegate
|
328
|
#pragma mark - CLLocationManagerDelegate
|
314
|
|
329
|
|
315
|
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
|
330
|
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
|
|
@@ -345,18 +360,4 @@ static dispatch_queue_t persisitingQueue; |
|
@@ -345,18 +360,4 @@ static dispatch_queue_t persisitingQueue; |
345
|
NSLog(@"%@", errorMsg);
|
360
|
NSLog(@"%@", errorMsg);
|
346
|
}
|
361
|
}
|
347
|
|
362
|
|
348
|
-
|
|
|
349
|
-- (void)setLogStrategy:(YHLogStrategy)strategyNumber
|
|
|
350
|
-{
|
|
|
351
|
- NSUserDefaults *strategy = [NSUserDefaults standardUserDefaults];
|
|
|
352
|
- [strategy setObject: [NSNumber numberWithInteger:strategyNumber] forKey:@"LOGSTRATEGY"];
|
|
|
353
|
- [strategy synchronize];
|
|
|
354
|
-}
|
|
|
355
|
-
|
|
|
356
|
-- (YHLogStrategy)logStrategy
|
|
|
357
|
-{
|
|
|
358
|
- NSUserDefaults *strategy = [NSUserDefaults standardUserDefaults];
|
|
|
359
|
- NSNumber * strategyObj = [strategy objectForKey:@"LOGSTRATEGY"];
|
|
|
360
|
- return [strategyObj intValue];
|
|
|
361
|
-}
|
|
|
362
|
@end |
363
|
@end |