expo-background-task 0.2.1 → 0.2.3

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/android/build.gradle +2 -2
  3. package/build/BackgroundTask.d.ts.map +1 -1
  4. package/build/BackgroundTask.js +20 -1
  5. package/build/BackgroundTask.js.map +1 -1
  6. package/build/ExpoBackgroundTaskModule.web.d.ts.map +1 -1
  7. package/expo-module.config.json +1 -1
  8. package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/{0.2.1/expo.modules.backgroundtask-0.2.1.module → 0.2.3/expo.modules.backgroundtask-0.2.3.module} +7 -7
  9. package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/0.2.3/expo.modules.backgroundtask-0.2.3.module.md5 +1 -0
  10. package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/0.2.3/expo.modules.backgroundtask-0.2.3.module.sha1 +1 -0
  11. package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/0.2.3/expo.modules.backgroundtask-0.2.3.module.sha256 +1 -0
  12. package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/0.2.3/expo.modules.backgroundtask-0.2.3.module.sha512 +1 -0
  13. package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/{0.2.1/expo.modules.backgroundtask-0.2.1.pom → 0.2.3/expo.modules.backgroundtask-0.2.3.pom} +1 -1
  14. package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/0.2.3/expo.modules.backgroundtask-0.2.3.pom.md5 +1 -0
  15. package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/0.2.3/expo.modules.backgroundtask-0.2.3.pom.sha1 +1 -0
  16. package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/0.2.3/expo.modules.backgroundtask-0.2.3.pom.sha256 +1 -0
  17. package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/0.2.3/expo.modules.backgroundtask-0.2.3.pom.sha512 +1 -0
  18. package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/maven-metadata.xml +4 -4
  19. package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/maven-metadata.xml.md5 +1 -1
  20. package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/maven-metadata.xml.sha1 +1 -1
  21. package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/maven-metadata.xml.sha256 +1 -1
  22. package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/maven-metadata.xml.sha512 +1 -1
  23. package/package.json +4 -4
  24. package/src/BackgroundTask.ts +24 -1
  25. package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/0.2.1/expo.modules.backgroundtask-0.2.1.module.md5 +0 -1
  26. package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/0.2.1/expo.modules.backgroundtask-0.2.1.module.sha1 +0 -1
  27. package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/0.2.1/expo.modules.backgroundtask-0.2.1.module.sha256 +0 -1
  28. package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/0.2.1/expo.modules.backgroundtask-0.2.1.module.sha512 +0 -1
  29. package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/0.2.1/expo.modules.backgroundtask-0.2.1.pom.md5 +0 -1
  30. package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/0.2.1/expo.modules.backgroundtask-0.2.1.pom.sha1 +0 -1
  31. package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/0.2.1/expo.modules.backgroundtask-0.2.1.pom.sha256 +0 -1
  32. package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/0.2.1/expo.modules.backgroundtask-0.2.1.pom.sha512 +0 -1
  33. /package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/{0.2.1/expo.modules.backgroundtask-0.2.1-sources.jar → 0.2.3/expo.modules.backgroundtask-0.2.3-sources.jar} +0 -0
  34. /package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/{0.2.1/expo.modules.backgroundtask-0.2.1-sources.jar.md5 → 0.2.3/expo.modules.backgroundtask-0.2.3-sources.jar.md5} +0 -0
  35. /package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/{0.2.1/expo.modules.backgroundtask-0.2.1-sources.jar.sha1 → 0.2.3/expo.modules.backgroundtask-0.2.3-sources.jar.sha1} +0 -0
  36. /package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/{0.2.1/expo.modules.backgroundtask-0.2.1-sources.jar.sha256 → 0.2.3/expo.modules.backgroundtask-0.2.3-sources.jar.sha256} +0 -0
  37. /package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/{0.2.1/expo.modules.backgroundtask-0.2.1-sources.jar.sha512 → 0.2.3/expo.modules.backgroundtask-0.2.3-sources.jar.sha512} +0 -0
  38. /package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/{0.2.1/expo.modules.backgroundtask-0.2.1.aar → 0.2.3/expo.modules.backgroundtask-0.2.3.aar} +0 -0
  39. /package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/{0.2.1/expo.modules.backgroundtask-0.2.1.aar.md5 → 0.2.3/expo.modules.backgroundtask-0.2.3.aar.md5} +0 -0
  40. /package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/{0.2.1/expo.modules.backgroundtask-0.2.1.aar.sha1 → 0.2.3/expo.modules.backgroundtask-0.2.3.aar.sha1} +0 -0
  41. /package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/{0.2.1/expo.modules.backgroundtask-0.2.1.aar.sha256 → 0.2.3/expo.modules.backgroundtask-0.2.3.aar.sha256} +0 -0
  42. /package/local-maven-repo/host/exp/exponent/expo.modules.backgroundtask/{0.2.1/expo.modules.backgroundtask-0.2.1.aar.sha512 → 0.2.3/expo.modules.backgroundtask-0.2.3.aar.sha512} +0 -0
package/CHANGELOG.md CHANGED
@@ -10,6 +10,16 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 0.2.3 — 2025-04-11
14
+
15
+ ### 💡 Others
16
+
17
+ - Added warning about Background Tasks not being supported in Expo Go ([#36063](https://github.com/expo/expo/pull/36063) by [@chrfalch](https://github.com/chrfalch))
18
+
19
+ ## 0.2.2 — 2025-04-09
20
+
21
+ _This version does not introduce any user-facing changes._
22
+
13
23
  ## 0.2.1 — 2025-04-08
14
24
 
15
25
  ### 🐛 Bug fixes
@@ -4,7 +4,7 @@ plugins {
4
4
  }
5
5
 
6
6
  group = 'host.exp.exponent'
7
- version = '0.2.1'
7
+ version = '0.2.3'
8
8
 
9
9
  dependencies {
10
10
  implementation 'androidx.work:work-runtime-ktx:2.9.1'
@@ -15,7 +15,7 @@ android {
15
15
  namespace "expo.modules.backgroundtask"
16
16
  defaultConfig {
17
17
  versionCode 23
18
- versionName "0.2.1"
18
+ versionName "0.2.3"
19
19
  consumerProguardFiles("proguard-rules.pro")
20
20
  }
21
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"BackgroundTask.d.ts","sourceRoot":"","sources":["../src/BackgroundTask.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAOrF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,QAAa,QAAQ,oBAAoB,CAMnE,CAAC;AAGF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,IAAI,CAAC,CAwBf;AAGD;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAQzE;AAGD;;;;;GAKG;AAcH,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"BackgroundTask.d.ts","sourceRoot":"","sources":["../src/BackgroundTask.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAwBrF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,QAAa,OAAO,CAAC,oBAAoB,CAQnE,CAAC;AAGF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,IAAI,CAAC,CAyBf;AAGD;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAUzE;AAGD;;;;;GAKG;AAcH,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,wBAAwB,CAAC"}
@@ -1,9 +1,24 @@
1
+ import { isRunningInExpoGo } from 'expo';
1
2
  import { Platform, UnavailabilityError } from 'expo-modules-core';
2
3
  import * as TaskManager from 'expo-task-manager';
3
4
  import { BackgroundTaskStatus } from './BackgroundTask.types';
4
5
  import ExpoBackgroundTaskModule from './ExpoBackgroundTaskModule';
5
6
  // Flag to warn about running on Apple simulator
6
7
  let warnAboutRunningOniOSSimulator = false;
8
+ let warnedAboutExpoGo = false;
9
+ function _validate(taskName) {
10
+ if (isRunningInExpoGo()) {
11
+ if (!warnedAboutExpoGo) {
12
+ const message = '`Background Task` functionality is not available in Expo Go:\n' +
13
+ 'Please use a development build to avoid limitations. Learn more: https://expo.fyi/dev-client.';
14
+ console.warn(message);
15
+ warnedAboutExpoGo = true;
16
+ }
17
+ }
18
+ if (!taskName || typeof taskName !== 'string') {
19
+ throw new TypeError('`taskName` must be a non-empty string.');
20
+ }
21
+ }
7
22
  // @needsAudit
8
23
  /**
9
24
  * Returns the status for the Background Task API. On web, it always returns `BackgroundTaskStatus.Restricted`,
@@ -15,7 +30,9 @@ export const getStatusAsync = async () => {
15
30
  if (!ExpoBackgroundTaskModule.getStatusAsync) {
16
31
  throw new UnavailabilityError('BackgroundTask', 'getStatusAsync');
17
32
  }
18
- return ExpoBackgroundTaskModule.getStatusAsync();
33
+ return isRunningInExpoGo()
34
+ ? BackgroundTaskStatus.Restricted
35
+ : ExpoBackgroundTaskModule.getStatusAsync();
19
36
  };
20
37
  // @needsAudit
21
38
  /**
@@ -66,6 +83,7 @@ export async function registerTaskAsync(taskName, options = {}) {
66
83
  }
67
84
  return;
68
85
  }
86
+ _validate(taskName);
69
87
  await ExpoBackgroundTaskModule.registerTaskAsync(taskName, options);
70
88
  }
71
89
  // @needsAudit
@@ -81,6 +99,7 @@ export async function unregisterTaskAsync(taskName) {
81
99
  if (!(await TaskManager.isTaskRegisteredAsync(taskName))) {
82
100
  throw new Error(`Task '${taskName}' is not registered.`);
83
101
  }
102
+ _validate(taskName);
84
103
  await ExpoBackgroundTaskModule.unregisterTaskAsync(taskName);
85
104
  }
86
105
  // @needsAudit
@@ -1 +1 @@
1
- {"version":3,"file":"BackgroundTask.js","sourceRoot":"","sources":["../src/BackgroundTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAyB,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAElE,gDAAgD;AAChD,IAAI,8BAA8B,GAAG,KAAK,CAAC;AAE3C,cAAc;AACd;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,IAAmC,EAAE;IACtE,IAAI,CAAC,wBAAwB,CAAC,cAAc,EAAE;QAC5C,MAAM,IAAI,mBAAmB,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;KACnE;IAED,OAAO,wBAAwB,CAAC,cAAc,EAAE,CAAC;AACnD,CAAC,CAAC;AAEF,cAAc;AACd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IAAI,KAAK,CAAC,SAAS,QAAQ,sBAAsB,CAAC,CAAC;KAC1D;IACD,MAAM,wBAAwB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AAC/D,CAAC;AAED,cAAc;AACd;;;;;GAKG;AACH,+EAA+E;AAC/E,mBAAmB;AACnB,wEAAwE;AACxE,6FAA6F;AAC7F,QAAQ;AACR,+DAA+D;AAC/D,gFAAgF;AAChF,aAAa;AACb,qCAAqC;AACrC,MAAM;AACN,IAAI;AAEJ,eAAe;AACf,OAAO,EACL,oBAAoB,EACpB,oBAAoB,GAErB,MAAM,wBAAwB,CAAC","sourcesContent":["import { Platform, UnavailabilityError } from 'expo-modules-core';\nimport * as TaskManager from 'expo-task-manager';\n\nimport { BackgroundTaskOptions, BackgroundTaskStatus } from './BackgroundTask.types';\nimport ExpoBackgroundTaskModule from './ExpoBackgroundTaskModule';\n\n// Flag to warn about running on Apple simulator\nlet warnAboutRunningOniOSSimulator = false;\n\n// @needsAudit\n/**\n * Returns the status for the Background Task API. On web, it always returns `BackgroundTaskStatus.Restricted`,\n * while on native platforms it returns `BackgroundTaskStatus.Available`.\n *\n * @returns A BackgroundTaskStatus enum value or `null` if not available.\n */\nexport const getStatusAsync = async (): Promise<BackgroundTaskStatus> => {\n if (!ExpoBackgroundTaskModule.getStatusAsync) {\n throw new UnavailabilityError('BackgroundTask', 'getStatusAsync');\n }\n\n return ExpoBackgroundTaskModule.getStatusAsync();\n};\n\n// @needsAudit\n/**\n * Registers a background task with the 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`](task-manager/#taskmanagerdefinetasktaskname-taskexecutor)\n * for more details.\n * @param options An object containing the background task options.\n *\n * @example\n * ```ts\n * import * as TaskManager from 'expo-task-manager';\n *\n * // Register the task outside of the component\n * TaskManager.defineTask(BACKGROUND_TASK_IDENTIFIER, () => {\n * try {\n * await AsyncStorage.setItem(LAST_TASK_DATE_KEY, Date.now().toString());\n * } catch (error) {\n * console.error('Failed to save the last fetch date', error);\n * return BackgroundTaskResult.Failed;\n * }\n * return BackgroundTaskResult.Success;\n * });\n * ```\n *\n * You can now use the `registerTaskAsync` function to register the task:\n *\n * ```ts\n * BackgroundTask.registerTaskAsync(BACKGROUND_TASK_IDENTIFIER, {});\n * ```\n */\nexport async function registerTaskAsync(\n taskName: string,\n options: BackgroundTaskOptions = {}\n): Promise<void> {\n if (!ExpoBackgroundTaskModule.registerTaskAsync) {\n throw new UnavailabilityError('BackgroundTask', '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 if (await TaskManager.isTaskRegisteredAsync(taskName)) {\n throw new Error(`Task '${taskName}' is already registered.`);\n }\n if ((await ExpoBackgroundTaskModule.getStatusAsync()) === BackgroundTaskStatus.Restricted) {\n if (!warnAboutRunningOniOSSimulator) {\n const message =\n Platform.OS === 'ios'\n ? `Background tasks are not supported on iOS simulators. Skipped registering task: ${taskName}.`\n : `Background tasks are not available in the current environment. Skipped registering task: ${taskName}.`;\n console.warn(message);\n warnAboutRunningOniOSSimulator = true;\n }\n return;\n }\n await ExpoBackgroundTaskModule.registerTaskAsync(taskName, options);\n}\n\n// @needsAudit\n/**\n * Unregisters a background 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 (!ExpoBackgroundTaskModule.unregisterTaskAsync) {\n throw new UnavailabilityError('BackgroundTask', 'unregisterTaskAsync');\n }\n if (!(await TaskManager.isTaskRegisteredAsync(taskName))) {\n throw new Error(`Task '${taskName}' is not registered.`);\n }\n await ExpoBackgroundTaskModule.unregisterTaskAsync(taskName);\n}\n\n// @needsAudit\n/**\n * When in debug mode this function will trigger running the background tasks.\n * This function will only work for apps built in debug mode.\n * @todo(chrfalch): When we have a usable devtools plugin we can enable this function.\n * @returns A promise which fulfils when the task is triggered.\n */\n// export async function triggerTaskWorkerForTestingAsync(): Promise<boolean> {\n// if (__DEV__) {\n// if (!ExpoBackgroundTaskModule.triggerTaskWorkerForTestingAsync) {\n// throw new UnavailabilityError('BackgroundTask', 'triggerTaskWorkerForTestingAsync');\n// }\n// console.log('Calling triggerTaskWorkerForTestingAsync');\n// return await ExpoBackgroundTaskModule.triggerTaskWorkerForTestingAsync();\n// } else {\n// return Promise.resolve(false);\n// }\n// }\n\n// Export types\nexport {\n BackgroundTaskStatus,\n BackgroundTaskResult,\n BackgroundTaskOptions,\n} from './BackgroundTask.types';\n"]}
1
+ {"version":3,"file":"BackgroundTask.js","sourceRoot":"","sources":["../src/BackgroundTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAyB,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAElE,gDAAgD;AAChD,IAAI,8BAA8B,GAAG,KAAK,CAAC;AAE3C,IAAI,iBAAiB,GAAG,KAAK,CAAC;AAE9B,SAAS,SAAS,CAAC,QAAiB;IAClC,IAAI,iBAAiB,EAAE,EAAE,CAAC;QACxB,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACvB,MAAM,OAAO,GACX,gEAAgE;gBAChE,+FAA+F,CAAC;YAClG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACtB,iBAAiB,GAAG,IAAI,CAAC;QAC3B,CAAC;IACH,CAAC;IACD,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC9C,MAAM,IAAI,SAAS,CAAC,wCAAwC,CAAC,CAAC;IAChE,CAAC;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8BAA8B,GAAG,IAAI,CAAC;QACxC,CAAC;QACD,OAAO;IACT,CAAC;IACD,SAAS,CAAC,QAAQ,CAAC,CAAC;IACpB,MAAM,wBAAwB,CAAC,iBAAiB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AACtE,CAAC;AAED,cAAc;AACd;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,QAAgB;IACxD,IAAI,CAAC,wBAAwB,CAAC,mBAAmB,EAAE,CAAC;QAClD,MAAM,IAAI,mBAAmB,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,CAAC;IACzE,CAAC;IACD,IAAI,CAAC,CAAC,MAAM,WAAW,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;QACzD,MAAM,IAAI,KAAK,CAAC,SAAS,QAAQ,sBAAsB,CAAC,CAAC;IAC3D,CAAC;IAED,SAAS,CAAC,QAAQ,CAAC,CAAC;IACpB,MAAM,wBAAwB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AAC/D,CAAC;AAED,cAAc;AACd;;;;;GAKG;AACH,+EAA+E;AAC/E,mBAAmB;AACnB,wEAAwE;AACxE,6FAA6F;AAC7F,QAAQ;AACR,+DAA+D;AAC/D,gFAAgF;AAChF,aAAa;AACb,qCAAqC;AACrC,MAAM;AACN,IAAI;AAEJ,eAAe;AACf,OAAO,EACL,oBAAoB,EACpB,oBAAoB,GAErB,MAAM,wBAAwB,CAAC","sourcesContent":["import { isRunningInExpoGo } from 'expo';\nimport { Platform, UnavailabilityError } from 'expo-modules-core';\nimport * as TaskManager from 'expo-task-manager';\n\nimport { BackgroundTaskOptions, BackgroundTaskStatus } from './BackgroundTask.types';\nimport ExpoBackgroundTaskModule from './ExpoBackgroundTaskModule';\n\n// Flag to warn about running on Apple simulator\nlet warnAboutRunningOniOSSimulator = false;\n\nlet warnedAboutExpoGo = false;\n\nfunction _validate(taskName: unknown) {\n if (isRunningInExpoGo()) {\n if (!warnedAboutExpoGo) {\n const message =\n '`Background Task` functionality is not available in Expo Go:\\n' +\n 'Please use a development build to avoid limitations. Learn more: https://expo.fyi/dev-client.';\n console.warn(message);\n warnedAboutExpoGo = true;\n }\n }\n if (!taskName || typeof taskName !== 'string') {\n throw new TypeError('`taskName` must be a non-empty string.');\n }\n}\n\n// @needsAudit\n/**\n * Returns the status for the Background Task API. On web, it always returns `BackgroundTaskStatus.Restricted`,\n * while on native platforms it returns `BackgroundTaskStatus.Available`.\n *\n * @returns A BackgroundTaskStatus enum value or `null` if not available.\n */\nexport const getStatusAsync = async (): Promise<BackgroundTaskStatus> => {\n if (!ExpoBackgroundTaskModule.getStatusAsync) {\n throw new UnavailabilityError('BackgroundTask', 'getStatusAsync');\n }\n\n return isRunningInExpoGo()\n ? BackgroundTaskStatus.Restricted\n : ExpoBackgroundTaskModule.getStatusAsync();\n};\n\n// @needsAudit\n/**\n * Registers a background task with the 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`](task-manager/#taskmanagerdefinetasktaskname-taskexecutor)\n * for more details.\n * @param options An object containing the background task options.\n *\n * @example\n * ```ts\n * import * as TaskManager from 'expo-task-manager';\n *\n * // Register the task outside of the component\n * TaskManager.defineTask(BACKGROUND_TASK_IDENTIFIER, () => {\n * try {\n * await AsyncStorage.setItem(LAST_TASK_DATE_KEY, Date.now().toString());\n * } catch (error) {\n * console.error('Failed to save the last fetch date', error);\n * return BackgroundTaskResult.Failed;\n * }\n * return BackgroundTaskResult.Success;\n * });\n * ```\n *\n * You can now use the `registerTaskAsync` function to register the task:\n *\n * ```ts\n * BackgroundTask.registerTaskAsync(BACKGROUND_TASK_IDENTIFIER, {});\n * ```\n */\nexport async function registerTaskAsync(\n taskName: string,\n options: BackgroundTaskOptions = {}\n): Promise<void> {\n if (!ExpoBackgroundTaskModule.registerTaskAsync) {\n throw new UnavailabilityError('BackgroundTask', '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 if (await TaskManager.isTaskRegisteredAsync(taskName)) {\n throw new Error(`Task '${taskName}' is already registered.`);\n }\n if ((await ExpoBackgroundTaskModule.getStatusAsync()) === BackgroundTaskStatus.Restricted) {\n if (!warnAboutRunningOniOSSimulator) {\n const message =\n Platform.OS === 'ios'\n ? `Background tasks are not supported on iOS simulators. Skipped registering task: ${taskName}.`\n : `Background tasks are not available in the current environment. Skipped registering task: ${taskName}.`;\n console.warn(message);\n warnAboutRunningOniOSSimulator = true;\n }\n return;\n }\n _validate(taskName);\n await ExpoBackgroundTaskModule.registerTaskAsync(taskName, options);\n}\n\n// @needsAudit\n/**\n * Unregisters a background 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 (!ExpoBackgroundTaskModule.unregisterTaskAsync) {\n throw new UnavailabilityError('BackgroundTask', 'unregisterTaskAsync');\n }\n if (!(await TaskManager.isTaskRegisteredAsync(taskName))) {\n throw new Error(`Task '${taskName}' is not registered.`);\n }\n\n _validate(taskName);\n await ExpoBackgroundTaskModule.unregisterTaskAsync(taskName);\n}\n\n// @needsAudit\n/**\n * When in debug mode this function will trigger running the background tasks.\n * This function will only work for apps built in debug mode.\n * @todo(chrfalch): When we have a usable devtools plugin we can enable this function.\n * @returns A promise which fulfils when the task is triggered.\n */\n// export async function triggerTaskWorkerForTestingAsync(): Promise<boolean> {\n// if (__DEV__) {\n// if (!ExpoBackgroundTaskModule.triggerTaskWorkerForTestingAsync) {\n// throw new UnavailabilityError('BackgroundTask', 'triggerTaskWorkerForTestingAsync');\n// }\n// console.log('Calling triggerTaskWorkerForTestingAsync');\n// return await ExpoBackgroundTaskModule.triggerTaskWorkerForTestingAsync();\n// } else {\n// return Promise.resolve(false);\n// }\n// }\n\n// Export types\nexport {\n BackgroundTaskStatus,\n BackgroundTaskResult,\n BackgroundTaskOptions,\n} from './BackgroundTask.types';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoBackgroundTaskModule.web.d.ts","sourceRoot":"","sources":["../src/ExpoBackgroundTaskModule.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;;sBAGpC,QAAQ,oBAAoB,CAAC;;AADvD,wBAIE"}
1
+ {"version":3,"file":"ExpoBackgroundTaskModule.web.d.ts","sourceRoot":"","sources":["../src/ExpoBackgroundTaskModule.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;;sBAGpC,OAAO,CAAC,oBAAoB,CAAC;;AADvD,wBAIE"}
@@ -9,7 +9,7 @@
9
9
  "publication": {
10
10
  "groupId": "host.exp.exponent",
11
11
  "artifactId": "expo.modules.backgroundtask",
12
- "version": "0.2.1",
12
+ "version": "0.2.3",
13
13
  "repository": "local-maven-repo"
14
14
  }
15
15
  }
@@ -3,7 +3,7 @@
3
3
  "component": {
4
4
  "group": "host.exp.exponent",
5
5
  "module": "expo.modules.backgroundtask",
6
- "version": "0.2.1",
6
+ "version": "0.2.3",
7
7
  "attributes": {
8
8
  "org.gradle.status": "release"
9
9
  }
@@ -24,8 +24,8 @@
24
24
  },
25
25
  "files": [
26
26
  {
27
- "name": "expo.modules.backgroundtask-0.2.1.aar",
28
- "url": "expo.modules.backgroundtask-0.2.1.aar",
27
+ "name": "expo.modules.backgroundtask-0.2.3.aar",
28
+ "url": "expo.modules.backgroundtask-0.2.3.aar",
29
29
  "size": 47938,
30
30
  "sha512": "df365cff219528667a5ad1a044439dd3d46be3018c473bff6907568fb2ff5f484fa43b988c9dc4283b0edfc7035f1207f4d715d0483d12b30e37170aa94b6e8a",
31
31
  "sha256": "812c871ecce58021366e8bffc1b201cff6c121bdeeba5b53711f8c11635724fe",
@@ -64,8 +64,8 @@
64
64
  ],
65
65
  "files": [
66
66
  {
67
- "name": "expo.modules.backgroundtask-0.2.1.aar",
68
- "url": "expo.modules.backgroundtask-0.2.1.aar",
67
+ "name": "expo.modules.backgroundtask-0.2.3.aar",
68
+ "url": "expo.modules.backgroundtask-0.2.3.aar",
69
69
  "size": 47938,
70
70
  "sha512": "df365cff219528667a5ad1a044439dd3d46be3018c473bff6907568fb2ff5f484fa43b988c9dc4283b0edfc7035f1207f4d715d0483d12b30e37170aa94b6e8a",
71
71
  "sha256": "812c871ecce58021366e8bffc1b201cff6c121bdeeba5b53711f8c11635724fe",
@@ -84,8 +84,8 @@
84
84
  },
85
85
  "files": [
86
86
  {
87
- "name": "expo.modules.backgroundtask-0.2.1-sources.jar",
88
- "url": "expo.modules.backgroundtask-0.2.1-sources.jar",
87
+ "name": "expo.modules.backgroundtask-0.2.3-sources.jar",
88
+ "url": "expo.modules.backgroundtask-0.2.3-sources.jar",
89
89
  "size": 6743,
90
90
  "sha512": "558f8112433c958b3ce00edac1b1e08835137759aca7f9344968661df70dccbaffb9a193a2a8f186b193edb6e59d0e94021a69455a5f04f6b5495a155ba7560f",
91
91
  "sha256": "4019bc874cc09d9187352e03c4f54941c7abd91e4a3d8b41c2aaf351dd7ba28e",
@@ -0,0 +1 @@
1
+ 37cf664232d2b5f79bd42bb6934d7cf8d26cd2a0d4cc1d1b6fc71c2925f483c1
@@ -0,0 +1 @@
1
+ 75c7d8731b6f37248c0e7c77ca35fbfc238a8e7262c4a429bab732bb5b0663d0412eaf8185ff4d8d31acded3d298641c7f49f4bacacc48d0c5bc7df3cd650c3f
@@ -9,7 +9,7 @@
9
9
  <modelVersion>4.0.0</modelVersion>
10
10
  <groupId>host.exp.exponent</groupId>
11
11
  <artifactId>expo.modules.backgroundtask</artifactId>
12
- <version>0.2.1</version>
12
+ <version>0.2.3</version>
13
13
  <packaging>aar</packaging>
14
14
  <name>expo.modules.backgroundtask</name>
15
15
  <url>https://github.com/expo/expo</url>
@@ -0,0 +1 @@
1
+ 4ba9bdc3d1a78d103bda8d7a28dcf1492f7d279e323a6255d73d0a0e38726b02
@@ -0,0 +1 @@
1
+ 0a2f48582849c4eaa4b0690f0cb00ac96df1dfd5775403bf17a61a8dd18624697b0169db47ec1ab63c183d26ec4ed14c2ca3bf98e0bdfc2706646eb0d24192be
@@ -3,11 +3,11 @@
3
3
  <groupId>host.exp.exponent</groupId>
4
4
  <artifactId>expo.modules.backgroundtask</artifactId>
5
5
  <versioning>
6
- <latest>0.2.1</latest>
7
- <release>0.2.1</release>
6
+ <latest>0.2.3</latest>
7
+ <release>0.2.3</release>
8
8
  <versions>
9
- <version>0.2.1</version>
9
+ <version>0.2.3</version>
10
10
  </versions>
11
- <lastUpdated>20250408212901</lastUpdated>
11
+ <lastUpdated>20250411043200</lastUpdated>
12
12
  </versioning>
13
13
  </metadata>
@@ -1 +1 @@
1
- 0615517e5eb408519211f4e158b4c753
1
+ 3197afbb5116a75292619128ba4927b0
@@ -1 +1 @@
1
- 455a0b63e3a0bca5b704faf6bad7d7af067e6a06
1
+ e4a8af23b63c9ad31e8e1f3149348dcf78c97d88
@@ -1 +1 @@
1
- 089ecfd44d81580eceeaa66504cec3285882d73e2b690d37d1040d84508d5032
1
+ b85d7dbad6c4d61e45947510ade78cac16a0294e6443e0f7ec55dcd48ee59194
@@ -1 +1 @@
1
- 3bfddac092cfc9b8fb4d11283595bac4aabe063a888c8b97279dc2a44d6b6711b00d584c809928acab6410383ced229cb74c498a4343572c033252b7f1713f59
1
+ 01e76bfe49114b9593679028628b99e1991fc5e82d7d417365c472b6bfa768d64977233b3eb53141271d6312557cabab730adde321bace0f010fc8d92a3021f8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-background-task",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Expo Android and iOS module for Background Task APIs",
5
5
  "main": "build/BackgroundTask.js",
6
6
  "types": "build/BackgroundTask.d.ts",
@@ -32,13 +32,13 @@
32
32
  "license": "MIT",
33
33
  "homepage": "https://docs.expo.dev/versions/latest/sdk/background-task/",
34
34
  "dependencies": {
35
- "expo-task-manager": "~13.1.0"
35
+ "expo-task-manager": "~13.1.2"
36
36
  },
37
37
  "devDependencies": {
38
- "expo-module-scripts": "^4.1.0"
38
+ "expo-module-scripts": "^4.1.1"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "expo": "*"
42
42
  },
43
- "gitHead": "2487c7aa9b5ef6a7052e82bbf9a53604c2ed273f"
43
+ "gitHead": "c81263062bf24ad09e51e019f1d7dc29fa651c55"
44
44
  }
@@ -1,3 +1,4 @@
1
+ import { isRunningInExpoGo } from 'expo';
1
2
  import { Platform, UnavailabilityError } from 'expo-modules-core';
2
3
  import * as TaskManager from 'expo-task-manager';
3
4
 
@@ -7,6 +8,23 @@ import ExpoBackgroundTaskModule from './ExpoBackgroundTaskModule';
7
8
  // Flag to warn about running on Apple simulator
8
9
  let warnAboutRunningOniOSSimulator = false;
9
10
 
11
+ let warnedAboutExpoGo = false;
12
+
13
+ function _validate(taskName: unknown) {
14
+ if (isRunningInExpoGo()) {
15
+ if (!warnedAboutExpoGo) {
16
+ const message =
17
+ '`Background Task` functionality is not available in Expo Go:\n' +
18
+ 'Please use a development build to avoid limitations. Learn more: https://expo.fyi/dev-client.';
19
+ console.warn(message);
20
+ warnedAboutExpoGo = true;
21
+ }
22
+ }
23
+ if (!taskName || typeof taskName !== 'string') {
24
+ throw new TypeError('`taskName` must be a non-empty string.');
25
+ }
26
+ }
27
+
10
28
  // @needsAudit
11
29
  /**
12
30
  * Returns the status for the Background Task API. On web, it always returns `BackgroundTaskStatus.Restricted`,
@@ -19,7 +37,9 @@ export const getStatusAsync = async (): Promise<BackgroundTaskStatus> => {
19
37
  throw new UnavailabilityError('BackgroundTask', 'getStatusAsync');
20
38
  }
21
39
 
22
- return ExpoBackgroundTaskModule.getStatusAsync();
40
+ return isRunningInExpoGo()
41
+ ? BackgroundTaskStatus.Restricted
42
+ : ExpoBackgroundTaskModule.getStatusAsync();
23
43
  };
24
44
 
25
45
  // @needsAudit
@@ -77,6 +97,7 @@ export async function registerTaskAsync(
77
97
  }
78
98
  return;
79
99
  }
100
+ _validate(taskName);
80
101
  await ExpoBackgroundTaskModule.registerTaskAsync(taskName, options);
81
102
  }
82
103
 
@@ -93,6 +114,8 @@ export async function unregisterTaskAsync(taskName: string): Promise<void> {
93
114
  if (!(await TaskManager.isTaskRegisteredAsync(taskName))) {
94
115
  throw new Error(`Task '${taskName}' is not registered.`);
95
116
  }
117
+
118
+ _validate(taskName);
96
119
  await ExpoBackgroundTaskModule.unregisterTaskAsync(taskName);
97
120
  }
98
121
 
@@ -1 +0,0 @@
1
- 9630af27f6d6f99458ea047c9ee6d8fc926f666b766a383db32a8a0970e3a14b
@@ -1 +0,0 @@
1
- a949f20e3b3507ce58629154203a2cccd5f126797772783b971e7dda13ba5485b42bcc203b8a4e3b40b5bfc118d14a966610299af2a3d415b04f867cc92251ef
@@ -1 +0,0 @@
1
- 79a804b5a324d77b77f9ead754891d8f5c1cd848a57315f01ba072b94e699b87
@@ -1 +0,0 @@
1
- e435e6e67e5d03548ac1b15737308a1242f28cdcbf7773a8fb03948bd2d7d60ba99cf9edcff75b871bfbf4f201714b75e2ca6d417ec08789b3051b3a9a6e8ec0