diff --git a/.gitignore b/.gitignore
index c933968..dec4230 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,3 +12,5 @@ ios/.generated
pubspec.lock
doc/
build/
+example/.flutter-plugins-dependencies
+example/ios/Flutter/flutter_export_environment.sh
diff --git a/example/.flutter-plugins-dependencies b/example/.flutter-plugins-dependencies
deleted file mode 100644
index 4dea89c..0000000
--- a/example/.flutter-plugins-dependencies
+++ /dev/null
@@ -1 +0,0 @@
-{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"background_fetch","path":"/Volumes/Glyph2TB/Users/chris/workspace/background-geolocation/flutter/flutter_background_fetch/","dependencies":[]},{"name":"shared_preferences","path":"/Volumes/Glyph2TB/Users/chris/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.6+1/","dependencies":[]}],"android":[{"name":"background_fetch","path":"/Volumes/Glyph2TB/Users/chris/workspace/background-geolocation/flutter/flutter_background_fetch/","dependencies":[]},{"name":"shared_preferences","path":"/Volumes/Glyph2TB/Users/chris/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.6+1/","dependencies":[]}],"macos":[{"name":"shared_preferences_macos","path":"/Volumes/Glyph2TB/Users/chris/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-0.0.1+4/","dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"shared_preferences_web","path":"/Volumes/Glyph2TB/Users/chris/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_web-0.1.2+3/","dependencies":[]}]},"dependencyGraph":[{"name":"background_fetch","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]}],"date_created":"2020-06-12 09:58:57.324790","version":"1.17.3"}
\ No newline at end of file
diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh
deleted file mode 100755
index 9238991..0000000
--- a/example/ios/Flutter/flutter_export_environment.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/sh
-# This is a generated file; do not edit or check into version control.
-export "FLUTTER_ROOT=/Volumes/Glyph2TB/Users/chris/development/flutter"
-export "FLUTTER_APPLICATION_PATH=/Volumes/Glyph2TB/Users/chris/workspace/background-geolocation/flutter/flutter_background_fetch/example"
-export "FLUTTER_TARGET=lib/main.dart"
-export "FLUTTER_BUILD_DIR=build"
-export "SYMROOT=${SOURCE_ROOT}/../build/ios"
-export "OTHER_LDFLAGS=$(inherited) -framework Flutter"
-export "FLUTTER_FRAMEWORK_DIR=/Volumes/Glyph2TB/Users/chris/development/flutter/bin/cache/artifacts/engine/ios"
-export "FLUTTER_BUILD_NAME=1.0.0"
-export "FLUTTER_BUILD_NUMBER=1"
diff --git a/ios/Classes/BackgroundFetchPlugin.m b/ios/Classes/BackgroundFetchPlugin.m
index 9340359..61bb4e4 100644
--- a/ios/Classes/BackgroundFetchPlugin.m
+++ b/ios/Classes/BackgroundFetchPlugin.m
@@ -142,10 +142,14 @@ - (void) scheduleTask:(NSDictionary*)config result:(FlutterResult)result {
long delayMS = [[config objectForKey:@"delay"] longValue];
NSTimeInterval delay = delayMS / 1000;
BOOL periodic = [[config objectForKey:@"periodic"] boolValue];
+ BOOL requiresExternalPower = [[config objectForKey:@"requiresCharging"] boolValue];
+ BOOL requiresNetworkConnectivity = [[config objectForKey:@"requiresNetworkConnectivity"] boolValue];
NSError *error = [[TSBackgroundFetch sharedInstance] scheduleProcessingTaskWithIdentifier:taskId
delay:delay
periodic:periodic
+ requiresExternalPower:requiresExternalPower
+ requiresNetworkConnectivity:requiresNetworkConnectivity
callback:[self createCallback]];
if (!error) {
result(@(YES));
diff --git a/ios/TSBackgroundFetch.framework/Headers/TSBackgroundFetch.h b/ios/TSBackgroundFetch.framework/Headers/TSBackgroundFetch.h
index 278855f..06a8fd4 100644
--- a/ios/TSBackgroundFetch.framework/Headers/TSBackgroundFetch.h
+++ b/ios/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.framework/Info.plist b/ios/TSBackgroundFetch.framework/Info.plist
index 45089bf..7f544fe 100644
Binary files a/ios/TSBackgroundFetch.framework/Info.plist and b/ios/TSBackgroundFetch.framework/Info.plist differ
diff --git a/ios/TSBackgroundFetch.framework/TSBackgroundFetch b/ios/TSBackgroundFetch.framework/TSBackgroundFetch
old mode 100755
new mode 100644
index f3fe5f1..941e5a4
Binary files a/ios/TSBackgroundFetch.framework/TSBackgroundFetch and b/ios/TSBackgroundFetch.framework/TSBackgroundFetch differ
diff --git a/ios/TSBackgroundFetch.framework/_CodeSignature/CodeDirectory b/ios/TSBackgroundFetch.framework/_CodeSignature/CodeDirectory
deleted file mode 100644
index e065472..0000000
Binary files a/ios/TSBackgroundFetch.framework/_CodeSignature/CodeDirectory and /dev/null differ
diff --git a/ios/TSBackgroundFetch.framework/_CodeSignature/CodeRequirements b/ios/TSBackgroundFetch.framework/_CodeSignature/CodeRequirements
deleted file mode 100644
index 3141d21..0000000
Binary files a/ios/TSBackgroundFetch.framework/_CodeSignature/CodeRequirements and /dev/null differ
diff --git a/ios/TSBackgroundFetch.framework/_CodeSignature/CodeRequirements-1 b/ios/TSBackgroundFetch.framework/_CodeSignature/CodeRequirements-1
deleted file mode 100644
index c68ed6c..0000000
Binary files a/ios/TSBackgroundFetch.framework/_CodeSignature/CodeRequirements-1 and /dev/null differ
diff --git a/ios/TSBackgroundFetch.framework/_CodeSignature/CodeResources b/ios/TSBackgroundFetch.framework/_CodeSignature/CodeResources
deleted file mode 100644
index bfba954..0000000
--- a/ios/TSBackgroundFetch.framework/_CodeSignature/CodeResources
+++ /dev/null
@@ -1,151 +0,0 @@
-
-
-
-
- files
-
- Headers/TSBackgroundFetch.h
-
- 6IaHDuPW1C0nWBp03yKGD5PrgTY=
-
- Info.plist
-
- /q6b6t8hcxgtnV2U/r/pxyTm1is=
-
- Modules/module.modulemap
-
- 4NbofBeHHFHeUWRZ1ZcIkl3/T3w=
-
-
- files2
-
- Headers/TSBackgroundFetch.h
-
- hash
-
- 6IaHDuPW1C0nWBp03yKGD5PrgTY=
-
- hash2
-
- Q6MbZjcbrHTACLwceQDEESRGhY9/uOOu7bCb71fOAfk=
-
-
- Modules/module.modulemap
-
- hash
-
- 4NbofBeHHFHeUWRZ1ZcIkl3/T3w=
-
- hash2
-
- ZZoRDGe9SOWekYXO71UHMmkagz+I18vRneUTVMd0WnY=
-
-
-
- rules
-
- ^
-
- ^.*\.lproj/
-
- optional
-
- weight
- 1000
-
- ^.*\.lproj/locversion.plist$
-
- omit
-
- weight
- 1100
-
- ^Base\.lproj/
-
- weight
- 1010
-
- ^version.plist$
-
-
- rules2
-
- .*\.dSYM($|/)
-
- weight
- 11
-
- ^
-
- weight
- 20
-
- ^(.*/)?\.DS_Store$
-
- omit
-
- weight
- 2000
-
- ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/
-
- nested
-
- weight
- 10
-
- ^.*
-
- ^.*\.lproj/
-
- optional
-
- weight
- 1000
-
- ^.*\.lproj/locversion.plist$
-
- omit
-
- weight
- 1100
-
- ^Base\.lproj/
-
- weight
- 1010
-
- ^Info\.plist$
-
- omit
-
- weight
- 20
-
- ^PkgInfo$
-
- omit
-
- weight
- 20
-
- ^[^/]+$
-
- nested
-
- weight
- 10
-
- ^embedded\.provisionprofile$
-
- weight
- 20
-
- ^version\.plist$
-
- weight
- 20
-
-
-
-
diff --git a/ios/TSBackgroundFetch.framework/_CodeSignature/CodeSignature b/ios/TSBackgroundFetch.framework/_CodeSignature/CodeSignature
deleted file mode 100644
index 12a6a8c..0000000
Binary files a/ios/TSBackgroundFetch.framework/_CodeSignature/CodeSignature and /dev/null differ
diff --git a/lib/background_fetch.dart b/lib/background_fetch.dart
index 9a9e31c..d28796e 100644
--- a/lib/background_fetch.dart
+++ b/lib/background_fetch.dart
@@ -105,7 +105,9 @@ class _AbstractTaskConfig {
bool requiresStorageNotLow;
///
- /// [Android only] Specify that to run this job, the device must be charging (or be a non-battery-powered device connected to permanent power, such as Android TV devices). This defaults to false.
+ /// Specify that to run this job, the device must be charging (or be a non-battery-powered device connected to permanent power, such as Android TV devices). This defaults to [false].
+ ///
+ /// This will use the [requiresCharging] param on Android and [requiresExternalPower] param on iOS.
///
bool requiresCharging;
@@ -118,6 +120,12 @@ class _AbstractTaskConfig {
///
bool requiresDeviceIdle;
+ ///
+ /// [iOS only] When set true, ensure that this job will run only when device is has network connectivity.
+ ///
+ /// The default state is false: that is, the job can run even if device does not have network connectivity.
+ bool requiresNetworkConnectivity;
+
_AbstractTaskConfig(
{this.stopOnTerminate,
this.startOnBoot,
@@ -127,7 +135,8 @@ class _AbstractTaskConfig {
this.requiresBatteryNotLow,
this.requiresStorageNotLow,
this.requiresCharging,
- this.requiresDeviceIdle});
+ this.requiresDeviceIdle,
+ this.requiresNetworkConnectivity = false});
Map toMap() {
Map config = {};
@@ -145,6 +154,7 @@ class _AbstractTaskConfig {
if (requiresCharging != null) config['requiresCharging'] = requiresCharging;
if (requiresDeviceIdle != null)
config['requiresDeviceIdle'] = requiresDeviceIdle;
+ config['requiresNetworkConnectivity'] = requiresNetworkConnectivity ?? false;
return config;
}
}
@@ -225,6 +235,8 @@ class TaskConfig extends _AbstractTaskConfig {
bool requiresStorageNotLow,
bool requiresCharging,
bool requiresDeviceIdle,
+ bool requiresExternalPower,
+ bool requiresNetworkConnectivity,
}) : super(
stopOnTerminate: stopOnTerminate,
startOnBoot: startOnBoot,
@@ -234,13 +246,16 @@ class TaskConfig extends _AbstractTaskConfig {
requiresBatteryNotLow: requiresBatteryNotLow,
requiresStorageNotLow: requiresStorageNotLow,
requiresCharging: requiresCharging,
- requiresDeviceIdle: requiresDeviceIdle);
+ requiresDeviceIdle: requiresDeviceIdle,
+ requiresNetworkConnectivity: requiresNetworkConnectivity);
Map toMap() {
Map config = super.toMap();
config['taskId'] = this.taskId;
config['delay'] = this.delay;
config['periodic'] = this.periodic;
+ config['requiresCharging'] = this.requiresCharging ?? false;
+ config['requiresNetworkConnectivity'] = this.requiresNetworkConnectivity ?? false;
return config;
}
}