expo-notifications 0.29.7 → 0.29.8

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,10 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 0.29.8 — 2024-11-14
14
+
15
+ _This version does not introduce any user-facing changes._
16
+
13
17
  ## 0.29.7 — 2024-11-13
14
18
 
15
19
  _This version does not introduce any user-facing changes._
@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
2
2
  apply plugin: 'kotlin-parcelize'
3
3
 
4
4
  group = 'host.exp.exponent'
5
- version = '0.29.7'
5
+ version = '0.29.8'
6
6
 
7
7
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
8
8
  apply from: expoModulesCorePlugin
@@ -15,7 +15,7 @@ android {
15
15
  namespace "expo.modules.notifications"
16
16
  defaultConfig {
17
17
  versionCode 21
18
- versionName '0.29.7'
18
+ versionName '0.29.8'
19
19
  testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
20
20
  }
21
21
 
@@ -18,6 +18,7 @@ import { NotificationRequestInput, NotificationTriggerInput } from './Notificati
18
18
  * body: 'Change sides!',
19
19
  * },
20
20
  * trigger: {
21
+ * type: SchedulableTriggerInputTypes.TIME_INTERVAL,
21
22
  * seconds: 60,
22
23
  * },
23
24
  * });
@@ -32,6 +33,7 @@ import { NotificationRequestInput, NotificationTriggerInput } from './Notificati
32
33
  * title: 'Remember to drink water!',
33
34
  * },
34
35
  * trigger: {
36
+ * type: SchedulableTriggerInputTypes.TIME_INTERVAL,
35
37
  * seconds: 60 * 20,
36
38
  * repeats: true,
37
39
  * },
@@ -1 +1 @@
1
- {"version":3,"file":"scheduleNotificationAsync.d.ts","sourceRoot":"","sources":["../src/scheduleNotificationAsync.ts"],"names":[],"mappings":"AAGA,OAAO,EAIL,8BAA8B,EAK/B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EAEzB,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,wBAA8B,yBAAyB,CACrD,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,MAAM,CAAC,CAUjB;AAID,wBAAgB,YAAY,CAC1B,iBAAiB,EAAE,wBAAwB,GAC1C,8BAA8B,CAmDhC"}
1
+ {"version":3,"file":"scheduleNotificationAsync.d.ts","sourceRoot":"","sources":["../src/scheduleNotificationAsync.ts"],"names":[],"mappings":"AAGA,OAAO,EAIL,8BAA8B,EAK/B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EAEzB,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAA8B,yBAAyB,CACrD,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,MAAM,CAAC,CAUjB;AAID,wBAAgB,YAAY,CAC1B,iBAAiB,EAAE,wBAAwB,GAC1C,8BAA8B,CAmDhC"}
@@ -19,6 +19,7 @@ import { SchedulableTriggerInputTypes, } from './Notifications.types';
19
19
  * body: 'Change sides!',
20
20
  * },
21
21
  * trigger: {
22
+ * type: SchedulableTriggerInputTypes.TIME_INTERVAL,
22
23
  * seconds: 60,
23
24
  * },
24
25
  * });
@@ -33,6 +34,7 @@ import { SchedulableTriggerInputTypes, } from './Notifications.types';
33
34
  * title: 'Remember to drink water!',
34
35
  * },
35
36
  * trigger: {
37
+ * type: SchedulableTriggerInputTypes.TIME_INTERVAL,
36
38
  * seconds: 60 * 20,
37
39
  * repeats: true,
38
40
  * },
@@ -1 +1 @@
1
- {"version":3,"file":"scheduleNotificationAsync.js","sourceRoot":"","sources":["../src/scheduleNotificationAsync.ts"],"names":[],"mappings":"AAAA,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,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, uuid } from 'expo-modules-core';\n\nimport NotificationScheduler from './NotificationScheduler';\nimport {\n NativeCalendarTriggerInput,\n NativeDailyTriggerInput,\n NativeDateTriggerInput,\n NativeNotificationTriggerInput,\n NativeTimeIntervalTriggerInput,\n NativeWeeklyTriggerInput,\n NativeMonthlyTriggerInput,\n NativeYearlyTriggerInput,\n} from './NotificationScheduler.types';\nimport {\n NotificationRequestInput,\n NotificationTriggerInput,\n SchedulableTriggerInputTypes,\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`](#setnotificationhandlerhandler)\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 ?? uuid.v4(),\n request.content,\n parseTrigger(request.trigger)\n );\n}\n\ntype ValidTriggerDateComponents = 'month' | 'day' | 'weekday' | 'hour' | 'minute';\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 const dateTrigger = parseDateTrigger(userFacingTrigger);\n if (dateTrigger) {\n return dateTrigger;\n }\n const calendarTrigger = parseCalendarTrigger(userFacingTrigger);\n if (calendarTrigger) {\n return calendarTrigger;\n }\n const dailyTrigger = parseDailyTrigger(userFacingTrigger);\n if (dailyTrigger) {\n return dailyTrigger;\n }\n const weeklyTrigger = parseWeeklyTrigger(userFacingTrigger);\n if (weeklyTrigger) {\n return weeklyTrigger;\n }\n const monthlyTrigger = parseMonthlyTrigger(userFacingTrigger);\n if (monthlyTrigger) {\n return monthlyTrigger;\n }\n const yearlyTrigger = parseYearlyTrigger(userFacingTrigger);\n if (yearlyTrigger) {\n return yearlyTrigger;\n }\n const timeIntervalTrigger = parseTimeIntervalTrigger(userFacingTrigger);\n if (timeIntervalTrigger) {\n return timeIntervalTrigger;\n }\n return Platform.select({\n default: null, // There's no notion of channels on platforms other than Android.\n android: {\n type: 'channel',\n channelId:\n typeof userFacingTrigger === 'object' &&\n userFacingTrigger !== null &&\n !(userFacingTrigger instanceof Date)\n ? userFacingTrigger?.channelId\n : undefined,\n },\n });\n}\n\nfunction parseCalendarTrigger(\n trigger: NotificationTriggerInput\n): NativeCalendarTriggerInput | undefined {\n if (\n trigger !== null &&\n typeof trigger === 'object' &&\n 'type' in trigger &&\n trigger.type === SchedulableTriggerInputTypes.CALENDAR\n ) {\n const { repeats, ...calendarTrigger } = trigger;\n return { type: 'calendar', value: calendarTrigger, repeats };\n }\n return undefined;\n}\n\nfunction parseDateTrigger(trigger: NotificationTriggerInput): NativeDateTriggerInput | undefined {\n if (trigger instanceof Date || typeof trigger === 'number') {\n return { type: 'date', timestamp: toTimestamp(trigger) };\n } else if (\n typeof trigger === 'object' &&\n trigger !== null &&\n 'type' in trigger &&\n trigger.type === SchedulableTriggerInputTypes.DATE &&\n 'date' in trigger &&\n trigger.date instanceof Date\n ) {\n const result: NativeDateTriggerInput = {\n type: 'date',\n timestamp: toTimestamp(trigger.date),\n };\n if (trigger.channelId) {\n result.channelId = trigger.channelId;\n }\n return result;\n } else {\n return undefined;\n }\n}\n\nfunction toTimestamp(date: number | Date) {\n if (date instanceof Date) {\n return date.getTime();\n }\n return date;\n}\n\nfunction parseDailyTrigger(trigger: NotificationTriggerInput): NativeDailyTriggerInput | undefined {\n if (\n trigger !== null &&\n typeof trigger === 'object' &&\n 'type' in trigger &&\n trigger.type === SchedulableTriggerInputTypes.DAILY\n ) {\n validateDateComponentsInTrigger(trigger, ['hour', 'minute']);\n const result: NativeDailyTriggerInput = {\n type: 'daily',\n hour: trigger.hour ?? placeholderDateComponentValue,\n minute: trigger.minute ?? placeholderDateComponentValue,\n };\n if (trigger.channelId) {\n result.channelId = trigger.channelId;\n }\n return result;\n }\n return undefined;\n}\n\nfunction parseWeeklyTrigger(\n trigger: NotificationTriggerInput\n): NativeWeeklyTriggerInput | undefined {\n if (\n trigger !== null &&\n typeof trigger === 'object' &&\n 'type' in trigger &&\n trigger.type === SchedulableTriggerInputTypes.WEEKLY\n ) {\n validateDateComponentsInTrigger(trigger, ['weekday', 'hour', 'minute']);\n const result: NativeWeeklyTriggerInput = {\n type: 'weekly',\n weekday: trigger.weekday ?? placeholderDateComponentValue,\n hour: trigger.hour ?? placeholderDateComponentValue,\n minute: trigger.minute ?? placeholderDateComponentValue,\n };\n if (trigger.channelId) {\n result.channelId = trigger.channelId;\n }\n return result;\n }\n return undefined;\n}\n\nfunction parseMonthlyTrigger(\n trigger: NotificationTriggerInput\n): NativeMonthlyTriggerInput | undefined {\n if (\n trigger !== null &&\n typeof trigger === 'object' &&\n 'type' in trigger &&\n trigger.type === SchedulableTriggerInputTypes.MONTHLY\n ) {\n validateDateComponentsInTrigger(trigger, ['day', 'hour', 'minute']);\n const result: NativeMonthlyTriggerInput = {\n type: 'monthly',\n day: trigger.day ?? placeholderDateComponentValue,\n hour: trigger.hour ?? placeholderDateComponentValue,\n minute: trigger.minute ?? placeholderDateComponentValue,\n };\n if (trigger.channelId) {\n result.channelId = trigger.channelId;\n }\n return result;\n }\n return undefined;\n}\n\nfunction parseYearlyTrigger(\n trigger: NotificationTriggerInput\n): NativeYearlyTriggerInput | undefined {\n if (\n trigger !== null &&\n typeof trigger === 'object' &&\n 'type' in trigger &&\n trigger.type === SchedulableTriggerInputTypes.YEARLY\n ) {\n validateDateComponentsInTrigger(trigger, ['month', 'day', 'hour', 'minute']);\n const result: NativeYearlyTriggerInput = {\n type: 'yearly',\n month: trigger.month ?? placeholderDateComponentValue,\n day: trigger.day ?? placeholderDateComponentValue,\n hour: trigger.hour ?? placeholderDateComponentValue,\n minute: trigger.minute ?? placeholderDateComponentValue,\n };\n if (trigger.channelId) {\n result.channelId = trigger.channelId;\n }\n return result;\n }\n return undefined;\n}\n\nfunction parseTimeIntervalTrigger(\n trigger: NotificationTriggerInput\n): NativeTimeIntervalTriggerInput | undefined {\n if (\n trigger !== null &&\n typeof trigger === 'object' &&\n 'type' in trigger &&\n trigger.type === SchedulableTriggerInputTypes.TIME_INTERVAL &&\n 'seconds' in trigger &&\n typeof trigger.seconds === 'number'\n ) {\n const result: NativeTimeIntervalTriggerInput = {\n type: 'timeInterval',\n seconds: trigger.seconds,\n repeats: trigger.repeats ?? false,\n };\n if (trigger.channelId) {\n result.channelId = trigger.channelId;\n }\n return result;\n }\n return undefined;\n}\n\n// Needed only to satisfy Typescript types for validated date components\nconst placeholderDateComponentValue = -9999;\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 = anyTriggerType.day;\n const month =\n anyTriggerType.month !== undefined ? anyTriggerType.month : new Date().getMonth();\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,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAExE,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAW5D,OAAO,EAGL,4BAA4B,GAC7B,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,yBAAyB,CACrD,OAAiC;IAEjC,IAAI,CAAC,qBAAqB,CAAC,yBAAyB,EAAE;QACpD,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAA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,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, uuid } from 'expo-modules-core';\n\nimport NotificationScheduler from './NotificationScheduler';\nimport {\n NativeCalendarTriggerInput,\n NativeDailyTriggerInput,\n NativeDateTriggerInput,\n NativeNotificationTriggerInput,\n NativeTimeIntervalTriggerInput,\n NativeWeeklyTriggerInput,\n NativeMonthlyTriggerInput,\n NativeYearlyTriggerInput,\n} from './NotificationScheduler.types';\nimport {\n NotificationRequestInput,\n NotificationTriggerInput,\n SchedulableTriggerInputTypes,\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`](#setnotificationhandlerhandler)\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 * type: SchedulableTriggerInputTypes.TIME_INTERVAL,\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 * type: SchedulableTriggerInputTypes.TIME_INTERVAL,\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 ?? uuid.v4(),\n request.content,\n parseTrigger(request.trigger)\n );\n}\n\ntype ValidTriggerDateComponents = 'month' | 'day' | 'weekday' | 'hour' | 'minute';\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 const dateTrigger = parseDateTrigger(userFacingTrigger);\n if (dateTrigger) {\n return dateTrigger;\n }\n const calendarTrigger = parseCalendarTrigger(userFacingTrigger);\n if (calendarTrigger) {\n return calendarTrigger;\n }\n const dailyTrigger = parseDailyTrigger(userFacingTrigger);\n if (dailyTrigger) {\n return dailyTrigger;\n }\n const weeklyTrigger = parseWeeklyTrigger(userFacingTrigger);\n if (weeklyTrigger) {\n return weeklyTrigger;\n }\n const monthlyTrigger = parseMonthlyTrigger(userFacingTrigger);\n if (monthlyTrigger) {\n return monthlyTrigger;\n }\n const yearlyTrigger = parseYearlyTrigger(userFacingTrigger);\n if (yearlyTrigger) {\n return yearlyTrigger;\n }\n const timeIntervalTrigger = parseTimeIntervalTrigger(userFacingTrigger);\n if (timeIntervalTrigger) {\n return timeIntervalTrigger;\n }\n return Platform.select({\n default: null, // There's no notion of channels on platforms other than Android.\n android: {\n type: 'channel',\n channelId:\n typeof userFacingTrigger === 'object' &&\n userFacingTrigger !== null &&\n !(userFacingTrigger instanceof Date)\n ? userFacingTrigger?.channelId\n : undefined,\n },\n });\n}\n\nfunction parseCalendarTrigger(\n trigger: NotificationTriggerInput\n): NativeCalendarTriggerInput | undefined {\n if (\n trigger !== null &&\n typeof trigger === 'object' &&\n 'type' in trigger &&\n trigger.type === SchedulableTriggerInputTypes.CALENDAR\n ) {\n const { repeats, ...calendarTrigger } = trigger;\n return { type: 'calendar', value: calendarTrigger, repeats };\n }\n return undefined;\n}\n\nfunction parseDateTrigger(trigger: NotificationTriggerInput): NativeDateTriggerInput | undefined {\n if (trigger instanceof Date || typeof trigger === 'number') {\n return { type: 'date', timestamp: toTimestamp(trigger) };\n } else if (\n typeof trigger === 'object' &&\n trigger !== null &&\n 'type' in trigger &&\n trigger.type === SchedulableTriggerInputTypes.DATE &&\n 'date' in trigger &&\n trigger.date instanceof Date\n ) {\n const result: NativeDateTriggerInput = {\n type: 'date',\n timestamp: toTimestamp(trigger.date),\n };\n if (trigger.channelId) {\n result.channelId = trigger.channelId;\n }\n return result;\n } else {\n return undefined;\n }\n}\n\nfunction toTimestamp(date: number | Date) {\n if (date instanceof Date) {\n return date.getTime();\n }\n return date;\n}\n\nfunction parseDailyTrigger(trigger: NotificationTriggerInput): NativeDailyTriggerInput | undefined {\n if (\n trigger !== null &&\n typeof trigger === 'object' &&\n 'type' in trigger &&\n trigger.type === SchedulableTriggerInputTypes.DAILY\n ) {\n validateDateComponentsInTrigger(trigger, ['hour', 'minute']);\n const result: NativeDailyTriggerInput = {\n type: 'daily',\n hour: trigger.hour ?? placeholderDateComponentValue,\n minute: trigger.minute ?? placeholderDateComponentValue,\n };\n if (trigger.channelId) {\n result.channelId = trigger.channelId;\n }\n return result;\n }\n return undefined;\n}\n\nfunction parseWeeklyTrigger(\n trigger: NotificationTriggerInput\n): NativeWeeklyTriggerInput | undefined {\n if (\n trigger !== null &&\n typeof trigger === 'object' &&\n 'type' in trigger &&\n trigger.type === SchedulableTriggerInputTypes.WEEKLY\n ) {\n validateDateComponentsInTrigger(trigger, ['weekday', 'hour', 'minute']);\n const result: NativeWeeklyTriggerInput = {\n type: 'weekly',\n weekday: trigger.weekday ?? placeholderDateComponentValue,\n hour: trigger.hour ?? placeholderDateComponentValue,\n minute: trigger.minute ?? placeholderDateComponentValue,\n };\n if (trigger.channelId) {\n result.channelId = trigger.channelId;\n }\n return result;\n }\n return undefined;\n}\n\nfunction parseMonthlyTrigger(\n trigger: NotificationTriggerInput\n): NativeMonthlyTriggerInput | undefined {\n if (\n trigger !== null &&\n typeof trigger === 'object' &&\n 'type' in trigger &&\n trigger.type === SchedulableTriggerInputTypes.MONTHLY\n ) {\n validateDateComponentsInTrigger(trigger, ['day', 'hour', 'minute']);\n const result: NativeMonthlyTriggerInput = {\n type: 'monthly',\n day: trigger.day ?? placeholderDateComponentValue,\n hour: trigger.hour ?? placeholderDateComponentValue,\n minute: trigger.minute ?? placeholderDateComponentValue,\n };\n if (trigger.channelId) {\n result.channelId = trigger.channelId;\n }\n return result;\n }\n return undefined;\n}\n\nfunction parseYearlyTrigger(\n trigger: NotificationTriggerInput\n): NativeYearlyTriggerInput | undefined {\n if (\n trigger !== null &&\n typeof trigger === 'object' &&\n 'type' in trigger &&\n trigger.type === SchedulableTriggerInputTypes.YEARLY\n ) {\n validateDateComponentsInTrigger(trigger, ['month', 'day', 'hour', 'minute']);\n const result: NativeYearlyTriggerInput = {\n type: 'yearly',\n month: trigger.month ?? placeholderDateComponentValue,\n day: trigger.day ?? placeholderDateComponentValue,\n hour: trigger.hour ?? placeholderDateComponentValue,\n minute: trigger.minute ?? placeholderDateComponentValue,\n };\n if (trigger.channelId) {\n result.channelId = trigger.channelId;\n }\n return result;\n }\n return undefined;\n}\n\nfunction parseTimeIntervalTrigger(\n trigger: NotificationTriggerInput\n): NativeTimeIntervalTriggerInput | undefined {\n if (\n trigger !== null &&\n typeof trigger === 'object' &&\n 'type' in trigger &&\n trigger.type === SchedulableTriggerInputTypes.TIME_INTERVAL &&\n 'seconds' in trigger &&\n typeof trigger.seconds === 'number'\n ) {\n const result: NativeTimeIntervalTriggerInput = {\n type: 'timeInterval',\n seconds: trigger.seconds,\n repeats: trigger.repeats ?? false,\n };\n if (trigger.channelId) {\n result.channelId = trigger.channelId;\n }\n return result;\n }\n return undefined;\n}\n\n// Needed only to satisfy Typescript types for validated date components\nconst placeholderDateComponentValue = -9999;\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 = anyTriggerType.day;\n const month =\n anyTriggerType.month !== undefined ? anyTriggerType.month : new Date().getMonth();\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.29.7",
3
+ "version": "0.29.8",
4
4
  "description": "Provides an API to fetch push notification tokens and to present, schedule, receive, and respond to notifications.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -55,5 +55,5 @@
55
55
  "react": "*",
56
56
  "react-native": "*"
57
57
  },
58
- "gitHead": "2c50bd7f0abaefb6fabcfd6d3935066724990b33"
58
+ "gitHead": "b7b95a93855cb4863b626c4524fc6e8b3a2305eb"
59
59
  }
@@ -35,6 +35,7 @@ import {
35
35
  * body: 'Change sides!',
36
36
  * },
37
37
  * trigger: {
38
+ * type: SchedulableTriggerInputTypes.TIME_INTERVAL,
38
39
  * seconds: 60,
39
40
  * },
40
41
  * });
@@ -49,6 +50,7 @@ import {
49
50
  * title: 'Remember to drink water!',
50
51
  * },
51
52
  * trigger: {
53
+ * type: SchedulableTriggerInputTypes.TIME_INTERVAL,
52
54
  * seconds: 60 * 20,
53
55
  * repeats: true,
54
56
  * },