expo-notifications 0.20.0 → 0.21.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,6 +10,16 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 0.21.0 — 2023-07-28
14
+
15
+ ### 💡 Others
16
+
17
+ - Fork `uuid@3.4.0` and move into `expo-modules-core`. Remove the original dependency. ([#23249](https://github.com/expo/expo/pull/23249) by [@alanhughes](https://github.com/alanjhughes))
18
+
19
+ ## 0.20.1 — 2023-06-24
20
+
21
+ _This version does not introduce any user-facing changes._
22
+
13
23
  ## 0.20.0 — 2023-06-21
14
24
 
15
25
  ### 🐛 Bug fixes
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
3
3
  apply plugin: 'maven-publish'
4
4
 
5
5
  group = 'host.exp.exponent'
6
- version = '0.20.0'
6
+ version = '0.21.0'
7
7
 
8
8
  buildscript {
9
9
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
@@ -67,7 +67,7 @@ android {
67
67
  minSdkVersion safeExtGet("minSdkVersion", 21)
68
68
  targetSdkVersion safeExtGet("targetSdkVersion", 33)
69
69
  versionCode 21
70
- versionName '0.20.0'
70
+ versionName '0.21.0'
71
71
  }
72
72
 
73
73
  lintOptions {
@@ -1 +1 @@
1
- {"version":3,"file":"ServerRegistrationModule.web.d.ts","sourceRoot":"","sources":["../src/ServerRegistrationModule.web.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;;AAW5E,wBAoC8B"}
1
+ {"version":3,"file":"ServerRegistrationModule.web.d.ts","sourceRoot":"","sources":["../src/ServerRegistrationModule.web.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;;AAW5E,wBAoC8B"}
@@ -1,5 +1,4 @@
1
- import { CodedError } from 'expo-modules-core';
2
- import { v4 as uuidv4 } from 'uuid';
1
+ import { CodedError, uuidv4 } from 'expo-modules-core';
3
2
  const INSTALLATION_ID_KEY = 'EXPO_NOTIFICATIONS_INSTALLATION_ID';
4
3
  const REGISTRATION_INFO_KEY = 'EXPO_NOTIFICATIONS_REGISTRATION_INFO';
5
4
  // Lazy fallback installationId per session initializer
@@ -1 +1 @@
1
- {"version":3,"file":"ServerRegistrationModule.web.js","sourceRoot":"","sources":["../src/ServerRegistrationModule.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAIpC,MAAM,mBAAmB,GAAG,oCAAoC,CAAC;AACjE,MAAM,qBAAqB,GAAG,sCAAsC,CAAC;AAErE,uDAAuD;AACvD,IAAI,yBAAyB,GAAG,GAAG,EAAE;IACnC,MAAM,qBAAqB,GAAG,MAAM,EAAE,CAAC;IACvC,yBAAyB,GAAG,GAAG,EAAE,CAAC,qBAAqB,CAAC;AAC1D,CAAC,CAAC;AAEF,eAAe;IACb,sBAAsB,EAAE,KAAK,IAAI,EAAE;QACjC,IAAI,cAAc,CAAC;QAEnB,IAAI;YACF,cAAc,GAAG,YAAY,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;YAC3D,IAAI,CAAC,cAAc,IAAI,OAAO,cAAc,KAAK,QAAQ,EAAE;gBACzD,cAAc,GAAG,MAAM,EAAE,CAAC;gBAC1B,YAAY,CAAC,OAAO,CAAC,mBAAmB,EAAE,cAAc,CAAC,CAAC;aAC3D;SACF;QAAC,MAAM;YACN,cAAc,GAAG,yBAAyB,EAAE,CAAC;SAC9C;QAED,OAAO,cAAc,CAAC;IACxB,CAAC;IACD,wBAAwB,EAAE,KAAK,IAAI,EAAE;QACnC,OAAO,YAAY,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACrD,CAAC;IACD,wBAAwB,EAAE,KAAK,EAAE,gBAA+B,EAAE,EAAE;QAClE,IAAI;YACF,IAAI,gBAAgB,EAAE;gBACpB,YAAY,CAAC,OAAO,CAAC,qBAAqB,EAAE,gBAAgB,CAAC,CAAC;aAC/D;iBAAM;gBACL,YAAY,CAAC,UAAU,CAAC,qBAAqB,CAAC,CAAC;aAChD;SACF;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,IAAI,UAAU,CAClB,iCAAiC,EACjC,2EAA2E,KAAK,EAAE,CACnF,CAAC;SACH;IACH,CAAC;IACD,uBAAuB;IACvB,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;IACrB,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;CACE,CAAC","sourcesContent":["import { CodedError } from 'expo-modules-core';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { ServerRegistrationModule } from './ServerRegistrationModule.types';\n\nconst INSTALLATION_ID_KEY = 'EXPO_NOTIFICATIONS_INSTALLATION_ID';\nconst REGISTRATION_INFO_KEY = 'EXPO_NOTIFICATIONS_REGISTRATION_INFO';\n\n// Lazy fallback installationId per session initializer\nlet getFallbackInstallationId = () => {\n const sessionInstallationId = uuidv4();\n getFallbackInstallationId = () => sessionInstallationId;\n};\n\nexport default {\n getInstallationIdAsync: async () => {\n let installationId;\n\n try {\n installationId = localStorage.getItem(INSTALLATION_ID_KEY);\n if (!installationId || typeof installationId !== 'string') {\n installationId = uuidv4();\n localStorage.setItem(INSTALLATION_ID_KEY, installationId);\n }\n } catch {\n installationId = getFallbackInstallationId();\n }\n\n return installationId;\n },\n getRegistrationInfoAsync: async () => {\n return localStorage.getItem(REGISTRATION_INFO_KEY);\n },\n setRegistrationInfoAsync: async (registrationInfo: string | null) => {\n try {\n if (registrationInfo) {\n localStorage.setItem(REGISTRATION_INFO_KEY, registrationInfo);\n } else {\n localStorage.removeItem(REGISTRATION_INFO_KEY);\n }\n } catch (error) {\n throw new CodedError(\n 'ERR_NOTIFICATIONS_STORAGE_ERROR',\n `Could not modify localStorage to persist auto-registration information: ${error}`\n );\n }\n },\n // mock implementations\n addListener: () => {},\n removeListeners: () => {},\n} as ServerRegistrationModule;\n"]}
1
+ {"version":3,"file":"ServerRegistrationModule.web.js","sourceRoot":"","sources":["../src/ServerRegistrationModule.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAIvD,MAAM,mBAAmB,GAAG,oCAAoC,CAAC;AACjE,MAAM,qBAAqB,GAAG,sCAAsC,CAAC;AAErE,uDAAuD;AACvD,IAAI,yBAAyB,GAAG,GAAG,EAAE;IACnC,MAAM,qBAAqB,GAAG,MAAM,EAAE,CAAC;IACvC,yBAAyB,GAAG,GAAG,EAAE,CAAC,qBAAqB,CAAC;AAC1D,CAAC,CAAC;AAEF,eAAe;IACb,sBAAsB,EAAE,KAAK,IAAI,EAAE;QACjC,IAAI,cAAc,CAAC;QAEnB,IAAI;YACF,cAAc,GAAG,YAAY,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;YAC3D,IAAI,CAAC,cAAc,IAAI,OAAO,cAAc,KAAK,QAAQ,EAAE;gBACzD,cAAc,GAAG,MAAM,EAAE,CAAC;gBAC1B,YAAY,CAAC,OAAO,CAAC,mBAAmB,EAAE,cAAc,CAAC,CAAC;aAC3D;SACF;QAAC,MAAM;YACN,cAAc,GAAG,yBAAyB,EAAE,CAAC;SAC9C;QAED,OAAO,cAAc,CAAC;IACxB,CAAC;IACD,wBAAwB,EAAE,KAAK,IAAI,EAAE;QACnC,OAAO,YAAY,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACrD,CAAC;IACD,wBAAwB,EAAE,KAAK,EAAE,gBAA+B,EAAE,EAAE;QAClE,IAAI;YACF,IAAI,gBAAgB,EAAE;gBACpB,YAAY,CAAC,OAAO,CAAC,qBAAqB,EAAE,gBAAgB,CAAC,CAAC;aAC/D;iBAAM;gBACL,YAAY,CAAC,UAAU,CAAC,qBAAqB,CAAC,CAAC;aAChD;SACF;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,IAAI,UAAU,CAClB,iCAAiC,EACjC,2EAA2E,KAAK,EAAE,CACnF,CAAC;SACH;IACH,CAAC;IACD,uBAAuB;IACvB,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;IACrB,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;CACE,CAAC","sourcesContent":["import { CodedError, uuidv4 } from 'expo-modules-core';\n\nimport { ServerRegistrationModule } from './ServerRegistrationModule.types';\n\nconst INSTALLATION_ID_KEY = 'EXPO_NOTIFICATIONS_INSTALLATION_ID';\nconst REGISTRATION_INFO_KEY = 'EXPO_NOTIFICATIONS_REGISTRATION_INFO';\n\n// Lazy fallback installationId per session initializer\nlet getFallbackInstallationId = () => {\n const sessionInstallationId = uuidv4();\n getFallbackInstallationId = () => sessionInstallationId;\n};\n\nexport default {\n getInstallationIdAsync: async () => {\n let installationId;\n\n try {\n installationId = localStorage.getItem(INSTALLATION_ID_KEY);\n if (!installationId || typeof installationId !== 'string') {\n installationId = uuidv4();\n localStorage.setItem(INSTALLATION_ID_KEY, installationId);\n }\n } catch {\n installationId = getFallbackInstallationId();\n }\n\n return installationId;\n },\n getRegistrationInfoAsync: async () => {\n return localStorage.getItem(REGISTRATION_INFO_KEY);\n },\n setRegistrationInfoAsync: async (registrationInfo: string | null) => {\n try {\n if (registrationInfo) {\n localStorage.setItem(REGISTRATION_INFO_KEY, registrationInfo);\n } else {\n localStorage.removeItem(REGISTRATION_INFO_KEY);\n }\n } catch (error) {\n throw new CodedError(\n 'ERR_NOTIFICATIONS_STORAGE_ERROR',\n `Could not modify localStorage to persist auto-registration information: ${error}`\n );\n }\n },\n // mock implementations\n addListener: () => {},\n removeListeners: () => {},\n} as ServerRegistrationModule;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"presentNotificationAsync.d.ts","sourceRoot":"","sources":["../src/presentNotificationAsync.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAIjE;;;;;;;GAOG;AACH,wBAA8B,wBAAwB,CACpD,OAAO,EAAE,wBAAwB,EACjC,UAAU,GAAE,MAAiB,GAC5B,OAAO,CAAC,MAAM,CAAC,CAajB"}
1
+ {"version":3,"file":"presentNotificationAsync.d.ts","sourceRoot":"","sources":["../src/presentNotificationAsync.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAIjE;;;;;;;GAOG;AACH,wBAA8B,wBAAwB,CACpD,OAAO,EAAE,wBAAwB,EACjC,UAAU,GAAE,MAAiB,GAC5B,OAAO,CAAC,MAAM,CAAC,CAajB"}
@@ -1,5 +1,4 @@
1
- import { UnavailabilityError } from 'expo-modules-core';
2
- import { v4 as uuidv4 } from 'uuid';
1
+ import { UnavailabilityError, uuidv4 } from 'expo-modules-core';
3
2
  import NotificationPresenter from './NotificationPresenterModule';
4
3
  let warningMessageShown = false;
5
4
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"presentNotificationAsync.js","sourceRoot":"","sources":["../src/presentNotificationAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,qBAAqB,MAAM,+BAA+B,CAAC;AAGlE,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAEhC;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,wBAAwB,CACpD,OAAiC,EACjC,aAAqB,MAAM,EAAE;IAE7B,IAAI,OAAO,IAAI,CAAC,mBAAmB,EAAE;QACnC,OAAO,CAAC,IAAI,CACV,qMAAqM,CACtM,CAAC;QACF,mBAAmB,GAAG,IAAI,CAAC;KAC5B;IAED,IAAI,CAAC,qBAAqB,CAAC,wBAAwB,EAAE;QACnD,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,0BAA0B,CAAC,CAAC;KAC5E;IAED,OAAO,MAAM,qBAAqB,CAAC,wBAAwB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AACnF,CAAC","sourcesContent":["import { UnavailabilityError } from 'expo-modules-core';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport NotificationPresenter from './NotificationPresenterModule';\nimport { NotificationContentInput } from './Notifications.types';\n\nlet warningMessageShown = false;\n\n/**\n * Schedules a notification for immediate trigger.\n * @param content An object representing the notification content.\n * @param identifier\n * @return It returns a Promise resolving with the notification's identifier once the notification is successfully scheduled for immediate display.\n * @header schedule\n * @deprecated This method has been deprecated in favor of using an explicit `NotificationHandler` and the [`scheduleNotificationAsync`](#notificationsschedulenotificationasyncrequest) method. More information can be found in our [FYI document](https://expo.fyi/presenting-notifications-deprecated).\n */\nexport default async function presentNotificationAsync(\n content: NotificationContentInput,\n identifier: string = uuidv4()\n): Promise<string> {\n if (__DEV__ && !warningMessageShown) {\n console.warn(\n '`presentNotificationAsync` has been deprecated in favor of using `scheduleNotificationAsync` + an explicit notification handler. Read more at https://expo.fyi/presenting-notifications-deprecated.'\n );\n warningMessageShown = true;\n }\n\n if (!NotificationPresenter.presentNotificationAsync) {\n throw new UnavailabilityError('Notifications', 'presentNotificationAsync');\n }\n\n return await NotificationPresenter.presentNotificationAsync(identifier, content);\n}\n"]}
1
+ {"version":3,"file":"presentNotificationAsync.js","sourceRoot":"","sources":["../src/presentNotificationAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhE,OAAO,qBAAqB,MAAM,+BAA+B,CAAC;AAGlE,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAEhC;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,wBAAwB,CACpD,OAAiC,EACjC,aAAqB,MAAM,EAAE;IAE7B,IAAI,OAAO,IAAI,CAAC,mBAAmB,EAAE;QACnC,OAAO,CAAC,IAAI,CACV,qMAAqM,CACtM,CAAC;QACF,mBAAmB,GAAG,IAAI,CAAC;KAC5B;IAED,IAAI,CAAC,qBAAqB,CAAC,wBAAwB,EAAE;QACnD,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,0BAA0B,CAAC,CAAC;KAC5E;IAED,OAAO,MAAM,qBAAqB,CAAC,wBAAwB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AACnF,CAAC","sourcesContent":["import { UnavailabilityError, uuidv4 } from 'expo-modules-core';\n\nimport NotificationPresenter from './NotificationPresenterModule';\nimport { NotificationContentInput } from './Notifications.types';\n\nlet warningMessageShown = false;\n\n/**\n * Schedules a notification for immediate trigger.\n * @param content An object representing the notification content.\n * @param identifier\n * @return It returns a Promise resolving with the notification's identifier once the notification is successfully scheduled for immediate display.\n * @header schedule\n * @deprecated This method has been deprecated in favor of using an explicit `NotificationHandler` and the [`scheduleNotificationAsync`](#notificationsschedulenotificationasyncrequest) method. More information can be found in our [FYI document](https://expo.fyi/presenting-notifications-deprecated).\n */\nexport default async function presentNotificationAsync(\n content: NotificationContentInput,\n identifier: string = uuidv4()\n): Promise<string> {\n if (__DEV__ && !warningMessageShown) {\n console.warn(\n '`presentNotificationAsync` has been deprecated in favor of using `scheduleNotificationAsync` + an explicit notification handler. Read more at https://expo.fyi/presenting-notifications-deprecated.'\n );\n warningMessageShown = true;\n }\n\n if (!NotificationPresenter.presentNotificationAsync) {\n throw new UnavailabilityError('Notifications', 'presentNotificationAsync');\n }\n\n return await NotificationPresenter.presentNotificationAsync(identifier, content);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"scheduleNotificationAsync.d.ts","sourceRoot":"","sources":["../src/scheduleNotificationAsync.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,IAAI,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AAC3G,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EASzB,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,wBAA8B,yBAAyB,CACrD,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,MAAM,CAAC,CAUjB;AAoBD,wBAAgB,YAAY,CAC1B,iBAAiB,EAAE,wBAAwB,GAC1C,8BAA8B,CA4DhC"}
1
+ {"version":3,"file":"scheduleNotificationAsync.d.ts","sourceRoot":"","sources":["../src/scheduleNotificationAsync.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,wBAAwB,IAAI,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AAC3G,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EASzB,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,wBAA8B,yBAAyB,CACrD,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,MAAM,CAAC,CAUjB;AAoBD,wBAAgB,YAAY,CAC1B,iBAAiB,EAAE,wBAAwB,GAC1C,8BAA8B,CA4DhC"}
@@ -1,5 +1,4 @@
1
- import { Platform, UnavailabilityError } from 'expo-modules-core';
2
- import { v4 as uuidv4 } from 'uuid';
1
+ import { Platform, UnavailabilityError, uuidv4 } from 'expo-modules-core';
3
2
  import NotificationScheduler from './NotificationScheduler';
4
3
  /**
5
4
  * Schedules a notification to be triggered in the future.
@@ -1 +1 @@
1
- {"version":3,"file":"scheduleNotificationAsync.js","sourceRoot":"","sources":["../src/scheduleNotificationAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAe5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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B,YAAY,GAAG,EAAE,CAChG,CAAC;iBACH;gBACD,MAAM;aACP;YACD,KAAK,SAAS,CAAC,CAAC;gBACd,MAAM,EAAE,OAAO,EAAE,GAAG,cAAc,CAAC;gBACnC,IAAI,OAAO,GAAG,CAAC,IAAI,OAAO,GAAG,CAAC,EAAE;oBAC9B,MAAM,IAAI,UAAU,CAClB,6DAA6D,OAAO,EAAE,CACvE,CAAC;iBACH;gBACD,MAAM;aACP;YACD,KAAK,MAAM,CAAC,CAAC;gBACX,MAAM,EAAE,IAAI,EAAE,GAAG,cAAc,CAAC;gBAChC,IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,EAAE,EAAE;oBACzB,MAAM,IAAI,UAAU,CAAC,2DAA2D,IAAI,EAAE,CAAC,CAAC;iBACzF;gBACD,MAAM;aACP;YACD,KAAK,QAAQ,CAAC,CAAC;gBACb,MAAM,EAAE,MAAM,EAAE,GAAG,cAAc,CAAC;gBAClC,IAAI,MAAM,GAAG,CAAC,IAAI,MAAM,GAAG,EAAE,EAAE;oBAC7B,MAAM,IAAI,UAAU,CAClB,6DAA6D,MAAM,EAAE,CACtE,CAAC;iBACH;gBACD,MAAM;aACP;SACF;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,SAAS,WAAW,CAAC,QAAgB,CAAC,EAAE,IAAa;IACnD,OAAO,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;AACxD,CAAC","sourcesContent":["import { Platform, UnavailabilityError } from 'expo-modules-core';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport NotificationScheduler from './NotificationScheduler';\nimport { NotificationTriggerInput as NativeNotificationTriggerInput } from './NotificationScheduler.types';\nimport {\n NotificationRequestInput,\n NotificationTriggerInput,\n DailyTriggerInput,\n WeeklyTriggerInput,\n YearlyTriggerInput,\n CalendarTriggerInput,\n TimeIntervalTriggerInput,\n DateTriggerInput,\n ChannelAwareTriggerInput,\n SchedulableNotificationTriggerInput,\n} from './Notifications.types';\n\n/**\n * Schedules a notification to be triggered in the future.\n * > **Note:** Please note that this does not mean that the notification will be presented when it is triggered.\n * For the notification to be presented you have to set a notification handler with [`setNotificationHandler`](#notificationssetnotificationhandlerhandler)\n * that will return an appropriate notification behavior. For more information see the example below.\n * @param request An object describing the notification to be triggered.\n * @return Returns a Promise resolving to a string which is a notification identifier you can later use to cancel the notification or to identify an incoming notification.\n * @example\n * # Schedule the notification that will trigger once, in one minute from now\n * ```ts\n * import * as Notifications from 'expo-notifications';\n *\n * Notifications.scheduleNotificationAsync({\n * content: {\n * title: \"Time's up!\",\n * body: 'Change sides!',\n * },\n * trigger: {\n * seconds: 60,\n * },\n * });\n * ```\n *\n * # Schedule the notification that will trigger repeatedly, every 20 minutes\n * ```ts\n * import * as Notifications from 'expo-notifications';\n *\n * Notifications.scheduleNotificationAsync({\n * content: {\n * title: 'Remember to drink water!',\n * },\n * trigger: {\n * seconds: 60 * 20,\n * repeats: true,\n * },\n * });\n * ```\n *\n * # Schedule the notification that will trigger once, at the beginning of next hour\n * ```ts\n * import * as Notifications from 'expo-notifications';\n *\n * const trigger = new Date(Date.now() + 60 * 60 * 1000);\n * trigger.setMinutes(0);\n * trigger.setSeconds(0);\n *\n * Notifications.scheduleNotificationAsync({\n * content: {\n * title: 'Happy new hour!',\n * },\n * trigger,\n * });\n * ```\n * @header schedule\n */\nexport default async function scheduleNotificationAsync(\n request: NotificationRequestInput\n): Promise<string> {\n if (!NotificationScheduler.scheduleNotificationAsync) {\n throw new UnavailabilityError('Notifications', 'scheduleNotificationAsync');\n }\n\n return await NotificationScheduler.scheduleNotificationAsync(\n request.identifier ?? uuidv4(),\n request.content,\n parseTrigger(request.trigger)\n );\n}\n\ntype ValidTriggerDateComponents = 'month' | 'day' | 'weekday' | 'hour' | 'minute';\n\nconst DAILY_TRIGGER_EXPECTED_DATE_COMPONENTS: readonly ValidTriggerDateComponents[] = [\n 'hour',\n 'minute',\n];\nconst WEEKLY_TRIGGER_EXPECTED_DATE_COMPONENTS: readonly ValidTriggerDateComponents[] = [\n 'weekday',\n 'hour',\n 'minute',\n];\nconst YEARLY_TRIGGER_EXPECTED_DATE_COMPONENTS: readonly ValidTriggerDateComponents[] = [\n 'day',\n 'month',\n 'hour',\n 'minute',\n];\n\nexport function parseTrigger(\n userFacingTrigger: NotificationTriggerInput\n): NativeNotificationTriggerInput {\n if (userFacingTrigger === null) {\n return null;\n }\n\n if (userFacingTrigger === undefined) {\n throw new TypeError(\n 'Encountered an `undefined` notification trigger. If you want to trigger the notification immediately, pass in an explicit `null` value.'\n );\n }\n\n if (isDateTrigger(userFacingTrigger)) {\n return parseDateTrigger(userFacingTrigger);\n } else if (isDailyTriggerInput(userFacingTrigger)) {\n validateDateComponentsInTrigger(userFacingTrigger, DAILY_TRIGGER_EXPECTED_DATE_COMPONENTS);\n return {\n type: 'daily',\n channelId: userFacingTrigger.channelId,\n hour: userFacingTrigger.hour,\n minute: userFacingTrigger.minute,\n };\n } else if (isWeeklyTriggerInput(userFacingTrigger)) {\n validateDateComponentsInTrigger(userFacingTrigger, WEEKLY_TRIGGER_EXPECTED_DATE_COMPONENTS);\n return {\n type: 'weekly',\n channelId: userFacingTrigger.channelId,\n weekday: userFacingTrigger.weekday,\n hour: userFacingTrigger.hour,\n minute: userFacingTrigger.minute,\n };\n } else if (isYearlyTriggerInput(userFacingTrigger)) {\n validateDateComponentsInTrigger(userFacingTrigger, YEARLY_TRIGGER_EXPECTED_DATE_COMPONENTS);\n return {\n type: 'yearly',\n channelId: userFacingTrigger.channelId,\n day: userFacingTrigger.day,\n month: userFacingTrigger.month,\n hour: userFacingTrigger.hour,\n minute: userFacingTrigger.minute,\n };\n } else if (isSecondsPropertyMisusedInCalendarTriggerInput(userFacingTrigger)) {\n throw new TypeError(\n 'Could not have inferred the notification trigger type: if you want to use a time interval trigger, pass in only `seconds` with or without `repeats` property; if you want to use calendar-based trigger, pass in `second`.'\n );\n } else if ('seconds' in userFacingTrigger) {\n return {\n type: 'timeInterval',\n channelId: userFacingTrigger.channelId,\n seconds: userFacingTrigger.seconds,\n repeats: userFacingTrigger.repeats ?? false,\n };\n } else if (isCalendarTrigger(userFacingTrigger)) {\n const { repeats, ...calendarTrigger } = userFacingTrigger;\n return { type: 'calendar', value: calendarTrigger, repeats };\n } else {\n return Platform.select({\n default: null, // There's no notion of channels on platforms other than Android.\n android: { type: 'channel', channelId: userFacingTrigger.channelId },\n });\n }\n}\n\nfunction isCalendarTrigger(\n trigger: CalendarTriggerInput | ChannelAwareTriggerInput\n): trigger is CalendarTriggerInput {\n const { channelId, ...triggerWithoutChannelId } = trigger;\n return Object.keys(triggerWithoutChannelId).length > 0;\n}\n\nfunction isDateTrigger(\n trigger:\n | DateTriggerInput\n | WeeklyTriggerInput\n | DailyTriggerInput\n | CalendarTriggerInput\n | TimeIntervalTriggerInput\n): trigger is DateTriggerInput {\n return (\n trigger instanceof Date ||\n typeof trigger === 'number' ||\n (typeof trigger === 'object' && 'date' in trigger)\n );\n}\n\nfunction parseDateTrigger(trigger: DateTriggerInput): NativeNotificationTriggerInput {\n if (trigger instanceof Date || typeof trigger === 'number') {\n return { type: 'date', timestamp: toTimestamp(trigger) };\n }\n return { type: 'date', timestamp: toTimestamp(trigger.date), channelId: trigger.channelId };\n}\n\nfunction toTimestamp(date: number | Date) {\n if (date instanceof Date) {\n return date.getTime();\n }\n return date;\n}\n\nfunction isDailyTriggerInput(\n trigger: SchedulableNotificationTriggerInput\n): trigger is DailyTriggerInput {\n if (typeof trigger !== 'object') return false;\n const { channelId, ...triggerWithoutChannelId } = trigger as DailyTriggerInput;\n return (\n Object.keys(triggerWithoutChannelId).length ===\n DAILY_TRIGGER_EXPECTED_DATE_COMPONENTS.length + 1 &&\n DAILY_TRIGGER_EXPECTED_DATE_COMPONENTS.every(\n (component) => component in triggerWithoutChannelId\n ) &&\n 'repeats' in triggerWithoutChannelId &&\n triggerWithoutChannelId.repeats === true\n );\n}\n\nfunction isWeeklyTriggerInput(\n trigger: SchedulableNotificationTriggerInput\n): trigger is WeeklyTriggerInput {\n if (typeof trigger !== 'object') return false;\n const { channelId, ...triggerWithoutChannelId } = trigger as WeeklyTriggerInput;\n return (\n Object.keys(triggerWithoutChannelId).length ===\n WEEKLY_TRIGGER_EXPECTED_DATE_COMPONENTS.length + 1 &&\n WEEKLY_TRIGGER_EXPECTED_DATE_COMPONENTS.every(\n (component) => component in triggerWithoutChannelId\n ) &&\n 'repeats' in triggerWithoutChannelId &&\n triggerWithoutChannelId.repeats === true\n );\n}\n\nfunction isYearlyTriggerInput(\n trigger: SchedulableNotificationTriggerInput\n): trigger is YearlyTriggerInput {\n if (typeof trigger !== 'object') return false;\n const { channelId, ...triggerWithoutChannelId } = trigger as YearlyTriggerInput;\n return (\n Object.keys(triggerWithoutChannelId).length ===\n YEARLY_TRIGGER_EXPECTED_DATE_COMPONENTS.length + 1 &&\n YEARLY_TRIGGER_EXPECTED_DATE_COMPONENTS.every(\n (component) => component in triggerWithoutChannelId\n ) &&\n 'repeats' in triggerWithoutChannelId &&\n triggerWithoutChannelId.repeats === true\n );\n}\n\nfunction isSecondsPropertyMisusedInCalendarTriggerInput(\n trigger: TimeIntervalTriggerInput | CalendarTriggerInput\n) {\n const { channelId, ...triggerWithoutChannelId } = trigger;\n return (\n // eg. { seconds: ..., repeats: ..., hour: ... }\n ('seconds' in triggerWithoutChannelId &&\n 'repeats' in triggerWithoutChannelId &&\n Object.keys(triggerWithoutChannelId).length > 2) ||\n // eg. { seconds: ..., hour: ... }\n ('seconds' in triggerWithoutChannelId &&\n !('repeats' in triggerWithoutChannelId) &&\n Object.keys(triggerWithoutChannelId).length > 1)\n );\n}\n\nfunction validateDateComponentsInTrigger(\n trigger: NonNullable<NotificationTriggerInput>,\n components: readonly ValidTriggerDateComponents[]\n) {\n const anyTriggerType = trigger as any;\n components.forEach((component) => {\n if (!(component in anyTriggerType)) {\n throw new TypeError(`The ${component} parameter needs to be present`);\n }\n if (typeof anyTriggerType[component] !== 'number') {\n throw new TypeError(`The ${component} parameter should be a number`);\n }\n switch (component) {\n case 'month': {\n const { month } = anyTriggerType;\n if (month < 0 || month > 11) {\n throw new RangeError(`The month parameter needs to be between 0 and 11. Found: ${month}`);\n }\n break;\n }\n case 'day': {\n const { day, month } = anyTriggerType;\n const daysInGivenMonth = daysInMonth(month);\n if (day < 1 || day > daysInGivenMonth) {\n throw new RangeError(\n `The day parameter for month ${month} must be between 1 and ${daysInGivenMonth}. Found: ${day}`\n );\n }\n break;\n }\n case 'weekday': {\n const { weekday } = anyTriggerType;\n if (weekday < 1 || weekday > 7) {\n throw new RangeError(\n `The weekday parameter needs to be between 1 and 7. Found: ${weekday}`\n );\n }\n break;\n }\n case 'hour': {\n const { hour } = anyTriggerType;\n if (hour < 0 || hour > 23) {\n throw new RangeError(`The hour parameter needs to be between 0 and 23. Found: ${hour}`);\n }\n break;\n }\n case 'minute': {\n const { minute } = anyTriggerType;\n if (minute < 0 || minute > 59) {\n throw new RangeError(\n `The minute parameter needs to be between 0 and 59. Found: ${minute}`\n );\n }\n break;\n }\n }\n });\n}\n\n/**\n * Determines the number of days in the given month (or January if omitted).\n * If year is specified, it will include leap year logic, else it will always assume a leap year\n */\nfunction daysInMonth(month: number = 0, year?: number) {\n return new Date(year ?? 2000, month + 1, 0).getDate();\n}\n"]}
1
+ {"version":3,"file":"scheduleNotificationAsync.js","sourceRoot":"","sources":["../src/scheduleNotificationAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE1E,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAe5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,yBAAyB,CACrD,OAAiC;IAEjC,IAAI,CAAC,qBAA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GAAG,cAAc,CAAC;gBACnC,IAAI,OAAO,GAAG,CAAC,IAAI,OAAO,GAAG,CAAC,EAAE;oBAC9B,MAAM,IAAI,UAAU,CAClB,6DAA6D,OAAO,EAAE,CACvE,CAAC;iBACH;gBACD,MAAM;aACP;YACD,KAAK,MAAM,CAAC,CAAC;gBACX,MAAM,EAAE,IAAI,EAAE,GAAG,cAAc,CAAC;gBAChC,IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,EAAE,EAAE;oBACzB,MAAM,IAAI,UAAU,CAAC,2DAA2D,IAAI,EAAE,CAAC,CAAC;iBACzF;gBACD,MAAM;aACP;YACD,KAAK,QAAQ,CAAC,CAAC;gBACb,MAAM,EAAE,MAAM,EAAE,GAAG,cAAc,CAAC;gBAClC,IAAI,MAAM,GAAG,CAAC,IAAI,MAAM,GAAG,EAAE,EAAE;oBAC7B,MAAM,IAAI,UAAU,CAClB,6DAA6D,MAAM,EAAE,CACtE,CAAC;iBACH;gBACD,MAAM;aACP;SACF;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,SAAS,WAAW,CAAC,QAAgB,CAAC,EAAE,IAAa;IACnD,OAAO,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;AACxD,CAAC","sourcesContent":["import { Platform, UnavailabilityError, uuidv4 } from 'expo-modules-core';\n\nimport NotificationScheduler from './NotificationScheduler';\nimport { NotificationTriggerInput as NativeNotificationTriggerInput } from './NotificationScheduler.types';\nimport {\n NotificationRequestInput,\n NotificationTriggerInput,\n DailyTriggerInput,\n WeeklyTriggerInput,\n YearlyTriggerInput,\n CalendarTriggerInput,\n TimeIntervalTriggerInput,\n DateTriggerInput,\n ChannelAwareTriggerInput,\n SchedulableNotificationTriggerInput,\n} from './Notifications.types';\n\n/**\n * Schedules a notification to be triggered in the future.\n * > **Note:** Please note that this does not mean that the notification will be presented when it is triggered.\n * For the notification to be presented you have to set a notification handler with [`setNotificationHandler`](#notificationssetnotificationhandlerhandler)\n * that will return an appropriate notification behavior. For more information see the example below.\n * @param request An object describing the notification to be triggered.\n * @return Returns a Promise resolving to a string which is a notification identifier you can later use to cancel the notification or to identify an incoming notification.\n * @example\n * # Schedule the notification that will trigger once, in one minute from now\n * ```ts\n * import * as Notifications from 'expo-notifications';\n *\n * Notifications.scheduleNotificationAsync({\n * content: {\n * title: \"Time's up!\",\n * body: 'Change sides!',\n * },\n * trigger: {\n * seconds: 60,\n * },\n * });\n * ```\n *\n * # Schedule the notification that will trigger repeatedly, every 20 minutes\n * ```ts\n * import * as Notifications from 'expo-notifications';\n *\n * Notifications.scheduleNotificationAsync({\n * content: {\n * title: 'Remember to drink water!',\n * },\n * trigger: {\n * seconds: 60 * 20,\n * repeats: true,\n * },\n * });\n * ```\n *\n * # Schedule the notification that will trigger once, at the beginning of next hour\n * ```ts\n * import * as Notifications from 'expo-notifications';\n *\n * const trigger = new Date(Date.now() + 60 * 60 * 1000);\n * trigger.setMinutes(0);\n * trigger.setSeconds(0);\n *\n * Notifications.scheduleNotificationAsync({\n * content: {\n * title: 'Happy new hour!',\n * },\n * trigger,\n * });\n * ```\n * @header schedule\n */\nexport default async function scheduleNotificationAsync(\n request: NotificationRequestInput\n): Promise<string> {\n if (!NotificationScheduler.scheduleNotificationAsync) {\n throw new UnavailabilityError('Notifications', 'scheduleNotificationAsync');\n }\n\n return await NotificationScheduler.scheduleNotificationAsync(\n request.identifier ?? uuidv4(),\n request.content,\n parseTrigger(request.trigger)\n );\n}\n\ntype ValidTriggerDateComponents = 'month' | 'day' | 'weekday' | 'hour' | 'minute';\n\nconst DAILY_TRIGGER_EXPECTED_DATE_COMPONENTS: readonly ValidTriggerDateComponents[] = [\n 'hour',\n 'minute',\n];\nconst WEEKLY_TRIGGER_EXPECTED_DATE_COMPONENTS: readonly ValidTriggerDateComponents[] = [\n 'weekday',\n 'hour',\n 'minute',\n];\nconst YEARLY_TRIGGER_EXPECTED_DATE_COMPONENTS: readonly ValidTriggerDateComponents[] = [\n 'day',\n 'month',\n 'hour',\n 'minute',\n];\n\nexport function parseTrigger(\n userFacingTrigger: NotificationTriggerInput\n): NativeNotificationTriggerInput {\n if (userFacingTrigger === null) {\n return null;\n }\n\n if (userFacingTrigger === undefined) {\n throw new TypeError(\n 'Encountered an `undefined` notification trigger. If you want to trigger the notification immediately, pass in an explicit `null` value.'\n );\n }\n\n if (isDateTrigger(userFacingTrigger)) {\n return parseDateTrigger(userFacingTrigger);\n } else if (isDailyTriggerInput(userFacingTrigger)) {\n validateDateComponentsInTrigger(userFacingTrigger, DAILY_TRIGGER_EXPECTED_DATE_COMPONENTS);\n return {\n type: 'daily',\n channelId: userFacingTrigger.channelId,\n hour: userFacingTrigger.hour,\n minute: userFacingTrigger.minute,\n };\n } else if (isWeeklyTriggerInput(userFacingTrigger)) {\n validateDateComponentsInTrigger(userFacingTrigger, WEEKLY_TRIGGER_EXPECTED_DATE_COMPONENTS);\n return {\n type: 'weekly',\n channelId: userFacingTrigger.channelId,\n weekday: userFacingTrigger.weekday,\n hour: userFacingTrigger.hour,\n minute: userFacingTrigger.minute,\n };\n } else if (isYearlyTriggerInput(userFacingTrigger)) {\n validateDateComponentsInTrigger(userFacingTrigger, YEARLY_TRIGGER_EXPECTED_DATE_COMPONENTS);\n return {\n type: 'yearly',\n channelId: userFacingTrigger.channelId,\n day: userFacingTrigger.day,\n month: userFacingTrigger.month,\n hour: userFacingTrigger.hour,\n minute: userFacingTrigger.minute,\n };\n } else if (isSecondsPropertyMisusedInCalendarTriggerInput(userFacingTrigger)) {\n throw new TypeError(\n 'Could not have inferred the notification trigger type: if you want to use a time interval trigger, pass in only `seconds` with or without `repeats` property; if you want to use calendar-based trigger, pass in `second`.'\n );\n } else if ('seconds' in userFacingTrigger) {\n return {\n type: 'timeInterval',\n channelId: userFacingTrigger.channelId,\n seconds: userFacingTrigger.seconds,\n repeats: userFacingTrigger.repeats ?? false,\n };\n } else if (isCalendarTrigger(userFacingTrigger)) {\n const { repeats, ...calendarTrigger } = userFacingTrigger;\n return { type: 'calendar', value: calendarTrigger, repeats };\n } else {\n return Platform.select({\n default: null, // There's no notion of channels on platforms other than Android.\n android: { type: 'channel', channelId: userFacingTrigger.channelId },\n });\n }\n}\n\nfunction isCalendarTrigger(\n trigger: CalendarTriggerInput | ChannelAwareTriggerInput\n): trigger is CalendarTriggerInput {\n const { channelId, ...triggerWithoutChannelId } = trigger;\n return Object.keys(triggerWithoutChannelId).length > 0;\n}\n\nfunction isDateTrigger(\n trigger:\n | DateTriggerInput\n | WeeklyTriggerInput\n | DailyTriggerInput\n | CalendarTriggerInput\n | TimeIntervalTriggerInput\n): trigger is DateTriggerInput {\n return (\n trigger instanceof Date ||\n typeof trigger === 'number' ||\n (typeof trigger === 'object' && 'date' in trigger)\n );\n}\n\nfunction parseDateTrigger(trigger: DateTriggerInput): NativeNotificationTriggerInput {\n if (trigger instanceof Date || typeof trigger === 'number') {\n return { type: 'date', timestamp: toTimestamp(trigger) };\n }\n return { type: 'date', timestamp: toTimestamp(trigger.date), channelId: trigger.channelId };\n}\n\nfunction toTimestamp(date: number | Date) {\n if (date instanceof Date) {\n return date.getTime();\n }\n return date;\n}\n\nfunction isDailyTriggerInput(\n trigger: SchedulableNotificationTriggerInput\n): trigger is DailyTriggerInput {\n if (typeof trigger !== 'object') return false;\n const { channelId, ...triggerWithoutChannelId } = trigger as DailyTriggerInput;\n return (\n Object.keys(triggerWithoutChannelId).length ===\n DAILY_TRIGGER_EXPECTED_DATE_COMPONENTS.length + 1 &&\n DAILY_TRIGGER_EXPECTED_DATE_COMPONENTS.every(\n (component) => component in triggerWithoutChannelId\n ) &&\n 'repeats' in triggerWithoutChannelId &&\n triggerWithoutChannelId.repeats === true\n );\n}\n\nfunction isWeeklyTriggerInput(\n trigger: SchedulableNotificationTriggerInput\n): trigger is WeeklyTriggerInput {\n if (typeof trigger !== 'object') return false;\n const { channelId, ...triggerWithoutChannelId } = trigger as WeeklyTriggerInput;\n return (\n Object.keys(triggerWithoutChannelId).length ===\n WEEKLY_TRIGGER_EXPECTED_DATE_COMPONENTS.length + 1 &&\n WEEKLY_TRIGGER_EXPECTED_DATE_COMPONENTS.every(\n (component) => component in triggerWithoutChannelId\n ) &&\n 'repeats' in triggerWithoutChannelId &&\n triggerWithoutChannelId.repeats === true\n );\n}\n\nfunction isYearlyTriggerInput(\n trigger: SchedulableNotificationTriggerInput\n): trigger is YearlyTriggerInput {\n if (typeof trigger !== 'object') return false;\n const { channelId, ...triggerWithoutChannelId } = trigger as YearlyTriggerInput;\n return (\n Object.keys(triggerWithoutChannelId).length ===\n YEARLY_TRIGGER_EXPECTED_DATE_COMPONENTS.length + 1 &&\n YEARLY_TRIGGER_EXPECTED_DATE_COMPONENTS.every(\n (component) => component in triggerWithoutChannelId\n ) &&\n 'repeats' in triggerWithoutChannelId &&\n triggerWithoutChannelId.repeats === true\n );\n}\n\nfunction isSecondsPropertyMisusedInCalendarTriggerInput(\n trigger: TimeIntervalTriggerInput | CalendarTriggerInput\n) {\n const { channelId, ...triggerWithoutChannelId } = trigger;\n return (\n // eg. { seconds: ..., repeats: ..., hour: ... }\n ('seconds' in triggerWithoutChannelId &&\n 'repeats' in triggerWithoutChannelId &&\n Object.keys(triggerWithoutChannelId).length > 2) ||\n // eg. { seconds: ..., hour: ... }\n ('seconds' in triggerWithoutChannelId &&\n !('repeats' in triggerWithoutChannelId) &&\n Object.keys(triggerWithoutChannelId).length > 1)\n );\n}\n\nfunction validateDateComponentsInTrigger(\n trigger: NonNullable<NotificationTriggerInput>,\n components: readonly ValidTriggerDateComponents[]\n) {\n const anyTriggerType = trigger as any;\n components.forEach((component) => {\n if (!(component in anyTriggerType)) {\n throw new TypeError(`The ${component} parameter needs to be present`);\n }\n if (typeof anyTriggerType[component] !== 'number') {\n throw new TypeError(`The ${component} parameter should be a number`);\n }\n switch (component) {\n case 'month': {\n const { month } = anyTriggerType;\n if (month < 0 || month > 11) {\n throw new RangeError(`The month parameter needs to be between 0 and 11. Found: ${month}`);\n }\n break;\n }\n case 'day': {\n const { day, month } = anyTriggerType;\n const daysInGivenMonth = daysInMonth(month);\n if (day < 1 || day > daysInGivenMonth) {\n throw new RangeError(\n `The day parameter for month ${month} must be between 1 and ${daysInGivenMonth}. Found: ${day}`\n );\n }\n break;\n }\n case 'weekday': {\n const { weekday } = anyTriggerType;\n if (weekday < 1 || weekday > 7) {\n throw new RangeError(\n `The weekday parameter needs to be between 1 and 7. Found: ${weekday}`\n );\n }\n break;\n }\n case 'hour': {\n const { hour } = anyTriggerType;\n if (hour < 0 || hour > 23) {\n throw new RangeError(`The hour parameter needs to be between 0 and 23. Found: ${hour}`);\n }\n break;\n }\n case 'minute': {\n const { minute } = anyTriggerType;\n if (minute < 0 || minute > 59) {\n throw new RangeError(\n `The minute parameter needs to be between 0 and 59. Found: ${minute}`\n );\n }\n break;\n }\n }\n });\n}\n\n/**\n * Determines the number of days in the given month (or January if omitted).\n * If year is specified, it will include leap year logic, else it will always assume a leap year\n */\nfunction daysInMonth(month: number = 0, year?: number) {\n return new Date(year ?? 2000, month + 1, 0).getDate();\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-notifications",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "description": "Notifications module",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -43,7 +43,7 @@
43
43
  "assert": "^2.0.0",
44
44
  "badgin": "^1.1.5",
45
45
  "expo-application": "~5.3.0",
46
- "expo-constants": "~14.4.0",
46
+ "expo-constants": "~14.5.0",
47
47
  "fs-extra": "^9.1.0",
48
48
  "uuid": "^3.4.0"
49
49
  },
@@ -57,5 +57,5 @@
57
57
  "peerDependencies": {
58
58
  "expo": "*"
59
59
  },
60
- "gitHead": "fa5ecca8251986b9f197cc14074eec0ab6dfb6db"
60
+ "gitHead": "663654577a7068c641b5e9474efbc502e3f334ea"
61
61
  }
@@ -1,5 +1,4 @@
1
- import { CodedError } from 'expo-modules-core';
2
- import { v4 as uuidv4 } from 'uuid';
1
+ import { CodedError, uuidv4 } from 'expo-modules-core';
3
2
 
4
3
  import { ServerRegistrationModule } from './ServerRegistrationModule.types';
5
4
 
@@ -1,5 +1,4 @@
1
- import { UnavailabilityError } from 'expo-modules-core';
2
- import { v4 as uuidv4 } from 'uuid';
1
+ import { UnavailabilityError, uuidv4 } from 'expo-modules-core';
3
2
 
4
3
  import NotificationPresenter from './NotificationPresenterModule';
5
4
  import { NotificationContentInput } from './Notifications.types';
@@ -1,5 +1,4 @@
1
- import { Platform, UnavailabilityError } from 'expo-modules-core';
2
- import { v4 as uuidv4 } from 'uuid';
1
+ import { Platform, UnavailabilityError, uuidv4 } from 'expo-modules-core';
3
2
 
4
3
  import NotificationScheduler from './NotificationScheduler';
5
4
  import { NotificationTriggerInput as NativeNotificationTriggerInput } from './NotificationScheduler.types';