expo-background-fetch 10.1.1 → 10.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -1
- package/README.md +4 -4
- package/android/build.gradle +27 -9
- package/android/src/main/java/expo/modules/backgroundfetch/BackgroundFetchModule.java +1 -1
- package/android/src/main/java/expo/modules/backgroundfetch/BackgroundFetchTaskConsumer.java +5 -5
- package/build/BackgroundFetch.d.ts +2 -1
- package/build/BackgroundFetch.d.ts.map +1 -0
- package/build/BackgroundFetch.js +1 -1
- package/build/BackgroundFetch.js.map +1 -1
- package/build/BackgroundFetch.types.d.ts +8 -5
- package/build/BackgroundFetch.types.d.ts.map +1 -0
- package/build/BackgroundFetch.types.js.map +1 -1
- package/build/ExpoBackgroundFetch.d.ts +1 -0
- package/build/ExpoBackgroundFetch.d.ts.map +1 -0
- package/build/ExpoBackgroundFetch.web.d.ts +1 -0
- package/build/ExpoBackgroundFetch.web.d.ts.map +1 -0
- package/ios/EXBackgroundFetch/EXBackgroundFetch.m +4 -3
- package/ios/EXBackgroundFetch/EXBackgroundFetchTaskConsumer.h +3 -3
- package/ios/EXBackgroundFetch/EXBackgroundFetchTaskConsumer.m +4 -4
- package/ios/EXBackgroundFetch.podspec +0 -1
- package/package.json +4 -4
- package/src/BackgroundFetch.ts +1 -1
- package/src/BackgroundFetch.types.ts +7 -5
package/CHANGELOG.md
CHANGED
|
@@ -10,7 +10,17 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
-
## 10.
|
|
13
|
+
## 10.2.0 — 2022-04-18
|
|
14
|
+
|
|
15
|
+
### 💡 Others
|
|
16
|
+
|
|
17
|
+
- Updated `@expo/config-plugins` from `4.0.2` to `4.0.14` ([#15621](https://github.com/expo/expo/pull/15621) by [@EvanBacon](https://github.com/EvanBacon))
|
|
18
|
+
|
|
19
|
+
### ⚠️ Notices
|
|
20
|
+
|
|
21
|
+
- On Android bump `compileSdkVersion` to `31`, `targetSdkVersion` to `31` and `Java` version to `11`. ([#16941](https://github.com/expo/expo/pull/16941) by [@bbarthec](https://github.com/bbarthec))
|
|
22
|
+
|
|
23
|
+
## 10.1.1 - 2022-02-01
|
|
14
24
|
|
|
15
25
|
### 🐛 Bug fixes
|
|
16
26
|
|
package/README.md
CHANGED
|
@@ -4,12 +4,12 @@ Expo universal module for BackgroundFetch API
|
|
|
4
4
|
|
|
5
5
|
# API documentation
|
|
6
6
|
|
|
7
|
-
- [Documentation for the
|
|
8
|
-
- [Documentation for the latest stable release](https://docs.expo.
|
|
7
|
+
- [Documentation for the main branch](https://github.com/expo/expo/blob/main/docs/pages/versions/unversioned/sdk/background-fetch.md)
|
|
8
|
+
- [Documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/background-fetch/)
|
|
9
9
|
|
|
10
10
|
# Installation in managed Expo projects
|
|
11
11
|
|
|
12
|
-
For
|
|
12
|
+
For [managed](https://docs.expo.dev/versions/latest/introduction/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/background-fetch/).
|
|
13
13
|
|
|
14
14
|
# Installation in bare React Native projects
|
|
15
15
|
|
|
@@ -25,7 +25,7 @@ expo install expo-background-fetch
|
|
|
25
25
|
|
|
26
26
|
Run `npx pod-install` after installing the npm package.
|
|
27
27
|
|
|
28
|
-
In order to use `BackgroundFetch` API in standalone, detached and bare apps on iOS, your app has to include background mode in the `Info.plist` file. See [background tasks configuration guide](https://docs.expo.
|
|
28
|
+
In order to use `BackgroundFetch` API in standalone, detached and bare apps on iOS, your app has to include background mode in the `Info.plist` file. See [background tasks configuration guide](https://docs.expo.dev/versions/latest/sdk/task-manager/#configuration-for-standalone-apps) for more details.
|
|
29
29
|
|
|
30
30
|
### Configure for Android
|
|
31
31
|
|
package/android/build.gradle
CHANGED
|
@@ -3,20 +3,35 @@ apply plugin: 'kotlin-android'
|
|
|
3
3
|
apply plugin: 'maven-publish'
|
|
4
4
|
|
|
5
5
|
group = 'host.exp.exponent'
|
|
6
|
-
version = '10.
|
|
6
|
+
version = '10.2.0'
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
9
|
+
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
10
|
+
if (expoModulesCorePlugin.exists()) {
|
|
11
|
+
apply from: expoModulesCorePlugin
|
|
12
|
+
applyKotlinExpoModulesCorePlugin()
|
|
13
|
+
}
|
|
14
|
+
|
|
9
15
|
// Simple helper that allows the root project to override versions declared by this library.
|
|
10
16
|
ext.safeExtGet = { prop, fallback ->
|
|
11
17
|
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
12
18
|
}
|
|
13
19
|
|
|
20
|
+
// Ensures backward compatibility
|
|
21
|
+
ext.getKotlinVersion = {
|
|
22
|
+
if (ext.has("kotlinVersion")) {
|
|
23
|
+
ext.kotlinVersion()
|
|
24
|
+
} else {
|
|
25
|
+
ext.safeExtGet("kotlinVersion", "1.6.10")
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
14
29
|
repositories {
|
|
15
30
|
mavenCentral()
|
|
16
31
|
}
|
|
17
32
|
|
|
18
33
|
dependencies {
|
|
19
|
-
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${
|
|
34
|
+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${getKotlinVersion()}")
|
|
20
35
|
}
|
|
21
36
|
}
|
|
22
37
|
|
|
@@ -44,18 +59,22 @@ afterEvaluate {
|
|
|
44
59
|
}
|
|
45
60
|
|
|
46
61
|
android {
|
|
47
|
-
compileSdkVersion safeExtGet("compileSdkVersion",
|
|
62
|
+
compileSdkVersion safeExtGet("compileSdkVersion", 31)
|
|
48
63
|
|
|
49
64
|
compileOptions {
|
|
50
|
-
sourceCompatibility JavaVersion.
|
|
51
|
-
targetCompatibility JavaVersion.
|
|
65
|
+
sourceCompatibility JavaVersion.VERSION_11
|
|
66
|
+
targetCompatibility JavaVersion.VERSION_11
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
kotlinOptions {
|
|
70
|
+
jvmTarget = JavaVersion.VERSION_11.majorVersion
|
|
52
71
|
}
|
|
53
72
|
|
|
54
73
|
defaultConfig {
|
|
55
74
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
56
|
-
targetSdkVersion safeExtGet("targetSdkVersion",
|
|
75
|
+
targetSdkVersion safeExtGet("targetSdkVersion", 31)
|
|
57
76
|
versionCode 23
|
|
58
|
-
versionName "10.
|
|
77
|
+
versionName "10.2.0"
|
|
59
78
|
}
|
|
60
79
|
lintOptions {
|
|
61
80
|
abortOnError false
|
|
@@ -64,7 +83,6 @@ android {
|
|
|
64
83
|
|
|
65
84
|
dependencies {
|
|
66
85
|
implementation project(':expo-modules-core')
|
|
67
|
-
implementation project(':unimodules-task-manager-interface')
|
|
68
86
|
|
|
69
|
-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${
|
|
87
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
|
|
70
88
|
}
|
|
@@ -8,7 +8,7 @@ import expo.modules.core.ExportedModule;
|
|
|
8
8
|
import expo.modules.core.ModuleRegistry;
|
|
9
9
|
import expo.modules.core.Promise;
|
|
10
10
|
import expo.modules.core.interfaces.ExpoMethod;
|
|
11
|
-
import
|
|
11
|
+
import expo.modules.interfaces.taskManager.TaskManagerInterface;
|
|
12
12
|
|
|
13
13
|
class BackgroundFetchModule extends ExportedModule {
|
|
14
14
|
private TaskManagerInterface mTaskManager;
|
|
@@ -10,11 +10,11 @@ import android.os.SystemClock;
|
|
|
10
10
|
import android.util.Log;
|
|
11
11
|
|
|
12
12
|
import expo.modules.core.interfaces.LifecycleEventListener;
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
13
|
+
import expo.modules.interfaces.taskManager.TaskConsumer;
|
|
14
|
+
import expo.modules.interfaces.taskManager.TaskConsumerInterface;
|
|
15
|
+
import expo.modules.interfaces.taskManager.TaskExecutionCallback;
|
|
16
|
+
import expo.modules.interfaces.taskManager.TaskInterface;
|
|
17
|
+
import expo.modules.interfaces.taskManager.TaskManagerUtilsInterface;
|
|
18
18
|
|
|
19
19
|
import java.util.Map;
|
|
20
20
|
|
|
@@ -30,7 +30,7 @@ export declare function setMinimumIntervalAsync(minimumInterval: number): Promis
|
|
|
30
30
|
* TaskManager.defineTask(YOUR_TASK_NAME, () => {
|
|
31
31
|
* try {
|
|
32
32
|
* const receivedNewData = // do your background fetch here
|
|
33
|
-
* return receivedNewData ? BackgroundFetch.
|
|
33
|
+
* return receivedNewData ? BackgroundFetch.BackgroundFetchResult.NewData : BackgroundFetch.BackgroundFetchResult.NoData;
|
|
34
34
|
* } catch (error) {
|
|
35
35
|
* return BackgroundFetch.Result.Failed;
|
|
36
36
|
* }
|
|
@@ -45,3 +45,4 @@ export declare function registerTaskAsync(taskName: string, options?: Background
|
|
|
45
45
|
*/
|
|
46
46
|
export declare function unregisterTaskAsync(taskName: string): Promise<void>;
|
|
47
47
|
export { BackgroundFetchResult, BackgroundFetchStatus, BackgroundFetchOptions };
|
|
48
|
+
//# sourceMappingURL=BackgroundFetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BackgroundFetch.d.ts","sourceRoot":"","sources":["../src/BackgroundFetch.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,yBAAyB,CAAC;AAIjC;;;GAGG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC,CAK5E;AAGD;;;;;;;;;;GAUG;AACH,wBAAsB,uBAAuB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMpF;AAGD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,IAAI,CAAC,CAUf;AAGD;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAKzE;AAED,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,CAAC"}
|
package/build/BackgroundFetch.js
CHANGED
|
@@ -47,7 +47,7 @@ export async function setMinimumIntervalAsync(minimumInterval) {
|
|
|
47
47
|
* TaskManager.defineTask(YOUR_TASK_NAME, () => {
|
|
48
48
|
* try {
|
|
49
49
|
* const receivedNewData = // do your background fetch here
|
|
50
|
-
* return receivedNewData ? BackgroundFetch.
|
|
50
|
+
* return receivedNewData ? BackgroundFetch.BackgroundFetchResult.NewData : BackgroundFetch.BackgroundFetchResult.NoData;
|
|
51
51
|
* } catch (error) {
|
|
52
52
|
* return BackgroundFetch.Result.Failed;
|
|
53
53
|
* }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackgroundFetch.js","sourceRoot":"","sources":["../src/BackgroundFetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAEL,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AAExD,cAAc;AACd;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc;IAClC,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE;QAC7B,OAAO,qBAAqB,CAAC,SAAS,CAAC;KACxC;IACD,OAAO,mBAAmB,CAAC,cAAc,EAAE,CAAC;AAC9C,CAAC;AAED,cAAc;AACd;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,eAAuB;IACnE,IAAI,CAAC,mBAAmB,CAAC,uBAAuB,EAAE;QAChD,OAAO;KACR;IACD,WAAW;IACX,MAAM,mBAAmB,CAAC,uBAAuB,CAAC,eAAe,CAAC,CAAC;AACrE,CAAC;AAED,cAAc;AACd;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,QAAgB,EAChB,UAAkC,EAAE;IAEpC,IAAI,CAAC,mBAAmB,CAAC,iBAAiB,EAAE;QAC1C,MAAM,IAAI,mBAAmB,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,CAAC;KACvE;IACD,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE;QACxC,MAAM,IAAI,KAAK,CACb,SAAS,QAAQ,2FAA2F,CAC7G,CAAC;KACH;IACD,MAAM,mBAAmB,CAAC,iBAAiB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AACjE,CAAC;AAED,cAAc;AACd;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,QAAgB;IACxD,IAAI,CAAC,mBAAmB,CAAC,mBAAmB,EAAE;QAC5C,MAAM,IAAI,mBAAmB,CAAC,iBAAiB,EAAE,qBAAqB,CAAC,CAAC;KACzE;IACD,MAAM,mBAAmB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AAC1D,CAAC;AAED,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAA0B,CAAC","sourcesContent":["import { Platform, UnavailabilityError } from 'expo-modules-core';\nimport * as TaskManager from 'expo-task-manager';\n\nimport {\n BackgroundFetchOptions,\n BackgroundFetchResult,\n BackgroundFetchStatus,\n} from './BackgroundFetch.types';\nimport ExpoBackgroundFetch from './ExpoBackgroundFetch';\n\n// @needsAudit\n/**\n * Gets a status of background fetch.\n * @return Returns a promise which fulfils with one of `BackgroundFetchStatus` enum values.\n */\nexport async function getStatusAsync(): Promise<BackgroundFetchStatus | null> {\n if (Platform.OS === 'android') {\n return BackgroundFetchStatus.Available;\n }\n return ExpoBackgroundFetch.getStatusAsync();\n}\n\n// @needsAudit\n/**\n * Sets the minimum number of seconds that must elapse before another background fetch can be\n * initiated. This value is advisory only and does not indicate the exact amount of time expected\n * between fetch operations.\n *\n * > This method doesn't take any effect on Android. It is a global value which means that it can\n * overwrite settings from another application opened through Expo Go.\n *\n * @param minimumInterval Number of seconds that must elapse before another background fetch can be called.\n * @return A promise which fulfils once the minimum interval is set.\n */\nexport async function setMinimumIntervalAsync(minimumInterval: number): Promise<void> {\n if (!ExpoBackgroundFetch.setMinimumIntervalAsync) {\n return;\n }\n // iOS only\n await ExpoBackgroundFetch.setMinimumIntervalAsync(minimumInterval);\n}\n\n// @needsAudit\n/**\n * Registers background fetch task with given name. Registered tasks are saved in persistent storage and restored once the app is initialized.\n * @param taskName Name of the task to register. The task needs to be defined first - see [`TaskManager.defineTask`](taskmanager#defineTask)\n * for more details.\n * @param options An object containing the background fetch options.\n *\n * @example\n * ```ts\n * import * as BackgroundFetch from 'expo-background-fetch';\n * import * as TaskManager from 'expo-task-manager';\n *\n * TaskManager.defineTask(YOUR_TASK_NAME, () => {\n * try {\n * const receivedNewData = // do your background fetch here\n * return receivedNewData ? BackgroundFetch.
|
|
1
|
+
{"version":3,"file":"BackgroundFetch.js","sourceRoot":"","sources":["../src/BackgroundFetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAEL,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AAExD,cAAc;AACd;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc;IAClC,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE;QAC7B,OAAO,qBAAqB,CAAC,SAAS,CAAC;KACxC;IACD,OAAO,mBAAmB,CAAC,cAAc,EAAE,CAAC;AAC9C,CAAC;AAED,cAAc;AACd;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,eAAuB;IACnE,IAAI,CAAC,mBAAmB,CAAC,uBAAuB,EAAE;QAChD,OAAO;KACR;IACD,WAAW;IACX,MAAM,mBAAmB,CAAC,uBAAuB,CAAC,eAAe,CAAC,CAAC;AACrE,CAAC;AAED,cAAc;AACd;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,QAAgB,EAChB,UAAkC,EAAE;IAEpC,IAAI,CAAC,mBAAmB,CAAC,iBAAiB,EAAE;QAC1C,MAAM,IAAI,mBAAmB,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,CAAC;KACvE;IACD,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE;QACxC,MAAM,IAAI,KAAK,CACb,SAAS,QAAQ,2FAA2F,CAC7G,CAAC;KACH;IACD,MAAM,mBAAmB,CAAC,iBAAiB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AACjE,CAAC;AAED,cAAc;AACd;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,QAAgB;IACxD,IAAI,CAAC,mBAAmB,CAAC,mBAAmB,EAAE;QAC5C,MAAM,IAAI,mBAAmB,CAAC,iBAAiB,EAAE,qBAAqB,CAAC,CAAC;KACzE;IACD,MAAM,mBAAmB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AAC1D,CAAC;AAED,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAA0B,CAAC","sourcesContent":["import { Platform, UnavailabilityError } from 'expo-modules-core';\nimport * as TaskManager from 'expo-task-manager';\n\nimport {\n BackgroundFetchOptions,\n BackgroundFetchResult,\n BackgroundFetchStatus,\n} from './BackgroundFetch.types';\nimport ExpoBackgroundFetch from './ExpoBackgroundFetch';\n\n// @needsAudit\n/**\n * Gets a status of background fetch.\n * @return Returns a promise which fulfils with one of `BackgroundFetchStatus` enum values.\n */\nexport async function getStatusAsync(): Promise<BackgroundFetchStatus | null> {\n if (Platform.OS === 'android') {\n return BackgroundFetchStatus.Available;\n }\n return ExpoBackgroundFetch.getStatusAsync();\n}\n\n// @needsAudit\n/**\n * Sets the minimum number of seconds that must elapse before another background fetch can be\n * initiated. This value is advisory only and does not indicate the exact amount of time expected\n * between fetch operations.\n *\n * > This method doesn't take any effect on Android. It is a global value which means that it can\n * overwrite settings from another application opened through Expo Go.\n *\n * @param minimumInterval Number of seconds that must elapse before another background fetch can be called.\n * @return A promise which fulfils once the minimum interval is set.\n */\nexport async function setMinimumIntervalAsync(minimumInterval: number): Promise<void> {\n if (!ExpoBackgroundFetch.setMinimumIntervalAsync) {\n return;\n }\n // iOS only\n await ExpoBackgroundFetch.setMinimumIntervalAsync(minimumInterval);\n}\n\n// @needsAudit\n/**\n * Registers background fetch task with given name. Registered tasks are saved in persistent storage and restored once the app is initialized.\n * @param taskName Name of the task to register. The task needs to be defined first - see [`TaskManager.defineTask`](taskmanager#defineTask)\n * for more details.\n * @param options An object containing the background fetch options.\n *\n * @example\n * ```ts\n * import * as BackgroundFetch from 'expo-background-fetch';\n * import * as TaskManager from 'expo-task-manager';\n *\n * TaskManager.defineTask(YOUR_TASK_NAME, () => {\n * try {\n * const receivedNewData = // do your background fetch here\n * return receivedNewData ? BackgroundFetch.BackgroundFetchResult.NewData : BackgroundFetch.BackgroundFetchResult.NoData;\n * } catch (error) {\n * return BackgroundFetch.Result.Failed;\n * }\n * });\n * ```\n */\nexport async function registerTaskAsync(\n taskName: string,\n options: BackgroundFetchOptions = {}\n): Promise<void> {\n if (!ExpoBackgroundFetch.registerTaskAsync) {\n throw new UnavailabilityError('BackgroundFetch', 'registerTaskAsync');\n }\n if (!TaskManager.isTaskDefined(taskName)) {\n throw new Error(\n `Task '${taskName}' is not defined. You must define a task using TaskManager.defineTask before registering.`\n );\n }\n await ExpoBackgroundFetch.registerTaskAsync(taskName, options);\n}\n\n// @needsAudit\n/**\n * Unregisters background fetch task, so the application will no longer be executing this task.\n * @param taskName Name of the task to unregister.\n * @return A promise which fulfils when the task is fully unregistered.\n */\nexport async function unregisterTaskAsync(taskName: string): Promise<void> {\n if (!ExpoBackgroundFetch.unregisterTaskAsync) {\n throw new UnavailabilityError('BackgroundFetch', 'unregisterTaskAsync');\n }\n await ExpoBackgroundFetch.unregisterTaskAsync(taskName);\n}\n\nexport { BackgroundFetchResult, BackgroundFetchStatus, BackgroundFetchOptions };\n"]}
|
|
@@ -39,20 +39,23 @@ export interface BackgroundFetchOptions {
|
|
|
39
39
|
* interval may differ from the specified one to minimize wakeups and battery usage.
|
|
40
40
|
* - On Android it defaults to __10 minutes__,
|
|
41
41
|
* - On iOS it calls [`BackgroundFetch.setMinimumIntervalAsync`](#backgroundfetchsetminimumintervalasyncminimuminterval)
|
|
42
|
-
*
|
|
42
|
+
* behind the scenes and the default value is the smallest fetch interval supported by the system __(10-15 minutes)__.
|
|
43
43
|
* Background fetch task receives no data, but your task should return a value that best describes
|
|
44
44
|
* the results of your background fetch work.
|
|
45
45
|
* @return Returns a promise that fulfils once the task is registered and rejects in case of any errors.
|
|
46
46
|
*/
|
|
47
47
|
minimumInterval?: number;
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
49
|
+
* Whether to stop receiving background fetch events after user terminates the app.
|
|
50
|
+
* @default true
|
|
51
|
+
* @platform android
|
|
51
52
|
*/
|
|
52
53
|
stopOnTerminate?: boolean;
|
|
53
54
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
55
|
+
* Whether to restart background fetch events when the device has finished booting.
|
|
56
|
+
* @default false
|
|
57
|
+
* @platform android
|
|
56
58
|
*/
|
|
57
59
|
startOnBoot?: boolean;
|
|
58
60
|
}
|
|
61
|
+
//# sourceMappingURL=BackgroundFetch.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BackgroundFetch.types.d.ts","sourceRoot":"","sources":["../src/BackgroundFetch.types.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AACH,oBAAY,qBAAqB;IAC/B;;OAEG;IACH,MAAM,IAAI;IACV;;OAEG;IACH,OAAO,IAAI;IACX;;OAEG;IACH,MAAM,IAAI;CACX;AAGD,oBAAY,qBAAqB;IAC/B;;OAEG;IACH,MAAM,IAAI;IACV;;;OAGG;IACH,UAAU,IAAI;IACd;;OAEG;IACH,SAAS,IAAI;CACd;AAGD,MAAM,WAAW,sBAAsB;IACrC;;;;;;;;;OASG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackgroundFetch.types.js","sourceRoot":"","sources":["../src/BackgroundFetch.types.ts"],"names":[],"mappings":"AAAA,cAAc;AACd;;;;;GAKG;AACH,MAAM,CAAN,IAAY,qBAaX;AAbD,WAAY,qBAAqB;IAC/B;;OAEG;IACH,qEAAU,CAAA;IACV;;OAEG;IACH,uEAAW,CAAA;IACX;;OAEG;IACH,qEAAU,CAAA;AACZ,CAAC,EAbW,qBAAqB,KAArB,qBAAqB,QAahC;AAED,cAAc;AACd,MAAM,CAAN,IAAY,qBAcX;AAdD,WAAY,qBAAqB;IAC/B;;OAEG;IACH,qEAAU,CAAA;IACV;;;OAGG;IACH,6EAAc,CAAA;IACd;;OAEG;IACH,2EAAa,CAAA;AACf,CAAC,EAdW,qBAAqB,KAArB,qBAAqB,QAchC","sourcesContent":["// @needsAudit\n/**\n * This return value is to let iOS know what the result of your background fetch was, so the\n * platform can better schedule future background fetches. Also, your app has up to 30 seconds\n * to perform the task, otherwise your app will be terminated and future background fetches\n * may be delayed.\n */\nexport enum BackgroundFetchResult {\n /**\n * There was no new data to download.\n */\n NoData = 1,\n /**\n * New data was successfully downloaded.\n */\n NewData = 2,\n /**\n * An attempt to download data was made but that attempt failed.\n */\n Failed = 3,\n}\n\n// @needsAudit\nexport enum BackgroundFetchStatus {\n /**\n * The user explicitly disabled background behavior for this app or for the whole system.\n */\n Denied = 1,\n /**\n * Background updates are unavailable and the user cannot enable them again. This status can occur\n * when, for example, parental controls are in effect for the current user.\n */\n Restricted = 2,\n /**\n * Background updates are available for the app.\n */\n Available = 3,\n}\n\n// @needsAudit\nexport interface BackgroundFetchOptions {\n /**\n * Inexact interval in seconds between subsequent repeats of the background fetch alarm. The final\n * interval may differ from the specified one to minimize wakeups and battery usage.\n * - On Android it defaults to __10 minutes__,\n * - On iOS it calls [`BackgroundFetch.setMinimumIntervalAsync`](#backgroundfetchsetminimumintervalasyncminimuminterval)\n *
|
|
1
|
+
{"version":3,"file":"BackgroundFetch.types.js","sourceRoot":"","sources":["../src/BackgroundFetch.types.ts"],"names":[],"mappings":"AAAA,cAAc;AACd;;;;;GAKG;AACH,MAAM,CAAN,IAAY,qBAaX;AAbD,WAAY,qBAAqB;IAC/B;;OAEG;IACH,qEAAU,CAAA;IACV;;OAEG;IACH,uEAAW,CAAA;IACX;;OAEG;IACH,qEAAU,CAAA;AACZ,CAAC,EAbW,qBAAqB,KAArB,qBAAqB,QAahC;AAED,cAAc;AACd,MAAM,CAAN,IAAY,qBAcX;AAdD,WAAY,qBAAqB;IAC/B;;OAEG;IACH,qEAAU,CAAA;IACV;;;OAGG;IACH,6EAAc,CAAA;IACd;;OAEG;IACH,2EAAa,CAAA;AACf,CAAC,EAdW,qBAAqB,KAArB,qBAAqB,QAchC","sourcesContent":["// @needsAudit\n/**\n * This return value is to let iOS know what the result of your background fetch was, so the\n * platform can better schedule future background fetches. Also, your app has up to 30 seconds\n * to perform the task, otherwise your app will be terminated and future background fetches\n * may be delayed.\n */\nexport enum BackgroundFetchResult {\n /**\n * There was no new data to download.\n */\n NoData = 1,\n /**\n * New data was successfully downloaded.\n */\n NewData = 2,\n /**\n * An attempt to download data was made but that attempt failed.\n */\n Failed = 3,\n}\n\n// @needsAudit\nexport enum BackgroundFetchStatus {\n /**\n * The user explicitly disabled background behavior for this app or for the whole system.\n */\n Denied = 1,\n /**\n * Background updates are unavailable and the user cannot enable them again. This status can occur\n * when, for example, parental controls are in effect for the current user.\n */\n Restricted = 2,\n /**\n * Background updates are available for the app.\n */\n Available = 3,\n}\n\n// @needsAudit\nexport interface BackgroundFetchOptions {\n /**\n * Inexact interval in seconds between subsequent repeats of the background fetch alarm. The final\n * interval may differ from the specified one to minimize wakeups and battery usage.\n * - On Android it defaults to __10 minutes__,\n * - On iOS it calls [`BackgroundFetch.setMinimumIntervalAsync`](#backgroundfetchsetminimumintervalasyncminimuminterval)\n * behind the scenes and the default value is the smallest fetch interval supported by the system __(10-15 minutes)__.\n * Background fetch task receives no data, but your task should return a value that best describes\n * the results of your background fetch work.\n * @return Returns a promise that fulfils once the task is registered and rejects in case of any errors.\n */\n minimumInterval?: number;\n /**\n * Whether to stop receiving background fetch events after user terminates the app.\n * @default true\n * @platform android\n */\n stopOnTerminate?: boolean;\n /**\n * Whether to restart background fetch events when the device has finished booting.\n * @default false\n * @platform android\n */\n startOnBoot?: boolean;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoBackgroundFetch.d.ts","sourceRoot":"","sources":["../src/ExpoBackgroundFetch.ts"],"names":[],"mappings":";AAEA,wBAAsD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoBackgroundFetch.web.d.ts","sourceRoot":"","sources":["../src/ExpoBackgroundFetch.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;;;sBAMtC,QAAQ,qBAAqB,GAAG,IAAI,CAAC;;AAJ/D,wBAOE"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
// Copyright 2018-present 650 Industries. All rights reserved.
|
|
2
2
|
|
|
3
3
|
#import <ExpoModulesCore/EXDefines.h>
|
|
4
|
+
#import <ExpoModulesCore/EXTaskManagerInterface.h>
|
|
5
|
+
|
|
4
6
|
#import <EXBackgroundFetch/EXBackgroundFetch.h>
|
|
5
7
|
#import <EXBackgroundFetch/EXBackgroundFetchTaskConsumer.h>
|
|
6
|
-
#import <UMTaskManagerInterface/UMTaskManagerInterface.h>
|
|
7
8
|
|
|
8
9
|
@interface EXBackgroundFetch ()
|
|
9
10
|
|
|
10
|
-
@property (nonatomic, weak) id<
|
|
11
|
+
@property (nonatomic, weak) id<EXTaskManagerInterface> taskManager;
|
|
11
12
|
|
|
12
13
|
@end
|
|
13
14
|
|
|
@@ -17,7 +18,7 @@ EX_EXPORT_MODULE(ExpoBackgroundFetch);
|
|
|
17
18
|
|
|
18
19
|
- (void)setModuleRegistry:(EXModuleRegistry *)moduleRegistry
|
|
19
20
|
{
|
|
20
|
-
_taskManager = [moduleRegistry getModuleImplementingProtocol:@protocol(
|
|
21
|
+
_taskManager = [moduleRegistry getModuleImplementingProtocol:@protocol(EXTaskManagerInterface)];
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
EX_EXPORT_METHOD_AS(getStatusAsync,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// Copyright 2018-present 650 Industries. All rights reserved.
|
|
2
2
|
|
|
3
3
|
#import <Foundation/Foundation.h>
|
|
4
|
-
#import <
|
|
4
|
+
#import <ExpoModulesCore/EXTaskConsumerInterface.h>
|
|
5
5
|
|
|
6
6
|
NS_ASSUME_NONNULL_BEGIN
|
|
7
7
|
|
|
8
|
-
@interface EXBackgroundFetchTaskConsumer : NSObject <
|
|
8
|
+
@interface EXBackgroundFetchTaskConsumer : NSObject <EXTaskConsumerInterface>
|
|
9
9
|
|
|
10
|
-
@property (nonatomic, strong) id<
|
|
10
|
+
@property (nonatomic, strong) id<EXTaskInterface> task;
|
|
11
11
|
|
|
12
12
|
@end
|
|
13
13
|
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
#import <EXBackgroundFetch/EXBackgroundFetch.h>
|
|
4
4
|
#import <EXBackgroundFetch/EXBackgroundFetchTaskConsumer.h>
|
|
5
|
-
#import <
|
|
5
|
+
#import <ExpoModulesCore/EXTaskInterface.h>
|
|
6
6
|
|
|
7
7
|
@implementation EXBackgroundFetchTaskConsumer
|
|
8
8
|
|
|
9
|
-
+ (BOOL)supportsLaunchReason:(
|
|
9
|
+
+ (BOOL)supportsLaunchReason:(EXTaskLaunchReason)launchReason
|
|
10
10
|
{
|
|
11
|
-
return launchReason ==
|
|
11
|
+
return launchReason == EXTaskLaunchReasonBackgroundFetch;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
- (NSString *)taskType
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
// Associating task to the consumer.
|
|
20
|
-
- (void)didRegisterTask:(id<
|
|
20
|
+
- (void)didRegisterTask:(id<EXTaskInterface>)task
|
|
21
21
|
{
|
|
22
22
|
_task = task;
|
|
23
23
|
[self updateMinimumInterval];
|
|
@@ -15,7 +15,6 @@ Pod::Spec.new do |s|
|
|
|
15
15
|
s.static_framework = true
|
|
16
16
|
|
|
17
17
|
s.dependency 'ExpoModulesCore'
|
|
18
|
-
s.dependency 'UMTaskManagerInterface'
|
|
19
18
|
|
|
20
19
|
if !$ExpoUseSources&.include?(package['name']) && ENV['EXPO_USE_SOURCE'].to_i == 0 && File.exist?("#{s.name}.xcframework") && Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.10.0')
|
|
21
20
|
s.source_files = "#{s.name}/**/*.h"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-background-fetch",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.2.0",
|
|
4
4
|
"description": "Expo universal module for BackgroundFetch API",
|
|
5
5
|
"main": "build/BackgroundFetch.js",
|
|
6
6
|
"types": "build/BackgroundFetch.d.ts",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"homepage": "https://docs.expo.dev/versions/latest/sdk/background-fetch/",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@expo/config-plugins": "^4.0.
|
|
37
|
-
"expo-task-manager": "~10.
|
|
36
|
+
"@expo/config-plugins": "^4.0.14",
|
|
37
|
+
"expo-task-manager": "~10.2.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"expo-module-scripts": "^2.0.0"
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"expo": "*"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "89a27c0ca0ca8becd7546697298e874a15e94faf"
|
|
46
46
|
}
|
package/src/BackgroundFetch.ts
CHANGED
|
@@ -55,7 +55,7 @@ export async function setMinimumIntervalAsync(minimumInterval: number): Promise<
|
|
|
55
55
|
* TaskManager.defineTask(YOUR_TASK_NAME, () => {
|
|
56
56
|
* try {
|
|
57
57
|
* const receivedNewData = // do your background fetch here
|
|
58
|
-
* return receivedNewData ? BackgroundFetch.
|
|
58
|
+
* return receivedNewData ? BackgroundFetch.BackgroundFetchResult.NewData : BackgroundFetch.BackgroundFetchResult.NoData;
|
|
59
59
|
* } catch (error) {
|
|
60
60
|
* return BackgroundFetch.Result.Failed;
|
|
61
61
|
* }
|
|
@@ -44,20 +44,22 @@ export interface BackgroundFetchOptions {
|
|
|
44
44
|
* interval may differ from the specified one to minimize wakeups and battery usage.
|
|
45
45
|
* - On Android it defaults to __10 minutes__,
|
|
46
46
|
* - On iOS it calls [`BackgroundFetch.setMinimumIntervalAsync`](#backgroundfetchsetminimumintervalasyncminimuminterval)
|
|
47
|
-
*
|
|
47
|
+
* behind the scenes and the default value is the smallest fetch interval supported by the system __(10-15 minutes)__.
|
|
48
48
|
* Background fetch task receives no data, but your task should return a value that best describes
|
|
49
49
|
* the results of your background fetch work.
|
|
50
50
|
* @return Returns a promise that fulfils once the task is registered and rejects in case of any errors.
|
|
51
51
|
*/
|
|
52
52
|
minimumInterval?: number;
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
54
|
+
* Whether to stop receiving background fetch events after user terminates the app.
|
|
55
|
+
* @default true
|
|
56
|
+
* @platform android
|
|
56
57
|
*/
|
|
57
58
|
stopOnTerminate?: boolean;
|
|
58
59
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
60
|
+
* Whether to restart background fetch events when the device has finished booting.
|
|
61
|
+
* @default false
|
|
62
|
+
* @platform android
|
|
61
63
|
*/
|
|
62
64
|
startOnBoot?: boolean;
|
|
63
65
|
}
|