expo-task-manager 11.7.2 → 11.8.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 CHANGED
@@ -10,13 +10,15 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
- ## 11.7.2 — 2024-01-26
13
+ ## 11.8.0 — 2024-04-18
14
14
 
15
- ### 🐛 Bug fixes
15
+ ### 💡 Others
16
16
 
17
- - On `Android`, added events to module definition to clear warnings. ([#26654](https://github.com/expo/expo/pull/26654) by [@alanjhughes](https://github.com/alanjhughes))
17
+ - [iOS] Add privacy manifest describing required reason API usage. ([#27770](https://github.com/expo/expo/pull/27770) by [@aleqsio](https://github.com/aleqsio))
18
+ - drop unused web `name` property. ([#27437](https://github.com/expo/expo/pull/27437) by [@EvanBacon](https://github.com/EvanBacon))
19
+ - Removed deprecated backward compatible Gradle settings. ([#28083](https://github.com/expo/expo/pull/28083) by [@kudo](https://github.com/kudo))
18
20
 
19
- ## 11.7.1 2024-01-25
21
+ ## 11.7.1 - 2024-01-25
20
22
 
21
23
  ### 🐛 Bug fixes
22
24
 
@@ -1,113 +1,24 @@
1
1
  apply plugin: 'com.android.library'
2
- apply plugin: 'kotlin-android'
3
- apply plugin: 'maven-publish'
4
2
 
5
3
  group = 'host.exp.exponent'
6
- version = '11.7.2'
4
+ version = '11.8.0'
7
5
 
8
6
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
9
- if (expoModulesCorePlugin.exists()) {
10
- apply from: expoModulesCorePlugin
11
- applyKotlinExpoModulesCorePlugin()
12
- // Remove this check, but keep the contents after SDK49 support is dropped
13
- if (safeExtGet("expoProvidesDefaultConfig", false)) {
14
- useExpoPublishing()
15
- useCoreDependencies()
16
- }
17
- }
18
-
19
- buildscript {
20
- // Simple helper that allows the root project to override versions declared by this library.
21
- ext.safeExtGet = { prop, fallback ->
22
- rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
23
- }
24
-
25
- // Ensures backward compatibility
26
- ext.getKotlinVersion = {
27
- if (ext.has("kotlinVersion")) {
28
- ext.kotlinVersion()
29
- } else {
30
- ext.safeExtGet("kotlinVersion", "1.8.10")
31
- }
32
- }
33
-
34
- repositories {
35
- mavenCentral()
36
- }
37
-
38
- dependencies {
39
- classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${getKotlinVersion()}")
40
- }
41
- }
42
-
43
- // Remove this if and it's contents, when support for SDK49 is dropped
44
- if (!safeExtGet("expoProvidesDefaultConfig", false)) {
45
- afterEvaluate {
46
- publishing {
47
- publications {
48
- release(MavenPublication) {
49
- from components.release
50
- }
51
- }
52
- repositories {
53
- maven {
54
- url = mavenLocal().url
55
- }
56
- }
57
- }
58
- }
59
- }
7
+ apply from: expoModulesCorePlugin
8
+ applyKotlinExpoModulesCorePlugin()
9
+ useCoreDependencies()
10
+ useDefaultAndroidSdkVersions()
11
+ useExpoPublishing()
60
12
 
61
13
  android {
62
- // Remove this if and it's contents, when support for SDK49 is dropped
63
- if (!safeExtGet("expoProvidesDefaultConfig", false)) {
64
- compileSdkVersion safeExtGet("compileSdkVersion", 34)
65
-
66
- defaultConfig {
67
- minSdkVersion safeExtGet("minSdkVersion", 23)
68
- targetSdkVersion safeExtGet("targetSdkVersion", 34)
69
- }
70
-
71
- publishing {
72
- singleVariant("release") {
73
- withSourcesJar()
74
- }
75
- }
76
-
77
- lintOptions {
78
- abortOnError false
79
- }
80
- }
81
-
82
- def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
83
- if (agpVersion.tokenize('.')[0].toInteger() < 8) {
84
- compileOptions {
85
- sourceCompatibility JavaVersion.VERSION_11
86
- targetCompatibility JavaVersion.VERSION_11
87
- }
88
-
89
- kotlinOptions {
90
- jvmTarget = JavaVersion.VERSION_11.majorVersion
91
- }
92
- }
93
-
94
14
  namespace "expo.modules.taskManager"
95
15
  defaultConfig {
96
16
  versionCode 23
97
- versionName "11.7.2"
17
+ versionName "11.8.0"
98
18
  }
99
19
  }
100
20
 
101
21
  dependencies {
102
- // Remove this if and it's contents, when support for SDK49 is dropped
103
- if (!safeExtGet("expoProvidesDefaultConfig", false)) {
104
- implementation project(':expo-modules-core')
105
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
106
- }
107
22
  implementation project(':unimodules-app-loader')
108
-
109
23
  api "androidx.core:core:1.0.0"
110
24
  }
111
- repositories {
112
- mavenCentral()
113
- }
@@ -1,5 +1,6 @@
1
1
  package expo.modules.taskManager
2
2
 
3
+ import android.os.Bundle
3
4
  import android.os.Handler
4
5
  import android.os.Looper
5
6
  import expo.modules.core.errors.ModuleNotFoundException
@@ -29,7 +30,7 @@ class TaskManagerModule : Module() {
29
30
  "EVENT_NAME" to TaskManagerInterface.EVENT_NAME
30
31
  )
31
32
 
32
- AsyncFunction("isAvailableAsync") {
33
+ AsyncFunction<Boolean>("isAvailableAsync") {
33
34
  return@AsyncFunction true
34
35
  }
35
36
 
@@ -45,7 +46,7 @@ class TaskManagerModule : Module() {
45
46
  taskService.getTaskOptions(taskName, appScopeKey)
46
47
  }
47
48
 
48
- AsyncFunction("getRegisteredTasksAsync") {
49
+ AsyncFunction<List<Bundle>>("getRegisteredTasksAsync") {
49
50
  taskService.getTasksForAppScopeKey(appScopeKey)
50
51
  }
51
52
 
@@ -53,7 +54,7 @@ class TaskManagerModule : Module() {
53
54
  taskService.unregisterTask(taskName, appScopeKey, null)
54
55
  }
55
56
 
56
- AsyncFunction("unregisterAllTasksAsync") {
57
+ AsyncFunction<Unit>("unregisterAllTasksAsync") {
57
58
  taskService.unregisterAllTasksForAppScopeKey(appScopeKey)
58
59
  }
59
60
 
@@ -3,7 +3,6 @@ package expo.modules.taskManager;
3
3
  import android.content.Context;
4
4
 
5
5
  import expo.modules.core.BasePackage;
6
- import expo.modules.core.ExportedModule;
7
6
  import expo.modules.core.interfaces.InternalModule;
8
7
  import expo.modules.core.interfaces.SingletonModule;
9
8
 
@@ -1,5 +1,4 @@
1
1
  declare const _default: {
2
- readonly name: string;
3
2
  readonly EVENT_NAME: string;
4
3
  addListener(): void;
5
4
  removeListeners(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoTaskManager.web.d.ts","sourceRoot":"","sources":["../src/ExpoTaskManager.web.ts"],"names":[],"mappings":";;;;;wBAS4B,QAAQ,OAAO,CAAC;;AAT5C,wBAYE"}
1
+ {"version":3,"file":"ExpoTaskManager.web.d.ts","sourceRoot":"","sources":["../src/ExpoTaskManager.web.ts"],"names":[],"mappings":";;;;wBAM4B,OAAO,CAAC,OAAO,CAAC;;AAN5C,wBASE"}
@@ -1,7 +1,4 @@
1
1
  export default {
2
- get name() {
3
- return 'ExpoTaskManager';
4
- },
5
2
  get EVENT_NAME() {
6
3
  return 'TaskManager.executeTask';
7
4
  },
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoTaskManager.web.js","sourceRoot":"","sources":["../src/ExpoTaskManager.web.ts"],"names":[],"mappings":"AAAA,eAAe;IACb,IAAI,IAAI;QACN,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IACD,IAAI,UAAU;QACZ,OAAO,yBAAyB,CAAC;IACnC,CAAC;IACD,WAAW,KAAI,CAAC;IAChB,eAAe,KAAI,CAAC;IACpB,KAAK,CAAC,gBAAgB;QACpB,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAC","sourcesContent":["export default {\n get name(): string {\n return 'ExpoTaskManager';\n },\n get EVENT_NAME(): string {\n return 'TaskManager.executeTask';\n },\n addListener() {},\n removeListeners() {},\n async isAvailableAsync(): Promise<boolean> {\n return false;\n },\n};\n"]}
1
+ {"version":3,"file":"ExpoTaskManager.web.js","sourceRoot":"","sources":["../src/ExpoTaskManager.web.ts"],"names":[],"mappings":"AAAA,eAAe;IACb,IAAI,UAAU;QACZ,OAAO,yBAAyB,CAAC;IACnC,CAAC;IACD,WAAW,KAAI,CAAC;IAChB,eAAe,KAAI,CAAC;IACpB,KAAK,CAAC,gBAAgB;QACpB,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAC","sourcesContent":["export default {\n get EVENT_NAME(): string {\n return 'TaskManager.executeTask';\n },\n addListener() {},\n removeListeners() {},\n async isAvailableAsync(): Promise<boolean> {\n return false;\n },\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"TaskManager.js","sourceRoot":"","sources":["../src/TaskManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAEtE,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAsFhD,MAAM,KAAK,GAA8C,IAAI,GAAG,EAG7D,CAAC;AAEJ,SAAS,iBAAiB,CAAC,QAAQ;IACjC,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;QAC7C,MAAM,IAAI,SAAS,CAAC,wCAAwC,CAAC,CAAC;KAC/D;AACH,CAAC;AAED,cAAc;AACd;;;;;;;;;GASG;AACH,MAAM,UAAU,UAAU,CACxB,QAAgB,EAChB,YAAwC;IAExC,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;QAC7C,OAAO,CAAC,IAAI,CAAC,yEAAyE,CAAC,CAAC;QACxF,OAAO;KACR;IACD,IAAI,CAAC,YAAY,IAAI,OAAO,YAAY,KAAK,UAAU,EAAE;QACvD,OAAO,CAAC,IAAI,CAAC,6DAA6D,CAAC,CAAC;QAC5E,OAAO;KACR;IACD,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;AACpC,CAAC;AAED,cAAc;AACd;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,QAAgB;IAC5C,OAAO,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC7B,CAAC;AAED,cAAc;AACd;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,QAAgB;IAC1D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AAe,CAAC,gBAAgB,EAAE,CAAC;AAClD,CAAC","sourcesContent":["import { EventEmitter, UnavailabilityError } from 'expo-modules-core';\n\nimport ExpoTaskManager from './ExpoTaskManager';\n\n// @needsAudit @docsMissing\n/**\n * Error object that can be received through [`TaskManagerTaskBody`](#taskmanagertaskbody) when the\n * task fails.\n */\nexport interface TaskManagerError {\n code: string | number;\n message: string;\n}\n\n// @needsAudit\n/**\n * Represents the object that is passed to the task executor.\n */\nexport interface TaskManagerTaskBody<T = unknown> {\n /**\n * An object of data passed to the task executor. Its properties depends on the type of the task.\n */\n data: T;\n\n /**\n * Error object if the task failed or `null` otherwise.\n */\n error: TaskManagerError | null;\n\n /**\n * Additional details containing unique ID of task event and name of the task.\n */\n executionInfo: TaskManagerTaskBodyExecutionInfo;\n}\n\n// @needsAudit\n/**\n * Additional details about execution provided in `TaskManagerTaskBody`.\n */\nexport interface TaskManagerTaskBodyExecutionInfo {\n /**\n * State of the application.\n * @platform ios\n */\n appState?: 'active' | 'background' | 'inactive';\n /**\n * Unique ID of task event.\n */\n eventId: string;\n /**\n * Name of the task.\n */\n taskName: string;\n}\n\n// @needsAudit\n/**\n * Represents an already registered task.\n */\nexport interface TaskManagerTask {\n /**\n * Name that the task is registered with.\n */\n taskName: string;\n\n /**\n * Type of the task which depends on how the task was registered.\n */\n taskType: string;\n\n /**\n * Provides `options` that the task was registered with.\n */\n options: any;\n}\n\n/**\n * @deprecated Use `TaskManagerTask` instead.\n * @hidden\n */\nexport interface RegisteredTask extends TaskManagerTask {}\n\n// @needsAudit\n/**\n * Type of task executor – a function that handles the task.\n */\nexport type TaskManagerTaskExecutor<T = unknown> = (body: TaskManagerTaskBody<T>) => void;\n\nconst tasks: Map<string, TaskManagerTaskExecutor<any>> = new Map<\n string,\n TaskManagerTaskExecutor<any>\n>();\n\nfunction _validateTaskName(taskName) {\n if (!taskName || typeof taskName !== 'string') {\n throw new TypeError('`taskName` must be a non-empty string.');\n }\n}\n\n// @needsAudit\n/**\n * Defines task function. It must be called in the global scope of your JavaScript bundle.\n * In particular, it cannot be called in any of React lifecycle methods like `componentDidMount`.\n * This limitation is due to the fact that when the application is launched in the background,\n * we need to spin up your JavaScript app, run your task and then shut down — no views are mounted\n * in this scenario.\n *\n * @param taskName Name of the task. It must be the same as the name you provided when registering the task.\n * @param taskExecutor A function that will be invoked when the task with given `taskName` is executed.\n */\nexport function defineTask<T = unknown>(\n taskName: string,\n taskExecutor: TaskManagerTaskExecutor<T>\n) {\n if (!taskName || typeof taskName !== 'string') {\n console.warn(`TaskManager.defineTask: 'taskName' argument must be a non-empty string.`);\n return;\n }\n if (!taskExecutor || typeof taskExecutor !== 'function') {\n console.warn(`TaskManager.defineTask: 'task' argument must be a function.`);\n return;\n }\n tasks.set(taskName, taskExecutor);\n}\n\n// @needsAudit\n/**\n * Checks whether the task is already defined.\n *\n * @param taskName Name of the task.\n */\nexport function isTaskDefined(taskName: string): boolean {\n return tasks.has(taskName);\n}\n\n// @needsAudit\n/**\n * Determine whether the task is registered. Registered tasks are stored in a persistent storage and\n * preserved between sessions.\n *\n * @param taskName Name of the task.\n * @returns A promise which fulfills with a `boolean` value whether or not the task with given name\n * is already registered.\n */\nexport async function isTaskRegisteredAsync(taskName: string): Promise<boolean> {\n if (!ExpoTaskManager.isTaskRegisteredAsync) {\n throw new UnavailabilityError('TaskManager', 'isTaskRegisteredAsync');\n }\n\n _validateTaskName(taskName);\n return ExpoTaskManager.isTaskRegisteredAsync(taskName);\n}\n\n// @needsAudit\n/**\n * Retrieves `options` associated with the task, that were passed to the function registering the task\n * (eg. `Location.startLocationUpdatesAsync`).\n *\n * @param taskName Name of the task.\n * @return A promise which fulfills with the `options` object that was passed while registering task\n * with given name or `null` if task couldn't be found.\n */\nexport async function getTaskOptionsAsync<TaskOptions>(taskName: string): Promise<TaskOptions> {\n if (!ExpoTaskManager.getTaskOptionsAsync) {\n throw new UnavailabilityError('TaskManager', 'getTaskOptionsAsync');\n }\n\n _validateTaskName(taskName);\n return ExpoTaskManager.getTaskOptionsAsync(taskName);\n}\n\n// @needsAudit\n/**\n * Provides information about tasks registered in the app.\n *\n * @returns A promise which fulfills with an array of tasks registered in the app. Example:\n * ```json\n * [\n * {\n * taskName: 'location-updates-task-name',\n * taskType: 'location',\n * options: {\n * accuracy: Location.Accuracy.High,\n * showsBackgroundLocationIndicator: false,\n * },\n * },\n * {\n * taskName: 'geofencing-task-name',\n * taskType: 'geofencing',\n * options: {\n * regions: [...],\n * },\n * },\n * ]\n * ```\n */\nexport async function getRegisteredTasksAsync(): Promise<TaskManagerTask[]> {\n if (!ExpoTaskManager.getRegisteredTasksAsync) {\n throw new UnavailabilityError('TaskManager', 'getRegisteredTasksAsync');\n }\n\n return ExpoTaskManager.getRegisteredTasksAsync();\n}\n\n// @needsAudit\n/**\n * Unregisters task from the app, so the app will not be receiving updates for that task anymore.\n * _It is recommended to use methods specialized by modules that registered the task, eg.\n * [`Location.stopLocationUpdatesAsync`](./location/#expolocationstoplocationupdatesasynctaskname)._\n *\n * @param taskName Name of the task to unregister.\n * @return A promise which fulfills as soon as the task is unregistered.\n */\nexport async function unregisterTaskAsync(taskName: string): Promise<void> {\n if (!ExpoTaskManager.unregisterTaskAsync) {\n throw new UnavailabilityError('TaskManager', 'unregisterTaskAsync');\n }\n\n _validateTaskName(taskName);\n await ExpoTaskManager.unregisterTaskAsync(taskName);\n}\n\n// @needsAudit\n/**\n * Unregisters all tasks registered for the running app. You may want to call this when the user is\n * signing out and you no longer need to track his location or run any other background tasks.\n * @return A promise which fulfills as soon as all tasks are completely unregistered.\n */\nexport async function unregisterAllTasksAsync(): Promise<void> {\n if (!ExpoTaskManager.unregisterAllTasksAsync) {\n throw new UnavailabilityError('TaskManager', 'unregisterAllTasksAsync');\n }\n\n await ExpoTaskManager.unregisterAllTasksAsync();\n}\n\nif (ExpoTaskManager) {\n const eventEmitter = new EventEmitter(ExpoTaskManager);\n eventEmitter.addListener<TaskManagerTaskBody>(\n ExpoTaskManager.EVENT_NAME,\n async ({ data, error, executionInfo }) => {\n const { eventId, taskName } = executionInfo;\n const taskExecutor = tasks.get(taskName);\n let result: any = null;\n\n if (taskExecutor) {\n try {\n // Execute JS task\n result = await taskExecutor({ data, error, executionInfo });\n } catch (error) {\n console.error(`TaskManager: Task \"${taskName}\" failed:`, error);\n } finally {\n // Notify manager the task is finished.\n await ExpoTaskManager.notifyTaskFinishedAsync(taskName, { eventId, result });\n }\n } else {\n console.warn(\n `TaskManager: Task \"${taskName}\" has been executed but looks like it is not defined. Please make sure that \"TaskManager.defineTask\" is called during initialization phase.`\n );\n // No tasks defined -> we need to notify about finish anyway.\n await ExpoTaskManager.notifyTaskFinishedAsync(taskName, { eventId, result });\n // We should also unregister such tasks automatically as the task might have been removed\n // from the app or just renamed - in that case it needs to be registered again (with the new name).\n await ExpoTaskManager.unregisterTaskAsync(taskName);\n }\n }\n );\n}\n\n// @needsAudit\n/**\n * Determine if the `TaskManager` API can be used in this app.\n * @return A promise fulfills with `true` if the API can be used, and `false` otherwise.\n * On the web it always returns `false`.\n */\nexport async function isAvailableAsync(): Promise<boolean> {\n return await ExpoTaskManager.isAvailableAsync();\n}\n"]}
1
+ {"version":3,"file":"TaskManager.js","sourceRoot":"","sources":["../src/TaskManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAEtE,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAsFhD,MAAM,KAAK,GAA8C,IAAI,GAAG,EAG7D,CAAC;AAEJ,SAAS,iBAAiB,CAAC,QAAQ;IACjC,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC9C,MAAM,IAAI,SAAS,CAAC,wCAAwC,CAAC,CAAC;IAChE,CAAC;AACH,CAAC;AAED,cAAc;AACd;;;;;;;;;GASG;AACH,MAAM,UAAU,UAAU,CACxB,QAAgB,EAChB,YAAwC;IAExC,IAAI,CAAC,QAAQ,IAAI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YAC9D,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,sBAAsB,QAAQ,WAAW,EAAE,KAAK,CAAC,CAAC;YAClE,CAAC;oBAAS,CAAC;gBACT,uCAAuC;gBACvC,MAAM,eAAe,CAAC,uBAAuB,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;YAC/E,CAAC;QACH,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CACV,sBAAsB,QAAQ,6IAA6I,CAC5K,CAAC;YACF,6DAA6D;YAC7D,MAAM,eAAe,CAAC,uBAAuB,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;YAC7E,yFAAyF;YACzF,mGAAmG;YACnG,MAAM,eAAe,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;QACtD,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC;AAED,cAAc;AACd;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,OAAO,MAAM,eAAe,CAAC,gBAAgB,EAAE,CAAC;AAClD,CAAC","sourcesContent":["import { EventEmitter, UnavailabilityError } from 'expo-modules-core';\n\nimport ExpoTaskManager from './ExpoTaskManager';\n\n// @needsAudit @docsMissing\n/**\n * Error object that can be received through [`TaskManagerTaskBody`](#taskmanagertaskbody) when the\n * task fails.\n */\nexport interface TaskManagerError {\n code: string | number;\n message: string;\n}\n\n// @needsAudit\n/**\n * Represents the object that is passed to the task executor.\n */\nexport interface TaskManagerTaskBody<T = unknown> {\n /**\n * An object of data passed to the task executor. Its properties depends on the type of the task.\n */\n data: T;\n\n /**\n * Error object if the task failed or `null` otherwise.\n */\n error: TaskManagerError | null;\n\n /**\n * Additional details containing unique ID of task event and name of the task.\n */\n executionInfo: TaskManagerTaskBodyExecutionInfo;\n}\n\n// @needsAudit\n/**\n * Additional details about execution provided in `TaskManagerTaskBody`.\n */\nexport interface TaskManagerTaskBodyExecutionInfo {\n /**\n * State of the application.\n * @platform ios\n */\n appState?: 'active' | 'background' | 'inactive';\n /**\n * Unique ID of task event.\n */\n eventId: string;\n /**\n * Name of the task.\n */\n taskName: string;\n}\n\n// @needsAudit\n/**\n * Represents an already registered task.\n */\nexport interface TaskManagerTask {\n /**\n * Name that the task is registered with.\n */\n taskName: string;\n\n /**\n * Type of the task which depends on how the task was registered.\n */\n taskType: string;\n\n /**\n * Provides `options` that the task was registered with.\n */\n options: any;\n}\n\n/**\n * @deprecated Use `TaskManagerTask` instead.\n * @hidden\n */\nexport interface RegisteredTask extends TaskManagerTask {}\n\n// @needsAudit\n/**\n * Type of task executor – a function that handles the task.\n */\nexport type TaskManagerTaskExecutor<T = unknown> = (body: TaskManagerTaskBody<T>) => void;\n\nconst tasks: Map<string, TaskManagerTaskExecutor<any>> = new Map<\n string,\n TaskManagerTaskExecutor<any>\n>();\n\nfunction _validateTaskName(taskName) {\n if (!taskName || typeof taskName !== 'string') {\n throw new TypeError('`taskName` must be a non-empty string.');\n }\n}\n\n// @needsAudit\n/**\n * Defines task function. It must be called in the global scope of your JavaScript bundle.\n * In particular, it cannot be called in any of React lifecycle methods like `componentDidMount`.\n * This limitation is due to the fact that when the application is launched in the background,\n * we need to spin up your JavaScript app, run your task and then shut down — no views are mounted\n * in this scenario.\n *\n * @param taskName Name of the task. It must be the same as the name you provided when registering the task.\n * @param taskExecutor A function that will be invoked when the task with given `taskName` is executed.\n */\nexport function defineTask<T = unknown>(\n taskName: string,\n taskExecutor: TaskManagerTaskExecutor<T>\n) {\n if (!taskName || typeof taskName !== 'string') {\n console.warn(`TaskManager.defineTask: 'taskName' argument must be a non-empty string.`);\n return;\n }\n if (!taskExecutor || typeof taskExecutor !== 'function') {\n console.warn(`TaskManager.defineTask: 'task' argument must be a function.`);\n return;\n }\n tasks.set(taskName, taskExecutor);\n}\n\n// @needsAudit\n/**\n * Checks whether the task is already defined.\n *\n * @param taskName Name of the task.\n */\nexport function isTaskDefined(taskName: string): boolean {\n return tasks.has(taskName);\n}\n\n// @needsAudit\n/**\n * Determine whether the task is registered. Registered tasks are stored in a persistent storage and\n * preserved between sessions.\n *\n * @param taskName Name of the task.\n * @returns A promise which fulfills with a `boolean` value whether or not the task with given name\n * is already registered.\n */\nexport async function isTaskRegisteredAsync(taskName: string): Promise<boolean> {\n if (!ExpoTaskManager.isTaskRegisteredAsync) {\n throw new UnavailabilityError('TaskManager', 'isTaskRegisteredAsync');\n }\n\n _validateTaskName(taskName);\n return ExpoTaskManager.isTaskRegisteredAsync(taskName);\n}\n\n// @needsAudit\n/**\n * Retrieves `options` associated with the task, that were passed to the function registering the task\n * (eg. `Location.startLocationUpdatesAsync`).\n *\n * @param taskName Name of the task.\n * @return A promise which fulfills with the `options` object that was passed while registering task\n * with given name or `null` if task couldn't be found.\n */\nexport async function getTaskOptionsAsync<TaskOptions>(taskName: string): Promise<TaskOptions> {\n if (!ExpoTaskManager.getTaskOptionsAsync) {\n throw new UnavailabilityError('TaskManager', 'getTaskOptionsAsync');\n }\n\n _validateTaskName(taskName);\n return ExpoTaskManager.getTaskOptionsAsync(taskName);\n}\n\n// @needsAudit\n/**\n * Provides information about tasks registered in the app.\n *\n * @returns A promise which fulfills with an array of tasks registered in the app. Example:\n * ```json\n * [\n * {\n * taskName: 'location-updates-task-name',\n * taskType: 'location',\n * options: {\n * accuracy: Location.Accuracy.High,\n * showsBackgroundLocationIndicator: false,\n * },\n * },\n * {\n * taskName: 'geofencing-task-name',\n * taskType: 'geofencing',\n * options: {\n * regions: [...],\n * },\n * },\n * ]\n * ```\n */\nexport async function getRegisteredTasksAsync(): Promise<TaskManagerTask[]> {\n if (!ExpoTaskManager.getRegisteredTasksAsync) {\n throw new UnavailabilityError('TaskManager', 'getRegisteredTasksAsync');\n }\n\n return ExpoTaskManager.getRegisteredTasksAsync();\n}\n\n// @needsAudit\n/**\n * Unregisters task from the app, so the app will not be receiving updates for that task anymore.\n * _It is recommended to use methods specialized by modules that registered the task, eg.\n * [`Location.stopLocationUpdatesAsync`](./location/#expolocationstoplocationupdatesasynctaskname)._\n *\n * @param taskName Name of the task to unregister.\n * @return A promise which fulfills as soon as the task is unregistered.\n */\nexport async function unregisterTaskAsync(taskName: string): Promise<void> {\n if (!ExpoTaskManager.unregisterTaskAsync) {\n throw new UnavailabilityError('TaskManager', 'unregisterTaskAsync');\n }\n\n _validateTaskName(taskName);\n await ExpoTaskManager.unregisterTaskAsync(taskName);\n}\n\n// @needsAudit\n/**\n * Unregisters all tasks registered for the running app. You may want to call this when the user is\n * signing out and you no longer need to track his location or run any other background tasks.\n * @return A promise which fulfills as soon as all tasks are completely unregistered.\n */\nexport async function unregisterAllTasksAsync(): Promise<void> {\n if (!ExpoTaskManager.unregisterAllTasksAsync) {\n throw new UnavailabilityError('TaskManager', 'unregisterAllTasksAsync');\n }\n\n await ExpoTaskManager.unregisterAllTasksAsync();\n}\n\nif (ExpoTaskManager) {\n const eventEmitter = new EventEmitter(ExpoTaskManager);\n eventEmitter.addListener<TaskManagerTaskBody>(\n ExpoTaskManager.EVENT_NAME,\n async ({ data, error, executionInfo }) => {\n const { eventId, taskName } = executionInfo;\n const taskExecutor = tasks.get(taskName);\n let result: any = null;\n\n if (taskExecutor) {\n try {\n // Execute JS task\n result = await taskExecutor({ data, error, executionInfo });\n } catch (error) {\n console.error(`TaskManager: Task \"${taskName}\" failed:`, error);\n } finally {\n // Notify manager the task is finished.\n await ExpoTaskManager.notifyTaskFinishedAsync(taskName, { eventId, result });\n }\n } else {\n console.warn(\n `TaskManager: Task \"${taskName}\" has been executed but looks like it is not defined. Please make sure that \"TaskManager.defineTask\" is called during initialization phase.`\n );\n // No tasks defined -> we need to notify about finish anyway.\n await ExpoTaskManager.notifyTaskFinishedAsync(taskName, { eventId, result });\n // We should also unregister such tasks automatically as the task might have been removed\n // from the app or just renamed - in that case it needs to be registered again (with the new name).\n await ExpoTaskManager.unregisterTaskAsync(taskName);\n }\n }\n );\n}\n\n// @needsAudit\n/**\n * Determine if the `TaskManager` API can be used in this app.\n * @return A promise fulfills with `true` if the API can be used, and `false` otherwise.\n * On the web it always returns `false`.\n */\nexport async function isAvailableAsync(): Promise<boolean> {\n return await ExpoTaskManager.isAvailableAsync();\n}\n"]}
@@ -451,6 +451,7 @@ EX_REGISTER_SINGLETON_MODULE(TaskService)
451
451
  */
452
452
  - (void)_saveConfigWithDictionary:(nonnull NSDictionary *)dict
453
453
  {
454
+ // Uses required reason API based on the following reason: CA92.1
454
455
  NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
455
456
  [userDefaults setObject:dict forKey:NSStringFromClass([self class])];
456
457
  [userDefaults synchronize];
@@ -17,6 +17,8 @@ Pod::Spec.new do |s|
17
17
  s.dependency 'ExpoModulesCore'
18
18
  s.dependency 'UMAppLoader'
19
19
 
20
+ s.resource_bundles = {'ExpoTaskManager_privacy' => ['PrivacyInfo.xcprivacy']}
21
+
20
22
  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
23
  s.source_files = "#{s.name}/**/*.h"
22
24
  s.vendored_frameworks = "#{s.name}.xcframework"
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>NSPrivacyCollectedDataTypes</key>
6
+ <array>
7
+ </array>
8
+ <key>NSPrivacyTracking</key>
9
+ <false/>
10
+ <key>NSPrivacyTrackingDomains</key>
11
+ <array/>
12
+ <key>NSPrivacyAccessedAPITypes</key>
13
+ <array>
14
+ <dict>
15
+ <key>NSPrivacyAccessedAPIType</key>
16
+ <string>NSPrivacyAccessedAPICategoryUserDefaults</string>
17
+ <key>NSPrivacyAccessedAPITypeReasons</key>
18
+ <array>
19
+ <string>CA92.1</string>
20
+ </array>
21
+ </dict>
22
+ </array>
23
+ </dict>
24
+ </plist>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-task-manager",
3
- "version": "11.7.2",
3
+ "version": "11.8.0",
4
4
  "description": "Expo module that provides support for tasks that can run in the background.",
5
5
  "main": "build/TaskManager.js",
6
6
  "types": "build/TaskManager.d.ts",
@@ -33,7 +33,7 @@
33
33
  "license": "MIT",
34
34
  "homepage": "https://docs.expo.dev/versions/latest/sdk/task-manager/",
35
35
  "dependencies": {
36
- "unimodules-app-loader": "~4.5.0"
36
+ "unimodules-app-loader": "~4.6.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "expo-module-scripts": "^3.0.0"
@@ -41,5 +41,5 @@
41
41
  "peerDependencies": {
42
42
  "expo": "*"
43
43
  },
44
- "gitHead": "82b69cba5b2e967806ca03413c3277f1d53bff8d"
44
+ "gitHead": "4165b8d72e1b9a1889c2767534cc619e21468110"
45
45
  }
@@ -1,7 +1,4 @@
1
1
  export default {
2
- get name(): string {
3
- return 'ExpoTaskManager';
4
- },
5
2
  get EVENT_NAME(): string {
6
3
  return 'TaskManager.executeTask';
7
4
  },