diff --git a/ios/TSBackgroundFetch/TSBackgroundFetch.framework/Headers/TSBackgroundFetch.h b/ios/TSBackgroundFetch/TSBackgroundFetch.framework/Headers/TSBackgroundFetch.h index 278855f..06a8fd4 100644 --- a/ios/TSBackgroundFetch/TSBackgroundFetch.framework/Headers/TSBackgroundFetch.h +++ b/ios/TSBackgroundFetch/TSBackgroundFetch.framework/Headers/TSBackgroundFetch.h @@ -25,7 +25,7 @@ -(void) configure:(NSTimeInterval)delay callback:(void(^)(UIBackgroundRefreshStatus status))callback; --(NSError*) scheduleProcessingTaskWithIdentifier:(NSString*)identifier delay:(NSTimeInterval)delay periodic:(BOOL)periodic callback:(void (^)(NSString* taskId))callback; +-(NSError*) scheduleProcessingTaskWithIdentifier:(NSString*)identifier delay:(NSTimeInterval)delay periodic:(BOOL)periodic requiresExternalPower:(BOOL)requiresExternalPower requiresNetworkConnectivity:(BOOL)requiresNetworkConnectivity callback:(void (^)(NSString* taskId))callback; -(void) addListener:(NSString*)componentName callback:(void (^)(NSString* componentName))callback; -(void) removeListener:(NSString*)componentName; diff --git a/ios/TSBackgroundFetch/TSBackgroundFetch.framework/Info.plist b/ios/TSBackgroundFetch/TSBackgroundFetch.framework/Info.plist index 45089bf..7f544fe 100644 Binary files a/ios/TSBackgroundFetch/TSBackgroundFetch.framework/Info.plist and b/ios/TSBackgroundFetch/TSBackgroundFetch.framework/Info.plist differ diff --git a/ios/TSBackgroundFetch/TSBackgroundFetch.framework/TSBackgroundFetch b/ios/TSBackgroundFetch/TSBackgroundFetch.framework/TSBackgroundFetch old mode 100755 new mode 100644 index f3fe5f1..941e5a4 Binary files a/ios/TSBackgroundFetch/TSBackgroundFetch.framework/TSBackgroundFetch and b/ios/TSBackgroundFetch/TSBackgroundFetch.framework/TSBackgroundFetch differ diff --git a/ios/TSBackgroundFetch/TSBackgroundFetch/TSBGTask.h b/ios/TSBackgroundFetch/TSBackgroundFetch/TSBGTask.h index bdd4228..e4abf08 100644 --- a/ios/TSBackgroundFetch/TSBackgroundFetch/TSBGTask.h +++ b/ios/TSBackgroundFetch/TSBackgroundFetch/TSBGTask.h @@ -21,7 +21,9 @@ @property (nonatomic) BOOL periodic; @property (nonatomic) BOOL enabled; @property (nonatomic, readonly) BOOL finished; -@property (nonatomic) BOOL stopOnTerminate; +@property (nonatomic) BOOL stopOnTerminate; +@property (nonatomic) BOOL requiresExternalPower; +@property (nonatomic) BOOL requiresNetworkConnectivity; +(void)load; +(NSMutableArray *)tasks; @@ -32,7 +34,7 @@ +(void)registerForTaskWithIdentifier:(NSString*)identifier; +(BOOL)useProcessingTaskScheduler; --(instancetype) initWithIdentifier:(NSString*)identifier delay:(NSTimeInterval)delay periodic:(BOOL)periodic callback:(void (^)(NSString* taskId))callback; +-(instancetype) initWithIdentifier:(NSString*)identifier delay:(NSTimeInterval)delay periodic:(BOOL)periodic requiresExternalPower:(BOOL)requiresExternalPower requiresNetworkConnectivity:(BOOL)requiresNetworkConnectivity callback:(void (^)(NSString* taskId))callback; -(instancetype) initWithDictionary:(NSDictionary*)config; -(BOOL) execute; diff --git a/ios/TSBackgroundFetch/TSBackgroundFetch/TSBGTask.m b/ios/TSBackgroundFetch/TSBackgroundFetch/TSBGTask.m index 7363358..c74ade3 100644 --- a/ios/TSBackgroundFetch/TSBackgroundFetch/TSBGTask.m +++ b/ios/TSBackgroundFetch/TSBackgroundFetch/TSBGTask.m @@ -108,13 +108,15 @@ -(instancetype)init { return self; } --(instancetype) initWithIdentifier:(NSString*)identifier delay:(NSTimeInterval)delay periodic:(BOOL)periodic callback:(void (^)(NSString* taskId))callback { +-(instancetype) initWithIdentifier:(NSString*)identifier delay:(NSTimeInterval)delay periodic:(BOOL)periodic requiresExternalPower:(BOOL)requiresExternalPower requiresNetworkConnectivity:(BOOL)requiresNetworkConnectivity callback:(void (^)(NSString* taskId))callback { self = [self init]; if (self) { _identifier = identifier; _delay = delay; _periodic = periodic; + _requiresExternalPower = requiresExternalPower; + _requiresNetworkConnectivity = requiresNetworkConnectivity; [TSBGTask add:self]; } return self; @@ -127,6 +129,8 @@ -(instancetype) initWithDictionary:(NSDictionary*)config { _delay = [[config objectForKey:@"delay"] longValue]; _periodic = [[config objectForKey:@"periodic"] boolValue]; _enabled = [[config objectForKey:@"enabled"] boolValue]; + _requiresExternalPower = [[config objectForKey:@"_requiresExternalPower"] boolValue]; + _requiresNetworkConnectivity = [[config objectForKey:@"_requiresNetworkConnectivity"] boolValue]; } return self; } @@ -146,9 +150,8 @@ - (NSError*) schedule { } BGProcessingTaskRequest *request = [[BGProcessingTaskRequest alloc] initWithIdentifier:_identifier]; - // TODO Configurable. - request.requiresExternalPower = NO; - request.requiresNetworkConnectivity = NO; + request.requiresExternalPower = _requiresExternalPower; + request.requiresNetworkConnectivity = _requiresNetworkConnectivity; request.earliestBeginDate = [NSDate dateWithTimeIntervalSinceNow:_delay]; NSError *error = nil; @@ -258,12 +261,14 @@ -(NSDictionary*) toDictionary { @"identifier": _identifier, @"delay": @(_delay), @"periodic": @(_periodic), - @"enabled": @(_enabled) + @"enabled": @(_enabled), + @"requiresExternalPower": @(_requiresExternalPower), + @"requiresNetworkConnectivity": @(_requiresNetworkConnectivity) }; } -(NSString*) description { - return [NSString stringWithFormat:@"", _identifier, (long)_delay, _periodic, _enabled]; + return [NSString stringWithFormat:@"", _identifier, (long)_delay, _periodic, _enabled, _requiresExternalPower, _requiresNetworkConnectivity]; } @end diff --git a/ios/TSBackgroundFetch/TSBackgroundFetch/TSBackgroundFetch.h b/ios/TSBackgroundFetch/TSBackgroundFetch/TSBackgroundFetch.h index 278855f..06a8fd4 100644 --- a/ios/TSBackgroundFetch/TSBackgroundFetch/TSBackgroundFetch.h +++ b/ios/TSBackgroundFetch/TSBackgroundFetch/TSBackgroundFetch.h @@ -25,7 +25,7 @@ -(void) configure:(NSTimeInterval)delay callback:(void(^)(UIBackgroundRefreshStatus status))callback; --(NSError*) scheduleProcessingTaskWithIdentifier:(NSString*)identifier delay:(NSTimeInterval)delay periodic:(BOOL)periodic callback:(void (^)(NSString* taskId))callback; +-(NSError*) scheduleProcessingTaskWithIdentifier:(NSString*)identifier delay:(NSTimeInterval)delay periodic:(BOOL)periodic requiresExternalPower:(BOOL)requiresExternalPower requiresNetworkConnectivity:(BOOL)requiresNetworkConnectivity callback:(void (^)(NSString* taskId))callback; -(void) addListener:(NSString*)componentName callback:(void (^)(NSString* componentName))callback; -(void) removeListener:(NSString*)componentName; diff --git a/ios/TSBackgroundFetch/TSBackgroundFetch/TSBackgroundFetch.m b/ios/TSBackgroundFetch/TSBackgroundFetch/TSBackgroundFetch.m index 9d3f479..316ad62 100644 --- a/ios/TSBackgroundFetch/TSBackgroundFetch/TSBackgroundFetch.m +++ b/ios/TSBackgroundFetch/TSBackgroundFetch/TSBackgroundFetch.m @@ -172,7 +172,7 @@ -(void) configure:(NSTimeInterval)delay callback:(void(^)(UIBackgroundRefreshSta }]; } --(NSError*) scheduleProcessingTaskWithIdentifier:(NSString*)identifier delay:(NSTimeInterval)delay periodic:(BOOL)periodic callback:(void (^)(NSString* taskId))callback { +-(NSError*) scheduleProcessingTaskWithIdentifier:(NSString*)identifier delay:(NSTimeInterval)delay periodic:(BOOL)periodic requiresExternalPower:(BOOL)requiresExternalPower requiresNetworkConnectivity:(BOOL)requiresNetworkConnectivity callback:(void (^)(NSString* taskId))callback { TSBGTask *tsTask = [TSBGTask get:identifier]; if (tsTask) { tsTask.delay = delay; @@ -187,7 +187,7 @@ -(NSError*) scheduleProcessingTaskWithIdentifier:(NSString*)identifier delay:(NS } } } else { - tsTask = [[TSBGTask alloc] initWithIdentifier:identifier delay:delay periodic:periodic callback:callback]; + tsTask = [[TSBGTask alloc] initWithIdentifier:identifier delay:delay periodic:periodic requiresExternalPower:requiresExternalPower requiresNetworkConnectivity:requiresNetworkConnectivity callback:callback]; tsTask.callback = callback; }