react-native-background-task
Advanced tools
Comparing version 0.2.0 to 0.2.1
{ | ||
"name": "react-native-background-task", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"author": "James Isaac <james.isaac@gmail.com>", | ||
@@ -5,0 +5,0 @@ "description": "Periodic background tasks for React Native apps, cross-platform (iOS and Android), which run even when the app is closed.", |
@@ -21,3 +21,3 @@ # react-native-background-task | ||
- Min API level: 16 (Android 4.1). | ||
- **iOS**: [react-native-background-fetch](https://github.com/transistorsoft/react-native-background-fetch), | ||
- **iOS**: A proxy around [react-native-background-fetch](https://github.com/transistorsoft/react-native-background-fetch), | ||
which uses the iOS-specific `Background Fetch` technique. | ||
@@ -97,7 +97,7 @@ | ||
- **`period?`** `number` - (Android only) Desired number of seconds between each | ||
- **`period?`**: `number` - (Android only) Desired number of seconds between each | ||
execution of the task. Even on Android, the OS will only take this as a | ||
recommendation, and will enforce a minimum of 15 minutes (similar to iOS). | ||
Default is 900 (15 minutes) | ||
- **`timeout?`** `number` - (Android only) Number of seconds the task will have | ||
- **`timeout?`**: `number` - (Android only) Number of seconds the task will have | ||
to execute. iOS has a hardcoded limit of 30 seconds. Default 30 seconds. | ||
@@ -119,17 +119,20 @@ | ||
- **`available`** `boolean` - Whether background tasks are available to the app. | ||
- **`available`**: `boolean` - Whether background tasks are available to the app. | ||
On Android this will always be true, but on iOS background tasks could be | ||
blocked (see [UIBackgroundRefreshStatus](https://developer.apple.com/documentation/uikit/uibackgroundrefreshstatus)). | ||
- **`unavailableReason?`** `string` - If unavailable, gives the reason: | ||
- **`BackgroundTask.UNAVAILABLE_DENIED`** - The user explicitly disabled | ||
- **`unavailableReason?`**: `string` - If unavailable, gives the reason: | ||
- **`BackgroundTask.UNAVAILABLE_DENIED`**: - The user explicitly disabled | ||
background behavior for this app or for the whole system. | ||
- **`BackgroundTask.UNAVAILABLE_RESTRICTED`** - Background updates | ||
- **`BackgroundTask.UNAVAILABLE_RESTRICTED`**: - Background updates | ||
unavailable and can't be enabled by the user (e.g. parental controls). | ||
## Caveats | ||
## Limitations | ||
- The exact timings of tasks are unpredictable (depends on device sleep state | ||
etc.), and cannot be more frequent than every 15 minutes. This library | ||
should only be used for tasks that can have inexact timing, such as the | ||
periodic background syncing of data. | ||
- Tasks cannot be scheduled any more frequently than every 15 minutes. | ||
- The exact timings of task execution are unpredictable, as both Anrdoid and | ||
iOS use black-box algorithms, which depend on factors like device sleep | ||
state. This library should only be used for tasks that are an incremental | ||
feature, and can have inexact timing, such as the periodic background syncing | ||
of data. You should be prepared for the case that background task doesn't | ||
fires at all. | ||
@@ -144,4 +147,9 @@ Android: | ||
- iOS Background Fetch does not work in the simulator. It must be tested on a | ||
real device. | ||
- iOS Background Fetch will not continue to run after a user manually closes | ||
the app. (The app being closed by the OS to free up memory etc. should be | ||
fine). | ||
- Background tasks will not be scheduled in the simulator. You'll need to | ||
either test it on a real device, or use the | ||
[Simulate Background Fetch](https://developer.apple.com/library/content/documentation/IDEs/Conceptual/iOS_Simulator_Guide/TestingontheiOSSimulator/TestingontheiOSSimulator.html#//apple_ref/doc/uid/TP40012848-CH4-SW5) | ||
feature of Xcode. | ||
- The user can disable Background App Refresh for your app from their Settings | ||
@@ -151,2 +159,12 @@ (use `statusAsync()` to check for this). | ||
## Debugging | ||
### Android | ||
```bash | ||
$ adb logcat *:S ReactNative:V ReactNativeJS:V BackgroundTask:V | ||
``` | ||
Keep in mind that after the app leaves the foreground, you'll have to wait at least 50% of the desired period (so, default is 7m30s) before the task executes. | ||
## Examples | ||
@@ -153,0 +171,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
24183
250
0