expo-notifications 0.31.1 → 0.31.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/android/build.gradle +2 -2
  3. package/android/src/main/java/expo/modules/notifications/notifications/emitting/NotificationsEmitter.kt +2 -2
  4. package/android/src/main/java/expo/modules/notifications/service/NotificationsService.kt +12 -12
  5. package/android/src/main/java/expo/modules/notifications/service/delegates/ExpoHandlingDelegate.kt +2 -0
  6. package/build/NotificationPermissions.d.ts +1 -1
  7. package/build/NotificationPermissions.js +1 -1
  8. package/build/NotificationPermissions.js.map +1 -1
  9. package/build/NotificationsEmitter.d.ts +18 -0
  10. package/build/NotificationsEmitter.d.ts.map +1 -1
  11. package/build/NotificationsEmitter.js +28 -6
  12. package/build/NotificationsEmitter.js.map +1 -1
  13. package/build/NotificationsEmitterModule.types.d.ts +2 -1
  14. package/build/NotificationsEmitterModule.types.d.ts.map +1 -1
  15. package/build/NotificationsEmitterModule.types.js.map +1 -1
  16. package/build/getDevicePushTokenAsync.web.js +1 -1
  17. package/build/getDevicePushTokenAsync.web.js.map +1 -1
  18. package/build/index.js +1 -1
  19. package/build/index.js.map +1 -1
  20. package/build/scheduleNotificationAsync.d.ts +1 -1
  21. package/build/scheduleNotificationAsync.js +1 -1
  22. package/build/scheduleNotificationAsync.js.map +1 -1
  23. package/expo-module.config.json +1 -1
  24. package/ios/EXNotifications/Notifications/Categories/CategoriesModule.swift +3 -5
  25. package/ios/EXNotifications/Notifications/Emitter/EmitterModule.swift +10 -11
  26. package/ios/EXNotifications/Notifications/NotificationCenterManager.swift +1 -2
  27. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/{0.31.1/expo.modules.notifications-0.31.1-sources.jar → 0.31.3/expo.modules.notifications-0.31.3-sources.jar} +0 -0
  28. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.3/expo.modules.notifications-0.31.3-sources.jar.md5 +1 -0
  29. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.3/expo.modules.notifications-0.31.3-sources.jar.sha1 +1 -0
  30. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.3/expo.modules.notifications-0.31.3-sources.jar.sha256 +1 -0
  31. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.3/expo.modules.notifications-0.31.3-sources.jar.sha512 +1 -0
  32. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.3/expo.modules.notifications-0.31.3.aar +0 -0
  33. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.3/expo.modules.notifications-0.31.3.aar.md5 +1 -0
  34. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.3/expo.modules.notifications-0.31.3.aar.sha1 +1 -0
  35. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.3/expo.modules.notifications-0.31.3.aar.sha256 +1 -0
  36. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.3/expo.modules.notifications-0.31.3.aar.sha512 +1 -0
  37. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/{0.31.1/expo.modules.notifications-0.31.1.module → 0.31.3/expo.modules.notifications-0.31.3.module} +22 -22
  38. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.3/expo.modules.notifications-0.31.3.module.md5 +1 -0
  39. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.3/expo.modules.notifications-0.31.3.module.sha1 +1 -0
  40. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.3/expo.modules.notifications-0.31.3.module.sha256 +1 -0
  41. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.3/expo.modules.notifications-0.31.3.module.sha512 +1 -0
  42. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/{0.31.1/expo.modules.notifications-0.31.1.pom → 0.31.3/expo.modules.notifications-0.31.3.pom} +1 -1
  43. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.3/expo.modules.notifications-0.31.3.pom.md5 +1 -0
  44. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.3/expo.modules.notifications-0.31.3.pom.sha1 +1 -0
  45. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.3/expo.modules.notifications-0.31.3.pom.sha256 +1 -0
  46. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.3/expo.modules.notifications-0.31.3.pom.sha512 +1 -0
  47. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/maven-metadata.xml +4 -4
  48. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/maven-metadata.xml.md5 +1 -1
  49. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/maven-metadata.xml.sha1 +1 -1
  50. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/maven-metadata.xml.sha256 +1 -1
  51. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/maven-metadata.xml.sha512 +1 -1
  52. package/package.json +4 -4
  53. package/src/NotificationPermissions.ts +1 -1
  54. package/src/NotificationsEmitter.ts +30 -6
  55. package/src/NotificationsEmitterModule.types.ts +2 -1
  56. package/src/getDevicePushTokenAsync.web.ts +1 -1
  57. package/src/index.ts +1 -1
  58. package/src/scheduleNotificationAsync.ts +1 -1
  59. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.1/expo.modules.notifications-0.31.1-sources.jar.md5 +0 -1
  60. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.1/expo.modules.notifications-0.31.1-sources.jar.sha1 +0 -1
  61. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.1/expo.modules.notifications-0.31.1-sources.jar.sha256 +0 -1
  62. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.1/expo.modules.notifications-0.31.1-sources.jar.sha512 +0 -1
  63. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.1/expo.modules.notifications-0.31.1.aar +0 -0
  64. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.1/expo.modules.notifications-0.31.1.aar.md5 +0 -1
  65. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.1/expo.modules.notifications-0.31.1.aar.sha1 +0 -1
  66. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.1/expo.modules.notifications-0.31.1.aar.sha256 +0 -1
  67. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.1/expo.modules.notifications-0.31.1.aar.sha512 +0 -1
  68. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.1/expo.modules.notifications-0.31.1.module.md5 +0 -1
  69. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.1/expo.modules.notifications-0.31.1.module.sha1 +0 -1
  70. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.1/expo.modules.notifications-0.31.1.module.sha256 +0 -1
  71. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.1/expo.modules.notifications-0.31.1.module.sha512 +0 -1
  72. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.1/expo.modules.notifications-0.31.1.pom.md5 +0 -1
  73. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.1/expo.modules.notifications-0.31.1.pom.sha1 +0 -1
  74. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.1/expo.modules.notifications-0.31.1.pom.sha256 +0 -1
  75. package/local-maven-repo/host/exp/exponent/expo.modules.notifications/0.31.1/expo.modules.notifications-0.31.1.pom.sha512 +0 -1
package/CHANGELOG.md CHANGED
@@ -10,6 +10,21 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 0.31.3 — 2025-06-04
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - [ios] ensure `getLastNotificationResponseAsync` does not return null when no response listener added ([#36930](https://github.com/expo/expo/pull/36930) by [@jmysliv](https://github.com/jmysliv))
18
+
19
+ ### 💡 Others
20
+
21
+ - improve test environment condition to avoid warning ([#33982](https://github.com/expo/expo/pull/33982) by [@PiotrBorowski](https://github.com/PiotrBorowski))
22
+ - Remove "Please" from warnings and errors ([#36862](https://github.com/expo/expo/pull/36862) by [@brentvatne](https://github.com/brentvatne))
23
+
24
+ ## 0.31.2 — 2025-05-08
25
+
26
+ _This version does not introduce any user-facing changes._
27
+
13
28
  ## 0.31.1 — 2025-04-30
14
29
 
15
30
  _This version does not introduce any user-facing changes._
@@ -5,13 +5,13 @@ plugins {
5
5
  }
6
6
 
7
7
  group = 'host.exp.exponent'
8
- version = '0.31.1'
8
+ version = '0.31.3'
9
9
 
10
10
  android {
11
11
  namespace "expo.modules.notifications"
12
12
  defaultConfig {
13
13
  versionCode 21
14
- versionName '0.31.1'
14
+ versionName '0.31.3'
15
15
  testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16
16
  }
17
17
 
@@ -38,11 +38,11 @@ open class NotificationsEmitter : Module(), NotificationListener {
38
38
  notificationManager.removeListener(this@NotificationsEmitter)
39
39
  }
40
40
 
41
- AsyncFunction<Bundle?>("getLastNotificationResponseAsync") {
41
+ Function<Bundle?>("getLastNotificationResponse") {
42
42
  lastNotificationResponseBundle
43
43
  }
44
44
 
45
- AsyncFunction("clearLastNotificationResponseAsync") {
45
+ Function("clearLastNotificationResponse") {
46
46
  lastNotificationResponseBundle = null
47
47
  null
48
48
  }
@@ -679,8 +679,8 @@ open class NotificationsService : BroadcastReceiver() {
679
679
  )
680
680
 
681
681
  open fun onGetAllPresentedNotifications(context: Context, intent: Intent) =
682
- Bundle().also {
683
- it.putParcelableArrayList(
682
+ Bundle().apply {
683
+ putParcelableArrayList(
684
684
  NOTIFICATIONS_KEY,
685
685
  ArrayList(
686
686
  getPresentationDelegate(context).getAllPresentedNotifications()
@@ -718,8 +718,8 @@ open class NotificationsService : BroadcastReceiver() {
718
718
  //region Category handling
719
719
 
720
720
  open fun onGetCategories(context: Context, intent: Intent) =
721
- Bundle().also {
722
- it.putParcelableArrayList(
721
+ Bundle().apply {
722
+ putParcelableArrayList(
723
723
  NOTIFICATION_CATEGORIES_KEY,
724
724
  ArrayList(
725
725
  getCategoriesDelegate(context).getCategories()
@@ -728,8 +728,8 @@ open class NotificationsService : BroadcastReceiver() {
728
728
  }
729
729
 
730
730
  open fun onSetCategory(context: Context, intent: Intent) =
731
- Bundle().also {
732
- it.putParcelable(
731
+ Bundle().apply {
732
+ putParcelable(
733
733
  NOTIFICATION_CATEGORY_KEY,
734
734
  getCategoriesDelegate(context).setCategory(
735
735
  intent.getParcelableExtra(NOTIFICATION_CATEGORY_KEY)!!
@@ -738,8 +738,8 @@ open class NotificationsService : BroadcastReceiver() {
738
738
  }
739
739
 
740
740
  open fun onDeleteCategory(context: Context, intent: Intent) =
741
- Bundle().also {
742
- it.putBoolean(
741
+ Bundle().apply {
742
+ putBoolean(
743
743
  SUCCEEDED_KEY,
744
744
  getCategoriesDelegate(context).deleteCategory(
745
745
  intent.extras?.getString(IDENTIFIER_KEY)!!
@@ -751,8 +751,8 @@ open class NotificationsService : BroadcastReceiver() {
751
751
  //region Scheduling notifications
752
752
 
753
753
  open fun onGetAllScheduledNotifications(context: Context, intent: Intent) =
754
- Bundle().also {
755
- it.putParcelableArrayList(
754
+ Bundle().apply {
755
+ putParcelableArrayList(
756
756
  NOTIFICATION_REQUESTS_KEY,
757
757
  ArrayList(
758
758
  getSchedulingDelegate(context).getAllScheduledNotifications()
@@ -761,8 +761,8 @@ open class NotificationsService : BroadcastReceiver() {
761
761
  }
762
762
 
763
763
  open fun onGetScheduledNotification(context: Context, intent: Intent) =
764
- Bundle().also {
765
- it.putParcelable(
764
+ Bundle().apply {
765
+ putParcelable(
766
766
  NOTIFICATION_REQUEST_KEY,
767
767
  getSchedulingDelegate(context).getScheduledNotification(
768
768
  intent.extras?.getString(IDENTIFIER_KEY)!!
@@ -124,6 +124,8 @@ class ExpoHandlingDelegate(protected val context: Context) : HandlingDelegate {
124
124
  } else if (notification.shouldPresent()) {
125
125
  // only data-only notifications reach this point and we present them if they fall into the documented exception:
126
126
  // https://docs.expo.dev/push-notifications/what-you-need-to-know/#headless-background-notifications
127
+ // this call can not be triggered by expo push service, only when using FCM directly.
128
+ // We keep this because we used to document this as a valid use case.
127
129
  NotificationsService.present(context, notification)
128
130
  }
129
131
  }
@@ -30,7 +30,7 @@ export declare function getPermissionsAsync(): Promise<import("./NotificationPer
30
30
  * import * as Notifications from 'expo-notifications';
31
31
  *
32
32
  * export function requestPermissionsAsync() {
33
- * return await Notifications.requestPermissionsAsync({
33
+ * return Notifications.requestPermissionsAsync({
34
34
  * ios: {
35
35
  * allowAlert: true,
36
36
  * allowBadge: true,
@@ -36,7 +36,7 @@ export async function getPermissionsAsync() {
36
36
  * import * as Notifications from 'expo-notifications';
37
37
  *
38
38
  * export function requestPermissionsAsync() {
39
- * return await Notifications.requestPermissionsAsync({
39
+ * return Notifications.requestPermissionsAsync({
40
40
  * ios: {
41
41
  * allowAlert: true,
42
42
  * allowBadge: true,
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationPermissions.js","sourceRoot":"","sources":["../src/NotificationPermissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAGlE,OAAO,6BAA6B,MAAM,iCAAiC,CAAC;AAE5E;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB;IACvC,IAAI,CAAC,6BAA6B,CAAC,mBAAmB,EAAE,CAAC;QACvD,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,qBAAqB,CAAC,CAAC;IACxE,CAAC;IAED,OAAO,MAAM,6BAA6B,CAAC,mBAAmB,EAAE,CAAC;AACnE,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,WAA4C;IACxF,IAAI,CAAC,6BAA6B,CAAC,uBAAuB,EAAE,CAAC;QAC3D,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,yBAAyB,CAAC,CAAC;IAC5E,CAAC;IAED,MAAM,oBAAoB,GAAG,WAAW,IAAI;QAC1C,GAAG,EAAE;YACH,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,IAAI;SACjB;KACF,CAAC;IACF,MAAM,4BAA4B,GAChC,oBAAoB,CAAC,QAAQ,CAAC,EAAuC,CAAC,CAAC;IACzE,iFAAiF;IACjF,OAAO,MAAM,6BAA6B,CAAC,uBAAuB,CAAC,4BAA6B,CAAC,CAAC;AACpG,CAAC","sourcesContent":["import { Platform, UnavailabilityError } from 'expo-modules-core';\n\nimport { NotificationPermissionsRequest } from './NotificationPermissions.types';\nimport NotificationPermissionsModule from './NotificationPermissionsModule';\n\n/**\n * Calling this function checks current permissions settings related to notifications.\n * It lets you verify whether the app is currently allowed to display alerts, play sounds, etc.\n * There is no user-facing effect of calling this.\n * @return It returns a `Promise` resolving to an object represents permission settings ([`NotificationPermissionsStatus`](#notificationpermissionsstatus)).\n * On iOS, make sure you [properly interpret the permissions response](#interpret-the-ios-permissions-response).\n * @example Check if the app is allowed to send any type of notifications (interrupting and non-interrupting–provisional on iOS).\n * ```ts\n * import * as Notifications from 'expo-notifications';\n *\n * export async function allowsNotificationsAsync() {\n * const settings = await Notifications.getPermissionsAsync();\n * return (\n * settings.granted || settings.ios?.status === Notifications.IosAuthorizationStatus.PROVISIONAL\n * );\n * }\n * ```\n * @header permissions\n */\nexport async function getPermissionsAsync() {\n if (!NotificationPermissionsModule.getPermissionsAsync) {\n throw new UnavailabilityError('Notifications', 'getPermissionsAsync');\n }\n\n return await NotificationPermissionsModule.getPermissionsAsync();\n}\n\n/**\n * Prompts the user for notification permissions according to request. **Request defaults to asking the user to allow displaying alerts,\n * setting badge count and playing sounds**.\n * @param permissions An object representing configuration for the request scope.\n * @return It returns a Promise resolving to an object represents permission settings ([`NotificationPermissionsStatus`](#notificationpermissionsstatus)).\n * On iOS, make sure you [properly interpret the permissions response](#interpret-the-ios-permissions-response).\n * @example Prompts the user to allow the app to show alerts, play sounds, set badge count and let Siri read out messages through AirPods.\n * ```ts\n * import * as Notifications from 'expo-notifications';\n *\n * export function requestPermissionsAsync() {\n * return await Notifications.requestPermissionsAsync({\n * ios: {\n * allowAlert: true,\n * allowBadge: true,\n * allowSound: true,\n * },\n * });\n * }\n * ```\n * @header permissions\n */\nexport async function requestPermissionsAsync(permissions?: NotificationPermissionsRequest) {\n if (!NotificationPermissionsModule.requestPermissionsAsync) {\n throw new UnavailabilityError('Notifications', 'requestPermissionsAsync');\n }\n\n const requestedPermissions = permissions ?? {\n ios: {\n allowAlert: true,\n allowBadge: true,\n allowSound: true,\n },\n };\n const requestedPlatformPermissions =\n requestedPermissions[Platform.OS as keyof typeof requestedPermissions];\n // TODO(@kitten): This never checks whether the configuration object is undefined\n return await NotificationPermissionsModule.requestPermissionsAsync(requestedPlatformPermissions!);\n}\n"]}
1
+ {"version":3,"file":"NotificationPermissions.js","sourceRoot":"","sources":["../src/NotificationPermissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAGlE,OAAO,6BAA6B,MAAM,iCAAiC,CAAC;AAE5E;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB;IACvC,IAAI,CAAC,6BAA6B,CAAC,mBAAmB,EAAE,CAAC;QACvD,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,qBAAqB,CAAC,CAAC;IACxE,CAAC;IAED,OAAO,MAAM,6BAA6B,CAAC,mBAAmB,EAAE,CAAC;AACnE,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,WAA4C;IACxF,IAAI,CAAC,6BAA6B,CAAC,uBAAuB,EAAE,CAAC;QAC3D,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,yBAAyB,CAAC,CAAC;IAC5E,CAAC;IAED,MAAM,oBAAoB,GAAG,WAAW,IAAI;QAC1C,GAAG,EAAE;YACH,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,IAAI;SACjB;KACF,CAAC;IACF,MAAM,4BAA4B,GAChC,oBAAoB,CAAC,QAAQ,CAAC,EAAuC,CAAC,CAAC;IACzE,iFAAiF;IACjF,OAAO,MAAM,6BAA6B,CAAC,uBAAuB,CAAC,4BAA6B,CAAC,CAAC;AACpG,CAAC","sourcesContent":["import { Platform, UnavailabilityError } from 'expo-modules-core';\n\nimport { NotificationPermissionsRequest } from './NotificationPermissions.types';\nimport NotificationPermissionsModule from './NotificationPermissionsModule';\n\n/**\n * Calling this function checks current permissions settings related to notifications.\n * It lets you verify whether the app is currently allowed to display alerts, play sounds, etc.\n * There is no user-facing effect of calling this.\n * @return It returns a `Promise` resolving to an object represents permission settings ([`NotificationPermissionsStatus`](#notificationpermissionsstatus)).\n * On iOS, make sure you [properly interpret the permissions response](#interpret-the-ios-permissions-response).\n * @example Check if the app is allowed to send any type of notifications (interrupting and non-interrupting–provisional on iOS).\n * ```ts\n * import * as Notifications from 'expo-notifications';\n *\n * export async function allowsNotificationsAsync() {\n * const settings = await Notifications.getPermissionsAsync();\n * return (\n * settings.granted || settings.ios?.status === Notifications.IosAuthorizationStatus.PROVISIONAL\n * );\n * }\n * ```\n * @header permissions\n */\nexport async function getPermissionsAsync() {\n if (!NotificationPermissionsModule.getPermissionsAsync) {\n throw new UnavailabilityError('Notifications', 'getPermissionsAsync');\n }\n\n return await NotificationPermissionsModule.getPermissionsAsync();\n}\n\n/**\n * Prompts the user for notification permissions according to request. **Request defaults to asking the user to allow displaying alerts,\n * setting badge count and playing sounds**.\n * @param permissions An object representing configuration for the request scope.\n * @return It returns a Promise resolving to an object represents permission settings ([`NotificationPermissionsStatus`](#notificationpermissionsstatus)).\n * On iOS, make sure you [properly interpret the permissions response](#interpret-the-ios-permissions-response).\n * @example Prompts the user to allow the app to show alerts, play sounds, set badge count and let Siri read out messages through AirPods.\n * ```ts\n * import * as Notifications from 'expo-notifications';\n *\n * export function requestPermissionsAsync() {\n * return Notifications.requestPermissionsAsync({\n * ios: {\n * allowAlert: true,\n * allowBadge: true,\n * allowSound: true,\n * },\n * });\n * }\n * ```\n * @header permissions\n */\nexport async function requestPermissionsAsync(permissions?: NotificationPermissionsRequest) {\n if (!NotificationPermissionsModule.requestPermissionsAsync) {\n throw new UnavailabilityError('Notifications', 'requestPermissionsAsync');\n }\n\n const requestedPermissions = permissions ?? {\n ios: {\n allowAlert: true,\n allowBadge: true,\n allowSound: true,\n },\n };\n const requestedPlatformPermissions =\n requestedPermissions[Platform.OS as keyof typeof requestedPermissions];\n // TODO(@kitten): This never checks whether the configuration object is undefined\n return await NotificationPermissionsModule.requestPermissionsAsync(requestedPlatformPermissions!);\n}\n"]}
@@ -78,6 +78,14 @@ export declare function removeNotificationSubscription(subscription: EventSubscr
78
78
  * - a [`NotificationResponse`](#notificationresponse) object - if a notification response was received
79
79
  */
80
80
  export declare function getLastNotificationResponseAsync(): Promise<NotificationResponse | null>;
81
+ /**
82
+ * Gets the notification response that was received most recently
83
+ * (a notification response designates an interaction with a notification, such as tapping on it).
84
+ *
85
+ * - `null` - if no notification response has been received yet
86
+ * - a [`NotificationResponse`](#notificationresponse) object - if a notification response was received
87
+ */
88
+ export declare function getLastNotificationResponse(): NotificationResponse | null;
81
89
  /**
82
90
  * Clears the notification response that was received most recently. May be used
83
91
  * when an app selects a route based on the notification response, and it is undesirable
@@ -89,6 +97,16 @@ export declare function getLastNotificationResponseAsync(): Promise<Notification
89
97
  * @return A promise that resolves if the native call was successful.
90
98
  */
91
99
  export declare function clearLastNotificationResponseAsync(): Promise<void>;
100
+ /**
101
+ * Clears the notification response that was received most recently. May be used
102
+ * when an app selects a route based on the notification response, and it is undesirable
103
+ * to continue selecting the route after the response has already been handled.
104
+ *
105
+ * If a component is using the [`useLastNotificationResponse`](#uselastnotificationresponse) hook,
106
+ * this call will also clear the value returned by the hook.
107
+ *
108
+ */
109
+ export declare function clearLastNotificationResponse(): void;
92
110
  /**
93
111
  * @hidden
94
112
  */
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationsEmitter.d.ts","sourceRoot":"","sources":["../src/NotificationsEmitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,iBAAiB,EAAuB,MAAM,mBAAmB,CAAC;AAEpG,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAa3E,eAAO,MAAM,yBAAyB,+CAA+C,CAAC;AAEtF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,+BAA+B,CAC7C,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,GACtC,iBAAiB,CAQnB;AAED;;;;;;;GAOG;AACH,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,iBAAiB,CAEvF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,uCAAuC,CACrD,QAAQ,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,GAC9C,iBAAiB,CAQnB;AAED;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAAC,YAAY,EAAE,iBAAiB,QAW7E;AAED;;;;;;GAMG;AACH,wBAAsB,gCAAgC,IAAI,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAO7F;AAED;;;;;;;;;GASG;AACH,wBAAsB,kCAAkC,IAAI,OAAO,CAAC,IAAI,CAAC,CAOxE;AAED;;GAEG;AACH,wBAAgB,sCAAsC,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,iBAAiB,CAE9F"}
1
+ {"version":3,"file":"NotificationsEmitter.d.ts","sourceRoot":"","sources":["../src/NotificationsEmitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,iBAAiB,EAAuB,MAAM,mBAAmB,CAAC;AAEpG,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAa3E,eAAO,MAAM,yBAAyB,+CAA+C,CAAC;AAEtF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,+BAA+B,CAC7C,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,GACtC,iBAAiB,CAQnB;AAED;;;;;;;GAOG;AACH,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,iBAAiB,CAEvF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,uCAAuC,CACrD,QAAQ,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,GAC9C,iBAAiB,CAQnB;AAED;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAAC,YAAY,EAAE,iBAAiB,QAW7E;AAED;;;;;;GAMG;AACH,wBAAsB,gCAAgC,IAAI,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAE7F;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,IAAI,oBAAoB,GAAG,IAAI,CAOzE;AAED;;;;;;;;;GASG;AACH,wBAAsB,kCAAkC,IAAI,OAAO,CAAC,IAAI,CAAC,CAExE;AAED;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,IAAI,IAAI,CAOpD;AAED;;GAEG;AACH,wBAAgB,sCAAsC,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,iBAAiB,CAE9F"}
@@ -106,10 +106,20 @@ export function removeNotificationSubscription(subscription) {
106
106
  * - a [`NotificationResponse`](#notificationresponse) object - if a notification response was received
107
107
  */
108
108
  export async function getLastNotificationResponseAsync() {
109
- if (!NotificationsEmitterModule.getLastNotificationResponseAsync) {
110
- throw new UnavailabilityError('ExpoNotifications', 'getLastNotificationResponseAsync');
109
+ return getLastNotificationResponse();
110
+ }
111
+ /**
112
+ * Gets the notification response that was received most recently
113
+ * (a notification response designates an interaction with a notification, such as tapping on it).
114
+ *
115
+ * - `null` - if no notification response has been received yet
116
+ * - a [`NotificationResponse`](#notificationresponse) object - if a notification response was received
117
+ */
118
+ export function getLastNotificationResponse() {
119
+ if (!NotificationsEmitterModule.getLastNotificationResponse) {
120
+ throw new UnavailabilityError('ExpoNotifications', 'getLastNotificationResponse');
111
121
  }
112
- const response = await NotificationsEmitterModule.getLastNotificationResponseAsync();
122
+ const response = NotificationsEmitterModule.getLastNotificationResponse();
113
123
  const mappedResponse = response ? mapNotificationResponse(response) : response;
114
124
  return mappedResponse;
115
125
  }
@@ -124,10 +134,22 @@ export async function getLastNotificationResponseAsync() {
124
134
  * @return A promise that resolves if the native call was successful.
125
135
  */
126
136
  export async function clearLastNotificationResponseAsync() {
127
- if (!NotificationsEmitterModule.clearLastNotificationResponseAsync) {
128
- throw new UnavailabilityError('ExpoNotifications', 'getLastNotificationResponseAsync');
137
+ clearLastNotificationResponse();
138
+ }
139
+ /**
140
+ * Clears the notification response that was received most recently. May be used
141
+ * when an app selects a route based on the notification response, and it is undesirable
142
+ * to continue selecting the route after the response has already been handled.
143
+ *
144
+ * If a component is using the [`useLastNotificationResponse`](#uselastnotificationresponse) hook,
145
+ * this call will also clear the value returned by the hook.
146
+ *
147
+ */
148
+ export function clearLastNotificationResponse() {
149
+ if (!NotificationsEmitterModule.clearLastNotificationResponse) {
150
+ throw new UnavailabilityError('ExpoNotifications', 'clearLastNotificationResponse');
129
151
  }
130
- await NotificationsEmitterModule.clearLastNotificationResponseAsync();
152
+ NotificationsEmitterModule.clearLastNotificationResponse();
131
153
  // Emit event to clear any useLastNotificationResponse hooks, after native call succeeds
132
154
  emitter.emit(didClearNotificationResponseEventName, []);
133
155
  }
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationsEmitter.js","sourceRoot":"","sources":["../src/NotificationsEmitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAA0B,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAGpG,OAAO,0BAA0B,MAAM,8BAA8B,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AAE,MAAM,KAAK,UAAU,EAAE,CAAC;QAC/C,YAAY,CAAC,MAAM,EAAE,CAAC;IACxB,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CACb,yEAAyE,YAAY,EAAE,CACxF,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,gCAAgC;IACpD,IAAI,CAAC,0BAA0B,CAAC,gCAAgC,EAAE,CAAC;QACjE,MAAM,IAAI,mBAAmB,CAAC,mBAAmB,EAAE,kCAAkC,CAAC,CAAC;IACzF,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,0BAA0B,CAAC,gCAAgC,EAAE,CAAC;IACrF,MAAM,cAAc,GAAG,QAAQ,CAAC,CAAC,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IAC/E,OAAO,cAAc,CAAC;AACxB,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,kCAAkC;IACtD,IAAI,CAAC,0BAA0B,CAAC,kCAAkC,EAAE,CAAC;QACnE,MAAM,IAAI,mBAAmB,CAAC,mBAAmB,EAAE,kCAAkC,CAAC,CAAC;IACzF,CAAC;IACD,MAAM,0BAA0B,CAAC,kCAAkC,EAAE,CAAC;IACtE,wFAAwF;IACxF,OAAO,CAAC,IAAI,CAAC,qCAAqC,EAAE,EAAE,CAAC,CAAC;AAC1D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sCAAsC,CAAC,QAAoB;IACzE,OAAO,OAAO,CAAC,WAAW,CAAO,qCAAqC,EAAE,QAAQ,CAAC,CAAC;AACpF,CAAC","sourcesContent":["import { LegacyEventEmitter, type EventSubscription, UnavailabilityError } from 'expo-modules-core';\n\nimport { Notification, NotificationResponse } from './Notifications.types';\nimport NotificationsEmitterModule from './NotificationsEmitterModule';\nimport { mapNotification, mapNotificationResponse } from './utils/mapNotificationResponse';\n\n// Web uses SyntheticEventEmitter\nconst emitter = new LegacyEventEmitter(NotificationsEmitterModule);\n\nconst didReceiveNotificationEventName = 'onDidReceiveNotification';\nconst didDropNotificationsEventName = 'onNotificationsDeleted';\nconst didReceiveNotificationResponseEventName = 'onDidReceiveNotificationResponse';\nconst didClearNotificationResponseEventName = 'onDidClearNotificationResponse';\n\n// @docsMissing\nexport const DEFAULT_ACTION_IDENTIFIER = 'expo.modules.notifications.actions.DEFAULT';\n\n/**\n * Listeners registered by this method will be called whenever a notification is received while the app is running.\n * @param listener A function accepting a notification ([`Notification`](#notification)) as an argument.\n * @return An [`EventSubscription`](#eventsubscription) object represents the subscription of the provided listener.\n * @example Registering a notification listener using a React hook:\n * ```jsx\n * import React from 'react';\n * import * as Notifications from 'expo-notifications';\n *\n * export default function App() {\n * React.useEffect(() => {\n * const subscription = Notifications.addNotificationReceivedListener(notification => {\n * console.log(notification);\n * });\n * return () => subscription.remove();\n * }, []);\n *\n * return (\n * // Your app content\n * );\n * }\n * ```\n * @header listen\n */\nexport function addNotificationReceivedListener(\n listener: (event: Notification) => void\n): EventSubscription {\n return emitter.addListener<Notification>(\n didReceiveNotificationEventName,\n (notification: Notification) => {\n const mappedNotification = mapNotification(notification);\n listener(mappedNotification);\n }\n );\n}\n\n/**\n * Listeners registered by this method will be called whenever some notifications have been dropped by the server.\n * Applicable only to Firebase Cloud Messaging which we use as a notifications service on Android. It corresponds to `onDeletedMessages()` callback.\n * More information can be found in [Firebase docs](https://firebase.google.com/docs/cloud-messaging/android/receive#override-ondeletedmessages).\n * @param listener A callback function.\n * @return An [`EventSubscription`](#eventsubscription) object represents the subscription of the provided listener.\n * @header listen\n */\nexport function addNotificationsDroppedListener(listener: () => void): EventSubscription {\n return emitter.addListener<void>(didDropNotificationsEventName, listener);\n}\n\n/**\n * Listeners registered by this method will be called whenever a user interacts with a notification (for example, taps on it).\n * @param listener A function accepting notification response ([`NotificationResponse`](#notificationresponse)) as an argument.\n * @return An [`EventSubscription`](#eventsubscription) object represents the subscription of the provided listener.\n * @example Register a notification responder listener:\n * ```jsx\n * import React from 'react';\n * import { Linking } from 'react-native';\n * import * as Notifications from 'expo-notifications';\n *\n * export default function Container() {\n * React.useEffect(() => {\n * const subscription = Notifications.addNotificationResponseReceivedListener(response => {\n * const url = response.notification.request.content.data.url;\n * Linking.openURL(url);\n * });\n * return () => subscription.remove();\n * }, []);\n *\n * return (\n * // Your app content\n * );\n * }\n * ```\n * @header listen\n */\nexport function addNotificationResponseReceivedListener(\n listener: (event: NotificationResponse) => void\n): EventSubscription {\n return emitter.addListener<NotificationResponse>(\n didReceiveNotificationResponseEventName,\n (response: NotificationResponse) => {\n const mappedResponse = mapNotificationResponse(response);\n listener(mappedResponse);\n }\n );\n}\n\n/**\n * @deprecated call `remove()` on the subscription object instead.\n *\n * Removes a notification subscription returned by an `addNotificationListener` call.\n * @param subscription A subscription returned by `addNotificationListener` method.\n * @header listen\n */\nexport function removeNotificationSubscription(subscription: EventSubscription) {\n console.warn(\n '`removeNotificationSubscription` is deprecated. Call `subscription.remove()` instead.'\n );\n if (typeof subscription?.remove === 'function') {\n subscription.remove();\n } else {\n throw new Error(\n `removeNotificationSubscription: Provided value is not a subscription: ${subscription}`\n );\n }\n}\n\n/**\n * Gets the notification response that was received most recently\n * (a notification response designates an interaction with a notification, such as tapping on it).\n *\n * - `null` - if no notification response has been received yet\n * - a [`NotificationResponse`](#notificationresponse) object - if a notification response was received\n */\nexport async function getLastNotificationResponseAsync(): Promise<NotificationResponse | null> {\n if (!NotificationsEmitterModule.getLastNotificationResponseAsync) {\n throw new UnavailabilityError('ExpoNotifications', 'getLastNotificationResponseAsync');\n }\n const response = await NotificationsEmitterModule.getLastNotificationResponseAsync();\n const mappedResponse = response ? mapNotificationResponse(response) : response;\n return mappedResponse;\n}\n\n/**\n * Clears the notification response that was received most recently. May be used\n * when an app selects a route based on the notification response, and it is undesirable\n * to continue selecting the route after the response has already been handled.\n *\n * If a component is using the [`useLastNotificationResponse`](#uselastnotificationresponse) hook,\n * this call will also clear the value returned by the hook.\n *\n * @return A promise that resolves if the native call was successful.\n */\nexport async function clearLastNotificationResponseAsync(): Promise<void> {\n if (!NotificationsEmitterModule.clearLastNotificationResponseAsync) {\n throw new UnavailabilityError('ExpoNotifications', 'getLastNotificationResponseAsync');\n }\n await NotificationsEmitterModule.clearLastNotificationResponseAsync();\n // Emit event to clear any useLastNotificationResponse hooks, after native call succeeds\n emitter.emit(didClearNotificationResponseEventName, []);\n}\n\n/**\n * @hidden\n */\nexport function addNotificationResponseClearedListener(listener: () => void): EventSubscription {\n return emitter.addListener<void>(didClearNotificationResponseEventName, listener);\n}\n"]}
1
+ {"version":3,"file":"NotificationsEmitter.js","sourceRoot":"","sources":["../src/NotificationsEmitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAA0B,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAGpG,OAAO,0BAA0B,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE3F,iCAAiC;AACjC,MAAM,OAAO,GAAG,IAAI,kBAAkB,CAAC,0BAA0B,CAAC,CAAC;AAEnE,MAAM,+BAA+B,GAAG,0BAA0B,CAAC;AACnE,MAAM,6BAA6B,GAAG,wBAAwB,CAAC;AAC/D,MAAM,uCAAuC,GAAG,kCAAkC,CAAC;AACnF,MAAM,qCAAqC,GAAG,gCAAgC,CAAC;AAE/E,eAAe;AACf,MAAM,CAAC,MAAM,yBAAyB,GAAG,4CAA4C,CAAC;AAEtF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,+BAA+B,CAC7C,QAAuC;IAEvC,OAAO,OAAO,CAAC,WAAW,CACxB,+BAA+B,EAC/B,CAAC,YAA0B,EAAE,EAAE;QAC7B,MAAM,kBAAkB,GAAG,eAAe,CAAC,YAAY,CAAC,CAAC;QACzD,QAAQ,CAAC,kBAAkB,CAAC,CAAC;IAC/B,CAAC,CACF,CAAC;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;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,kCAAkC;IACtD,6BAA6B,EAAE,CAAC;AAClC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,6BAA6B;IAC3C,IAAI,CAAC,0BAA0B,CAAC,6BAA6B,EAAE,CAAC;QAC9D,MAAM,IAAI,mBAAmB,CAAC,mBAAmB,EAAE,+BAA+B,CAAC,CAAC;IACtF,CAAC;IACD,0BAA0B,CAAC,6BAA6B,EAAE,CAAC;IAC3D,wFAAwF;IACxF,OAAO,CAAC,IAAI,CAAC,qCAAqC,EAAE,EAAE,CAAC,CAAC;AAC1D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sCAAsC,CAAC,QAAoB;IACzE,OAAO,OAAO,CAAC,WAAW,CAAO,qCAAqC,EAAE,QAAQ,CAAC,CAAC;AACpF,CAAC","sourcesContent":["import { LegacyEventEmitter, type EventSubscription, UnavailabilityError } from 'expo-modules-core';\n\nimport { Notification, NotificationResponse } from './Notifications.types';\nimport NotificationsEmitterModule from './NotificationsEmitterModule';\nimport { mapNotification, mapNotificationResponse } from './utils/mapNotificationResponse';\n\n// Web uses SyntheticEventEmitter\nconst emitter = new LegacyEventEmitter(NotificationsEmitterModule);\n\nconst didReceiveNotificationEventName = 'onDidReceiveNotification';\nconst didDropNotificationsEventName = 'onNotificationsDeleted';\nconst didReceiveNotificationResponseEventName = 'onDidReceiveNotificationResponse';\nconst didClearNotificationResponseEventName = 'onDidClearNotificationResponse';\n\n// @docsMissing\nexport const DEFAULT_ACTION_IDENTIFIER = 'expo.modules.notifications.actions.DEFAULT';\n\n/**\n * Listeners registered by this method will be called whenever a notification is received while the app is running.\n * @param listener A function accepting a notification ([`Notification`](#notification)) as an argument.\n * @return An [`EventSubscription`](#eventsubscription) object represents the subscription of the provided listener.\n * @example Registering a notification listener using a React hook:\n * ```jsx\n * import React from 'react';\n * import * as Notifications from 'expo-notifications';\n *\n * export default function App() {\n * React.useEffect(() => {\n * const subscription = Notifications.addNotificationReceivedListener(notification => {\n * console.log(notification);\n * });\n * return () => subscription.remove();\n * }, []);\n *\n * return (\n * // Your app content\n * );\n * }\n * ```\n * @header listen\n */\nexport function addNotificationReceivedListener(\n listener: (event: Notification) => void\n): EventSubscription {\n return emitter.addListener<Notification>(\n didReceiveNotificationEventName,\n (notification: Notification) => {\n const mappedNotification = mapNotification(notification);\n listener(mappedNotification);\n }\n );\n}\n\n/**\n * Listeners registered by this method will be called whenever some notifications have been dropped by the server.\n * Applicable only to Firebase Cloud Messaging which we use as a notifications service on Android. It corresponds to `onDeletedMessages()` callback.\n * More information can be found in [Firebase docs](https://firebase.google.com/docs/cloud-messaging/android/receive#override-ondeletedmessages).\n * @param listener A callback function.\n * @return An [`EventSubscription`](#eventsubscription) object represents the subscription of the provided listener.\n * @header listen\n */\nexport function addNotificationsDroppedListener(listener: () => void): EventSubscription {\n return emitter.addListener<void>(didDropNotificationsEventName, listener);\n}\n\n/**\n * Listeners registered by this method will be called whenever a user interacts with a notification (for example, taps on it).\n * @param listener A function accepting notification response ([`NotificationResponse`](#notificationresponse)) as an argument.\n * @return An [`EventSubscription`](#eventsubscription) object represents the subscription of the provided listener.\n * @example Register a notification responder listener:\n * ```jsx\n * import React from 'react';\n * import { Linking } from 'react-native';\n * import * as Notifications from 'expo-notifications';\n *\n * export default function Container() {\n * React.useEffect(() => {\n * const subscription = Notifications.addNotificationResponseReceivedListener(response => {\n * const url = response.notification.request.content.data.url;\n * Linking.openURL(url);\n * });\n * return () => subscription.remove();\n * }, []);\n *\n * return (\n * // Your app content\n * );\n * }\n * ```\n * @header listen\n */\nexport function addNotificationResponseReceivedListener(\n listener: (event: NotificationResponse) => void\n): EventSubscription {\n return emitter.addListener<NotificationResponse>(\n didReceiveNotificationResponseEventName,\n (response: NotificationResponse) => {\n const mappedResponse = mapNotificationResponse(response);\n listener(mappedResponse);\n }\n );\n}\n\n/**\n * @deprecated call `remove()` on the subscription object instead.\n *\n * Removes a notification subscription returned by an `addNotificationListener` call.\n * @param subscription A subscription returned by `addNotificationListener` method.\n * @header listen\n */\nexport function removeNotificationSubscription(subscription: EventSubscription) {\n console.warn(\n '`removeNotificationSubscription` is deprecated. Call `subscription.remove()` instead.'\n );\n if (typeof subscription?.remove === 'function') {\n subscription.remove();\n } else {\n throw new Error(\n `removeNotificationSubscription: Provided value is not a subscription: ${subscription}`\n );\n }\n}\n\n/**\n * Gets the notification response that was received most recently\n * (a notification response designates an interaction with a notification, such as tapping on it).\n *\n * - `null` - if no notification response has been received yet\n * - a [`NotificationResponse`](#notificationresponse) object - if a notification response was received\n */\nexport async function getLastNotificationResponseAsync(): Promise<NotificationResponse | null> {\n return getLastNotificationResponse();\n}\n\n/**\n * Gets the notification response that was received most recently\n * (a notification response designates an interaction with a notification, such as tapping on it).\n *\n * - `null` - if no notification response has been received yet\n * - a [`NotificationResponse`](#notificationresponse) object - if a notification response was received\n */\nexport function getLastNotificationResponse(): NotificationResponse | null {\n if (!NotificationsEmitterModule.getLastNotificationResponse) {\n throw new UnavailabilityError('ExpoNotifications', 'getLastNotificationResponse');\n }\n const response = NotificationsEmitterModule.getLastNotificationResponse();\n const mappedResponse = response ? mapNotificationResponse(response) : response;\n return mappedResponse;\n}\n\n/**\n * Clears the notification response that was received most recently. May be used\n * when an app selects a route based on the notification response, and it is undesirable\n * to continue selecting the route after the response has already been handled.\n *\n * If a component is using the [`useLastNotificationResponse`](#uselastnotificationresponse) hook,\n * this call will also clear the value returned by the hook.\n *\n * @return A promise that resolves if the native call was successful.\n */\nexport async function clearLastNotificationResponseAsync(): Promise<void> {\n clearLastNotificationResponse();\n}\n\n/**\n * Clears the notification response that was received most recently. May be used\n * when an app selects a route based on the notification response, and it is undesirable\n * to continue selecting the route after the response has already been handled.\n *\n * If a component is using the [`useLastNotificationResponse`](#uselastnotificationresponse) hook,\n * this call will also clear the value returned by the hook.\n *\n */\nexport function clearLastNotificationResponse(): void {\n if (!NotificationsEmitterModule.clearLastNotificationResponse) {\n throw new UnavailabilityError('ExpoNotifications', 'clearLastNotificationResponse');\n }\n NotificationsEmitterModule.clearLastNotificationResponse();\n // Emit event to clear any useLastNotificationResponse hooks, after native call succeeds\n emitter.emit(didClearNotificationResponseEventName, []);\n}\n\n/**\n * @hidden\n */\nexport function addNotificationResponseClearedListener(listener: () => void): EventSubscription {\n return emitter.addListener<void>(didClearNotificationResponseEventName, listener);\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import { ProxyNativeModule } from 'expo-modules-core';
2
2
  import { NotificationResponse } from './Notifications.types';
3
3
  export interface NotificationsEmitterModule extends ProxyNativeModule {
4
- getLastNotificationResponseAsync?: () => Promise<NotificationResponse | null>;
4
+ getLastNotificationResponse?: () => NotificationResponse | null;
5
+ clearLastNotificationResponse?: () => void;
5
6
  }
6
7
  //# sourceMappingURL=NotificationsEmitterModule.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationsEmitterModule.types.d.ts","sourceRoot":"","sources":["../src/NotificationsEmitterModule.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,MAAM,WAAW,0BAA2B,SAAQ,iBAAiB;IACnE,gCAAgC,CAAC,EAAE,MAAM,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;CAC/E"}
1
+ {"version":3,"file":"NotificationsEmitterModule.types.d.ts","sourceRoot":"","sources":["../src/NotificationsEmitterModule.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,MAAM,WAAW,0BAA2B,SAAQ,iBAAiB;IACnE,2BAA2B,CAAC,EAAE,MAAM,oBAAoB,GAAG,IAAI,CAAC;IAChE,6BAA6B,CAAC,EAAE,MAAM,IAAI,CAAC;CAC5C"}
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationsEmitterModule.types.js","sourceRoot":"","sources":["../src/NotificationsEmitterModule.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ProxyNativeModule } from 'expo-modules-core';\n\nimport { NotificationResponse } from './Notifications.types';\n\nexport interface NotificationsEmitterModule extends ProxyNativeModule {\n getLastNotificationResponseAsync?: () => Promise<NotificationResponse | null>;\n}\n"]}
1
+ {"version":3,"file":"NotificationsEmitterModule.types.js","sourceRoot":"","sources":["../src/NotificationsEmitterModule.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ProxyNativeModule } from 'expo-modules-core';\n\nimport { NotificationResponse } from './Notifications.types';\n\nexport interface NotificationsEmitterModule extends ProxyNativeModule {\n getLastNotificationResponse?: () => NotificationResponse | null;\n clearLastNotificationResponse?: () => void;\n}\n"]}
@@ -26,7 +26,7 @@ async function _subscribeDeviceToPushNotificationsAsync() {
26
26
  // @ts-expect-error: TODO: not on the schema
27
27
  const serviceWorkerPath = Constants.expoConfig?.notification?.serviceWorkerPath;
28
28
  if (!serviceWorkerPath) {
29
- throw new CodedError('ERR_NOTIFICATIONS_PUSH_MISSING_CONFIGURATION', 'You must specify `notification.serviceWorkerPath` in `app.json` to use push notifications on the web. Please provide the path to the service worker that will handle notifications.');
29
+ throw new CodedError('ERR_NOTIFICATIONS_PUSH_MISSING_CONFIGURATION', 'You must specify `notification.serviceWorkerPath` in `app.json` to use push notifications on the web. Provide the path to the service worker that will handle notifications.');
30
30
  }
31
31
  guardPermission();
32
32
  let registration = null;
@@ -1 +1 @@
1
- {"version":3,"file":"getDevicePushTokenAsync.web.js","sourceRoot":"","sources":["../src/getDevicePushTokenAsync.web.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAIlD,MAAM,CAAC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AAW,CACnC,IAAI,CAAC,SAAS,CAAC,EAAE,iBAAiB,EAAE,EAAE,gBAAgB,EAAE,EAAE,CAAC,CAC5D,CAAC;IAEF,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AAED,qFAAqF;AACrF,SAAS,sBAAsB,CAAC,YAAoB;IAClD,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAChE,MAAM,MAAM,GAAG,CAAC,YAAY,GAAG,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAE9E,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpC,MAAM,WAAW,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QACxC,WAAW,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import Constants from 'expo-constants';\nimport { CodedError, Platform } from 'expo-modules-core';\nimport { DeviceEventEmitter } from 'react-native';\n\nimport { DevicePushToken } from './Tokens.types';\n\nexport default async function getDevicePushTokenAsync(): Promise<DevicePushToken> {\n const data = await _subscribeDeviceToPushNotificationsAsync();\n DeviceEventEmitter.emit('onDevicePushToken', { devicePushToken: data });\n return { type: Platform.OS, data };\n}\n\nfunction guardPermission() {\n if (!('Notification' in window)) {\n throw new CodedError(\n 'ERR_UNAVAILABLE',\n 'The Web Notifications API is not available on this device.'\n );\n }\n if (!navigator.serviceWorker) {\n throw new CodedError(\n 'ERR_UNAVAILABLE',\n 'Notifications cannot be used because the service worker API is not supported on this device. This might also happen because your web page does not support HTTPS.'\n );\n }\n if (Notification.permission !== 'granted') {\n throw new CodedError(\n 'ERR_NOTIFICATIONS_PERMISSION_DENIED',\n `Cannot use web notifications without permissions granted. Request permissions with \"expo-permissions\".`\n );\n }\n}\n\nasync function _subscribeDeviceToPushNotificationsAsync(): Promise<DevicePushToken['data']> {\n // @ts-expect-error: TODO: not on the schema\n const vapidPublicKey: string | null = Constants.expoConfig?.notification?.vapidPublicKey;\n if (!vapidPublicKey) {\n throw new CodedError(\n 'ERR_NOTIFICATIONS_PUSH_WEB_MISSING_CONFIG',\n 'You must provide `notification.vapidPublicKey` in `app.json` to use push notifications on web. Learn more: https://docs.expo.dev/versions/latest/guides/using-vapid/.'\n );\n }\n\n // @ts-expect-error: TODO: not on the schema\n const serviceWorkerPath = Constants.expoConfig?.notification?.serviceWorkerPath;\n if (!serviceWorkerPath) {\n throw new CodedError(\n 'ERR_NOTIFICATIONS_PUSH_MISSING_CONFIGURATION',\n 'You must specify `notification.serviceWorkerPath` in `app.json` to use push notifications on the web. Please provide the path to the service worker that will handle notifications.'\n );\n }\n guardPermission();\n\n let registration: ServiceWorkerRegistration | null = null;\n try {\n registration = await navigator.serviceWorker.register(serviceWorkerPath);\n } catch (error) {\n throw new CodedError(\n 'ERR_NOTIFICATIONS_PUSH_REGISTRATION_FAILED',\n `Could not register this device for push notifications because the service worker (${serviceWorkerPath}) could not be registered: ${error}`\n );\n }\n await navigator.serviceWorker.ready;\n\n if (!registration.active) {\n throw new CodedError(\n 'ERR_NOTIFICATIONS_PUSH_REGISTRATION_FAILED',\n 'Could not register this device for push notifications because the service worker is not active.'\n );\n }\n\n const subscribeOptions = {\n userVisibleOnly: true,\n applicationServerKey: _urlBase64ToUint8Array(vapidPublicKey),\n };\n let pushSubscription: PushSubscription | null = null;\n try {\n pushSubscription = await registration.pushManager.subscribe(subscribeOptions);\n } catch (error) {\n throw new CodedError(\n 'ERR_NOTIFICATIONS_PUSH_REGISTRATION_FAILED',\n 'The device was unable to register for remote notifications with the browser endpoint. (' +\n error +\n ')'\n );\n }\n const pushSubscriptionJson = pushSubscription.toJSON();\n\n const subscriptionObject = {\n endpoint: pushSubscriptionJson.endpoint,\n keys: {\n p256dh: pushSubscriptionJson.keys!.p256dh,\n auth: pushSubscriptionJson.keys!.auth,\n },\n };\n\n // Store notification icon string in service worker.\n // This message is received by `/expo-service-worker.js`.\n // We wrap it with `fromExpoWebClient` to make sure other message\n // will not override content such as `notificationIcon`.\n // https://stackoverflow.com/a/35729334/2603230\n const notificationIcon = (Constants.expoConfig?.notification ?? {}).icon;\n await registration.active.postMessage(\n JSON.stringify({ fromExpoWebClient: { notificationIcon } })\n );\n\n return subscriptionObject;\n}\n\n// https://github.com/web-push-libs/web-push#using-vapid-key-for-applicationserverkey\nfunction _urlBase64ToUint8Array(base64String: string): Uint8Array {\n const padding = '='.repeat((4 - (base64String.length % 4)) % 4);\n const base64 = (base64String + padding).replace(/-/g, '+').replace(/_/g, '/');\n\n const rawData = window.atob(base64);\n const outputArray = new Uint8Array(rawData.length);\n\n for (let i = 0; i < rawData.length; ++i) {\n outputArray[i] = rawData.charCodeAt(i);\n }\n return outputArray;\n}\n"]}
1
+ {"version":3,"file":"getDevicePushTokenAsync.web.js","sourceRoot":"","sources":["../src/getDevicePushTokenAsync.web.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAIlD,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,uBAAuB;IACnD,MAAM,IAAI,GAAG,MAAM,wCAAwC,EAAE,CAAC;IAC9D,kBAAkB,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC;IACxE,OAAO,EAAE,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D,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAChE,MAAM,MAAM,GAAG,CAAC,YAAY,GAAG,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAE9E,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpC,MAAM,WAAW,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QACxC,WAAW,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import Constants from 'expo-constants';\nimport { CodedError, Platform } from 'expo-modules-core';\nimport { DeviceEventEmitter } from 'react-native';\n\nimport { DevicePushToken } from './Tokens.types';\n\nexport default async function getDevicePushTokenAsync(): Promise<DevicePushToken> {\n const data = await _subscribeDeviceToPushNotificationsAsync();\n DeviceEventEmitter.emit('onDevicePushToken', { devicePushToken: data });\n return { type: Platform.OS, data };\n}\n\nfunction guardPermission() {\n if (!('Notification' in window)) {\n throw new CodedError(\n 'ERR_UNAVAILABLE',\n 'The Web Notifications API is not available on this device.'\n );\n }\n if (!navigator.serviceWorker) {\n throw new CodedError(\n 'ERR_UNAVAILABLE',\n 'Notifications cannot be used because the service worker API is not supported on this device. This might also happen because your web page does not support HTTPS.'\n );\n }\n if (Notification.permission !== 'granted') {\n throw new CodedError(\n 'ERR_NOTIFICATIONS_PERMISSION_DENIED',\n `Cannot use web notifications without permissions granted. Request permissions with \"expo-permissions\".`\n );\n }\n}\n\nasync function _subscribeDeviceToPushNotificationsAsync(): Promise<DevicePushToken['data']> {\n // @ts-expect-error: TODO: not on the schema\n const vapidPublicKey: string | null = Constants.expoConfig?.notification?.vapidPublicKey;\n if (!vapidPublicKey) {\n throw new CodedError(\n 'ERR_NOTIFICATIONS_PUSH_WEB_MISSING_CONFIG',\n 'You must provide `notification.vapidPublicKey` in `app.json` to use push notifications on web. Learn more: https://docs.expo.dev/versions/latest/guides/using-vapid/.'\n );\n }\n\n // @ts-expect-error: TODO: not on the schema\n const serviceWorkerPath = Constants.expoConfig?.notification?.serviceWorkerPath;\n if (!serviceWorkerPath) {\n throw new CodedError(\n 'ERR_NOTIFICATIONS_PUSH_MISSING_CONFIGURATION',\n 'You must specify `notification.serviceWorkerPath` in `app.json` to use push notifications on the web. Provide the path to the service worker that will handle notifications.'\n );\n }\n guardPermission();\n\n let registration: ServiceWorkerRegistration | null = null;\n try {\n registration = await navigator.serviceWorker.register(serviceWorkerPath);\n } catch (error) {\n throw new CodedError(\n 'ERR_NOTIFICATIONS_PUSH_REGISTRATION_FAILED',\n `Could not register this device for push notifications because the service worker (${serviceWorkerPath}) could not be registered: ${error}`\n );\n }\n await navigator.serviceWorker.ready;\n\n if (!registration.active) {\n throw new CodedError(\n 'ERR_NOTIFICATIONS_PUSH_REGISTRATION_FAILED',\n 'Could not register this device for push notifications because the service worker is not active.'\n );\n }\n\n const subscribeOptions = {\n userVisibleOnly: true,\n applicationServerKey: _urlBase64ToUint8Array(vapidPublicKey),\n };\n let pushSubscription: PushSubscription | null = null;\n try {\n pushSubscription = await registration.pushManager.subscribe(subscribeOptions);\n } catch (error) {\n throw new CodedError(\n 'ERR_NOTIFICATIONS_PUSH_REGISTRATION_FAILED',\n 'The device was unable to register for remote notifications with the browser endpoint. (' +\n error +\n ')'\n );\n }\n const pushSubscriptionJson = pushSubscription.toJSON();\n\n const subscriptionObject = {\n endpoint: pushSubscriptionJson.endpoint,\n keys: {\n p256dh: pushSubscriptionJson.keys!.p256dh,\n auth: pushSubscriptionJson.keys!.auth,\n },\n };\n\n // Store notification icon string in service worker.\n // This message is received by `/expo-service-worker.js`.\n // We wrap it with `fromExpoWebClient` to make sure other message\n // will not override content such as `notificationIcon`.\n // https://stackoverflow.com/a/35729334/2603230\n const notificationIcon = (Constants.expoConfig?.notification ?? {}).icon;\n await registration.active.postMessage(\n JSON.stringify({ fromExpoWebClient: { notificationIcon } })\n );\n\n return subscriptionObject;\n}\n\n// https://github.com/web-push-libs/web-push#using-vapid-key-for-applicationserverkey\nfunction _urlBase64ToUint8Array(base64String: string): Uint8Array {\n const padding = '='.repeat((4 - (base64String.length % 4)) % 4);\n const base64 = (base64String + padding).replace(/-/g, '+').replace(/_/g, '/');\n\n const rawData = window.atob(base64);\n const outputArray = new Uint8Array(rawData.length);\n\n for (let i = 0; i < rawData.length; ++i) {\n outputArray[i] = rawData.charCodeAt(i);\n }\n return outputArray;\n}\n"]}
package/build/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { isRunningInExpoGo } from 'expo';
2
2
  function areWeTestingWithJest() {
3
- return process.env.JEST_WORKER_ID !== undefined || process.env.NODE_ENV === 'TEST';
3
+ return process.env.JEST_WORKER_ID !== undefined || process.env.NODE_ENV?.toLowerCase() === 'test';
4
4
  }
5
5
  if (isRunningInExpoGo() && !areWeTestingWithJest()) {
6
6
  const message = '`expo-notifications` functionality is not fully supported in Expo Go:\n' +
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAEzC,SAAS,oBAAoB;IAC3B,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,CAAC;AACrF,CAAC;AAED,IAAI,iBAAiB,EAAE,IAAI,CAAC,oBAAoB,EAAE,EAAE,CAAC;IACnD,MAAM,OAAO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I,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AACnG,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACnF,OAAO,EAAE,OAAO,IAAI,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AACjG,OAAO,EAAE,OAAO,IAAI,oCAAoC,EAAE,MAAM,wCAAwC,CAAC;AACzG,OAAO,EAAE,OAAO,IAAI,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAC7F,OAAO,EAAE,OAAO,IAAI,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AACzF,OAAO,EAAE,OAAO,IAAI,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AAC/F,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,OAAO,IAAI,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,qCAAqC,EAAE,MAAM,sCAAsC,CAAC;AAC7F,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACvE,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yCAAyC,CAAC;AACxD,cAAc,oCAAoC,CAAC;AACnD,cAAc,iCAAiC,CAAC;AAChD,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC","sourcesContent":["import { isRunningInExpoGo } from 'expo';\n\nfunction areWeTestingWithJest() {\n return process.env.JEST_WORKER_ID !== undefined || process.env.NODE_ENV === 'TEST';\n}\n\nif (isRunningInExpoGo() && !areWeTestingWithJest()) {\n const message =\n '`expo-notifications` functionality is not fully supported in Expo Go:\\n' +\n 'We recommend you instead use a development build to avoid limitations. Learn more: https://expo.fyi/dev-client.';\n console.warn(message);\n}\n\nexport { default as getDevicePushTokenAsync } from './getDevicePushTokenAsync';\nexport { default as unregisterForNotificationsAsync } from './unregisterForNotificationsAsync';\nexport { default as getExpoPushTokenAsync } from './getExpoPushTokenAsync';\nexport { default as getPresentedNotificationsAsync } from './getPresentedNotificationsAsync';\nexport { default as presentNotificationAsync } from './presentNotificationAsync';\nexport { default as dismissNotificationAsync } from './dismissNotificationAsync';\nexport { default as dismissAllNotificationsAsync } from './dismissAllNotificationsAsync';\nexport { default as getNotificationChannelsAsync } from './getNotificationChannelsAsync';\nexport { default as getNotificationChannelAsync } from './getNotificationChannelAsync';\nexport { default as setNotificationChannelAsync } from './setNotificationChannelAsync';\nexport { default as deleteNotificationChannelAsync } from './deleteNotificationChannelAsync';\nexport { default as getNotificationChannelGroupsAsync } from './getNotificationChannelGroupsAsync';\nexport { default as getNotificationChannelGroupAsync } from './getNotificationChannelGroupAsync';\nexport { default as setNotificationChannelGroupAsync } from './setNotificationChannelGroupAsync';\nexport { default as deleteNotificationChannelGroupAsync } from './deleteNotificationChannelGroupAsync';\nexport { default as getBadgeCountAsync } from './getBadgeCountAsync';\nexport { default as setBadgeCountAsync } from './setBadgeCountAsync';\nexport { default as getAllScheduledNotificationsAsync } from './getAllScheduledNotificationsAsync';\nexport { default as scheduleNotificationAsync } from './scheduleNotificationAsync';\nexport { default as cancelScheduledNotificationAsync } from './cancelScheduledNotificationAsync';\nexport { default as cancelAllScheduledNotificationsAsync } from './cancelAllScheduledNotificationsAsync';\nexport { default as getNotificationCategoriesAsync } from './getNotificationCategoriesAsync';\nexport { default as setNotificationCategoryAsync } from './setNotificationCategoryAsync';\nexport { default as deleteNotificationCategoryAsync } from './deleteNotificationCategoryAsync';\nexport { default as getNextTriggerDateAsync } from './getNextTriggerDateAsync';\nexport { default as useLastNotificationResponse } from './useLastNotificationResponse';\nexport { setAutoServerRegistrationEnabledAsync } from './DevicePushTokenAutoRegistration.fx';\nexport { default as registerTaskAsync } from './registerTaskAsync';\nexport { default as unregisterTaskAsync } from './unregisterTaskAsync';\nexport * from './TokenEmitter';\nexport * from './NotificationsEmitter';\nexport * from './NotificationsHandler';\nexport * from './NotificationPermissions';\nexport * from './NotificationChannelGroupManager.types';\nexport * from './NotificationChannelManager.types';\nexport * from './NotificationPermissions.types';\nexport * from './Notifications.types';\nexport * from './Tokens.types';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAEzC,SAAS,oBAAoB;IAC3B,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,WAAW,EAAE,KAAK,MAAM,CAAC;AACpG,CAAC;AAED,IAAI,iBAAiB,EAAE,IAAI,CAAC,oBAAoB,EAAE,EAAE,CAAC;IACnD,MAAM,OAAO,GACX,yEAAyE;QACzE,iHAAiH,CAAC;IACpH,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACxB,CAAC;AAED,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,OAAO,IAAI,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AAC/F,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAC7F,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACjF,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACjF,OAAO,EAAE,OAAO,IAAI,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AACzF,OAAO,EAAE,OAAO,IAAI,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AACzF,OAAO,EAAE,OAAO,IAAI,2BAA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EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACvE,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yCAAyC,CAAC;AACxD,cAAc,oCAAoC,CAAC;AACnD,cAAc,iCAAiC,CAAC;AAChD,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC","sourcesContent":["import { isRunningInExpoGo } from 'expo';\n\nfunction areWeTestingWithJest() {\n return process.env.JEST_WORKER_ID !== undefined || process.env.NODE_ENV?.toLowerCase() === 'test';\n}\n\nif (isRunningInExpoGo() && !areWeTestingWithJest()) {\n const message =\n '`expo-notifications` functionality is not fully supported in Expo Go:\\n' +\n 'We recommend you instead use a development build to avoid limitations. Learn more: https://expo.fyi/dev-client.';\n console.warn(message);\n}\n\nexport { default as getDevicePushTokenAsync } from './getDevicePushTokenAsync';\nexport { default as unregisterForNotificationsAsync } from './unregisterForNotificationsAsync';\nexport { default as getExpoPushTokenAsync } from './getExpoPushTokenAsync';\nexport { default as getPresentedNotificationsAsync } from './getPresentedNotificationsAsync';\nexport { default as presentNotificationAsync } from './presentNotificationAsync';\nexport { default as dismissNotificationAsync } from './dismissNotificationAsync';\nexport { default as dismissAllNotificationsAsync } from './dismissAllNotificationsAsync';\nexport { default as getNotificationChannelsAsync } from './getNotificationChannelsAsync';\nexport { default as getNotificationChannelAsync } from './getNotificationChannelAsync';\nexport { default as setNotificationChannelAsync } from './setNotificationChannelAsync';\nexport { default as deleteNotificationChannelAsync } from './deleteNotificationChannelAsync';\nexport { default as getNotificationChannelGroupsAsync } from './getNotificationChannelGroupsAsync';\nexport { default as getNotificationChannelGroupAsync } from './getNotificationChannelGroupAsync';\nexport { default as setNotificationChannelGroupAsync } from './setNotificationChannelGroupAsync';\nexport { default as deleteNotificationChannelGroupAsync } from './deleteNotificationChannelGroupAsync';\nexport { default as getBadgeCountAsync } from './getBadgeCountAsync';\nexport { default as setBadgeCountAsync } from './setBadgeCountAsync';\nexport { default as getAllScheduledNotificationsAsync } from './getAllScheduledNotificationsAsync';\nexport { default as scheduleNotificationAsync } from './scheduleNotificationAsync';\nexport { default as cancelScheduledNotificationAsync } from './cancelScheduledNotificationAsync';\nexport { default as cancelAllScheduledNotificationsAsync } from './cancelAllScheduledNotificationsAsync';\nexport { default as getNotificationCategoriesAsync } from './getNotificationCategoriesAsync';\nexport { default as setNotificationCategoryAsync } from './setNotificationCategoryAsync';\nexport { default as deleteNotificationCategoryAsync } from './deleteNotificationCategoryAsync';\nexport { default as getNextTriggerDateAsync } from './getNextTriggerDateAsync';\nexport { default as useLastNotificationResponse } from './useLastNotificationResponse';\nexport { setAutoServerRegistrationEnabledAsync } from './DevicePushTokenAutoRegistration.fx';\nexport { default as registerTaskAsync } from './registerTaskAsync';\nexport { default as unregisterTaskAsync } from './unregisterTaskAsync';\nexport * from './TokenEmitter';\nexport * from './NotificationsEmitter';\nexport * from './NotificationsHandler';\nexport * from './NotificationPermissions';\nexport * from './NotificationChannelGroupManager.types';\nexport * from './NotificationChannelManager.types';\nexport * from './NotificationPermissions.types';\nexport * from './Notifications.types';\nexport * from './Tokens.types';\n"]}
@@ -2,7 +2,7 @@ import { NativeNotificationTriggerInput } from './NotificationScheduler.types';
2
2
  import { NotificationRequestInput, NotificationTriggerInput } from './Notifications.types';
3
3
  /**
4
4
  * Schedules a notification to be triggered in the future.
5
- * > **Note:** Please note that this does not mean that the notification will be presented when it is triggered.
5
+ * > **Note:** This does not mean that the notification will be presented when it is triggered.
6
6
  * For the notification to be presented you have to set a notification handler with [`setNotificationHandler`](#setnotificationhandlerhandler)
7
7
  * that will return an appropriate notification behavior. For more information see the example below.
8
8
  * @param request An object describing the notification to be triggered.
@@ -3,7 +3,7 @@ import NotificationScheduler from './NotificationScheduler';
3
3
  import { SchedulableTriggerInputTypes, } from './Notifications.types';
4
4
  /**
5
5
  * Schedules a notification to be triggered in the future.
6
- * > **Note:** Please note that this does not mean that the notification will be presented when it is triggered.
6
+ * > **Note:** This does not mean that the notification will be presented when it is triggered.
7
7
  * For the notification to be presented you have to set a notification handler with [`setNotificationHandler`](#setnotificationhandlerhandler)
8
8
  * that will return an appropriate notification behavior. For more information see the example below.
9
9
  * @param request An object describing the notification to be triggered.
@@ -1 +1 @@
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,yBAAyB,CACrD,OAAiC;IAEjC,IAAI,CAAC,qBAAqB,CAAC,yBAAyB,EAAE,CAAC;QACrD,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,2BAA2B,CAAC,CAAC;IAC9E,CAAC;IAED,OAAO,MAAM,qBAAqB,CAAC,yBAAyB,CAC1D,OAAO,CAAC,UAAU,IAAI,IAAI,CAAC,EAAE,EAAE,EAC/B,OAAO,CAAC,OAAO,EACf,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAC9B,CAAC;AACJ,CAAC;AAID,MAAM,UAAU,YAAY,CAC1B,iBAA2C;IAE3C,IAAI,iBAAiB,KAAK,IAAI,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,iBAAiB,KAAK,SAAS,EAAE,CAAC;QACpC,MAAM,IAAI,SAAS,CACjB,yIAAyI,CAC1I,CAAC;IACJ,CAAC;IAED,MAAM,WAAW,G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E,EAAE,CAAC;oBAC1B,MAAM,IAAI,UAAU,CAAC,2DAA2D,IAAI,EAAE,CAAC,CAAC;gBAC1F,CAAC;gBACD,MAAM;YACR,CAAC;YACD,KAAK,QAAQ,CAAC,CAAC,CAAC;gBACd,MAAM,EAAE,MAAM,EAAE,GAAG,cAAc,CAAC;gBAClC,IAAI,MAAM,GAAG,CAAC,IAAI,MAAM,GAAG,EAAE,EAAE,CAAC;oBAC9B,MAAM,IAAI,UAAU,CAClB,6DAA6D,MAAM,EAAE,CACtE,CAAC;gBACJ,CAAC;gBACD,MAAM;YACR,CAAC;QACH,CAAC;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: Notifications.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: Notifications.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 date = new Date(Date.now() + 60 * 60 * 1000);\n * date.setMinutes(0);\n * date.setSeconds(0);\n *\n * Notifications.scheduleNotificationAsync({\n * content: {\n * title: 'Happy new hour!',\n * },\n * trigger: {\n * type: Notifications.SchedulableTriggerInputTypes.DATE,\n * date\n * },\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 { ...calendarTrigger, repeats: !!repeats, type: 'calendar' };\n }\n return undefined;\n}\n\nfunction parseDateTrigger(trigger: NotificationTriggerInput): NativeDateTriggerInput | undefined {\n if (trigger instanceof Date || typeof trigger === 'number') {\n // TODO @vonovak this branch is not be used by people using TS\n // but was part of the public api previously so we keep it for a bit for JS users\n console.warn(\n `You are using a deprecated parameter type (${trigger}) for the notification trigger. Use \"{ type: 'date', date: someValue }\" instead.`\n );\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 ) {\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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,yBAAyB,CACrD,OAAiC;IAEjC,IAAI,CAAC,qBAAqB,CAAC,yBAAyB,EAAE,CAAC;QACrD,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,2BAA2B,CAAC,CAAC;IAC9E,CAAC;IAED,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C;gBACJ,CAAC;gBACD,MAAM;YACR,CAAC;YACD,KAAK,SAAS,CAAC,CAAC,CAAC;gBACf,MAAM,EAAE,OAAO,EAAE,GAAG,cAAc,CAAC;gBACnC,IAAI,OAAO,GAAG,CAAC,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;oBAC/B,MAAM,IAAI,UAAU,CAClB,6DAA6D,OAAO,EAAE,CACvE,CAAC;gBACJ,CAAC;gBACD,MAAM;YACR,CAAC;YACD,KAAK,MAAM,CAAC,CAAC,CAAC;gBACZ,MAAM,EAAE,IAAI,EAAE,GAAG,cAAc,CAAC;gBAChC,IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,EAAE,EAAE,CAAC;oBAC1B,MAAM,IAAI,UAAU,CAAC,2DAA2D,IAAI,EAAE,CAAC,CAAC;gBAC1F,CAAC;gBACD,MAAM;YACR,CAAC;YACD,KAAK,QAAQ,CAAC,CAAC,CAAC;gBACd,MAAM,EAAE,MAAM,EAAE,GAAG,cAAc,CAAC;gBAClC,IAAI,MAAM,GAAG,CAAC,IAAI,MAAM,GAAG,EAAE,EAAE,CAAC;oBAC9B,MAAM,IAAI,UAAU,CAClB,6DAA6D,MAAM,EAAE,CACtE,CAAC;gBACJ,CAAC;gBACD,MAAM;YACR,CAAC;QACH,CAAC;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:** 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: Notifications.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: Notifications.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 date = new Date(Date.now() + 60 * 60 * 1000);\n * date.setMinutes(0);\n * date.setSeconds(0);\n *\n * Notifications.scheduleNotificationAsync({\n * content: {\n * title: 'Happy new hour!',\n * },\n * trigger: {\n * type: Notifications.SchedulableTriggerInputTypes.DATE,\n * date\n * },\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 { ...calendarTrigger, repeats: !!repeats, type: 'calendar' };\n }\n return undefined;\n}\n\nfunction parseDateTrigger(trigger: NotificationTriggerInput): NativeDateTriggerInput | undefined {\n if (trigger instanceof Date || typeof trigger === 'number') {\n // TODO @vonovak this branch is not be used by people using TS\n // but was part of the public api previously so we keep it for a bit for JS users\n console.warn(\n `You are using a deprecated parameter type (${trigger}) for the notification trigger. Use \"{ type: 'date', date: someValue }\" instead.`\n );\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 ) {\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"]}
@@ -33,7 +33,7 @@
33
33
  "publication": {
34
34
  "groupId": "host.exp.exponent",
35
35
  "artifactId": "expo.modules.notifications",
36
- "version": "0.31.1",
36
+ "version": "0.31.3",
37
37
  "repository": "local-maven-repo"
38
38
  }
39
39
  }
@@ -30,13 +30,11 @@ open class CategoriesModule: Module {
30
30
  let categoryRecord = CategoryRecord(identifier, actions: actions, options: options)
31
31
  let newNotificationCategory = categoryRecord.toUNNotificationCategory()
32
32
  let oldCategories = await UNUserNotificationCenter.current().notificationCategories()
33
- let newCategories = Set(
34
- oldCategories
33
+ let newCategories = oldCategories
35
34
  .filter { oldCategory in
36
35
  return oldCategory.identifier != newNotificationCategory.identifier
37
36
  }
38
37
  .union([newNotificationCategory])
39
- )
40
38
  UNUserNotificationCenter.current().setNotificationCategories(newCategories)
41
39
  return CategoryRecord(newNotificationCategory)
42
40
  }
@@ -47,9 +45,9 @@ open class CategoriesModule: Module {
47
45
  return oldCategory.identifier == identifier
48
46
  }
49
47
  if didDelete {
50
- let newCategories = Set(oldCategories.filter { oldCategory in
48
+ let newCategories = oldCategories.filter { oldCategory in
51
49
  return oldCategory.identifier != identifier
52
- })
50
+ }
53
51
  UNUserNotificationCenter.current().setNotificationCategories(newCategories)
54
52
  }
55
53
  return didDelete
@@ -9,28 +9,26 @@ let onDidReceiveNotificationResponse = "onDidReceiveNotificationResponse"
9
9
  let onDidClearNotificationResponse = "onDidClearNotificationResponse"
10
10
 
11
11
  open class EmitterModule: Module, NotificationDelegate {
12
+ private var lastResponse: [String: Any]?
12
13
  public func definition() -> ModuleDefinition {
13
14
  Name("ExpoNotificationsEmitter")
14
15
 
15
16
  Events([onDidReceiveNotification, onDidReceiveNotificationResponse, onDidClearNotificationResponse])
16
17
 
17
- OnStartObserving {
18
+ OnCreate {
18
19
  NotificationCenterManager.shared.addDelegate(self)
19
20
  }
20
21
 
21
- OnStopObserving {
22
+ OnDestroy {
22
23
  NotificationCenterManager.shared.removeDelegate(self)
23
24
  }
24
25
 
25
- AsyncFunction("getLastNotificationResponseAsync") {() -> [String: Any]? in
26
- if let lastResponse: UNNotificationResponse = NotificationCenterManager.shared.lastResponse {
27
- return EXNotificationSerializer.serializedNotificationResponse(lastResponse)
28
- }
29
- return nil
26
+ Function("getLastNotificationResponse") { () -> [String: Any]? in
27
+ return lastResponse
30
28
  }
31
29
 
32
- AsyncFunction("clearLastNotificationResponseAsync") {
33
- NotificationCenterManager.shared.lastResponse = nil
30
+ Function("clearLastNotificationResponse") {
31
+ lastResponse = nil
34
32
  }
35
33
  }
36
34
 
@@ -40,8 +38,9 @@ open class EmitterModule: Module, NotificationDelegate {
40
38
  }
41
39
 
42
40
  open func didReceive(_ response: UNNotificationResponse, completionHandler: @escaping () -> Void) -> Bool {
43
- NotificationCenterManager.shared.lastResponse = response
44
- self.sendEvent(onDidReceiveNotificationResponse, serializedResponse(response))
41
+ let notificationResponse = serializedResponse(response)
42
+ lastResponse = notificationResponse
43
+ self.sendEvent(onDidReceiveNotificationResponse, notificationResponse)
45
44
  completionHandler()
46
45
  return true
47
46
  }
@@ -41,7 +41,6 @@ public class NotificationCenterManager: NSObject,
41
41
  @objc
42
42
  public static let shared = NotificationCenterManager()
43
43
 
44
- var lastResponse: UNNotificationResponse?
45
44
  var delegates: [NotificationDelegate] = []
46
45
  var pendingResponses: [UNNotificationResponse] = []
47
46
  let userNotificationCenter: UNUserNotificationCenter = UNUserNotificationCenter.current()
@@ -52,7 +51,7 @@ public class NotificationCenterManager: NSObject,
52
51
  NSLog(
53
52
  "[expo-notifications] NotificationCenterManager encountered already present delegate of " +
54
53
  "UNUserNotificationCenter. NotificationCenterManager will not overwrite the value not to break other " +
55
- "features of your app. In return, expo-notifications may not work properly. To fix this problem either " +
54
+ "features of your app. In return, expo-notifications may not work properly. To fix this problem either " +
56
55
  "remove setting of the second delegate, or set the delegate to an instance of NotificationCenterManager " +
57
56
  "manually afterwards."
58
57
  )
@@ -0,0 +1 @@
1
+ 3d445a8ee9d150d620fafe8a452c8c74427a5d835ab1263cec7d4f0743ac8f3d
@@ -0,0 +1 @@
1
+ ad96d4d7ea7b0cecbdea1ce64b28e4dbf5267074af9d7d352bd9f866d67cc32310347a9e68712e8502b55a815890002007a154ca508c0451a61acee82865eb9e
@@ -0,0 +1 @@
1
+ c8e1f39d0b9ee62d8d1ad90195d6ac343b2fc5b5c31680ef91d005b91db0152e
@@ -0,0 +1 @@
1
+ 3d4d78ea43b434e2dc1f98753fe0df9c2231bb9c36ce7049dfad0b96588e754cfbf68dd256de9bb93a4e8724284c14108d1ddbdc5ad334f494cf7e7aa06867cd
@@ -3,7 +3,7 @@
3
3
  "component": {
4
4
  "group": "host.exp.exponent",
5
5
  "module": "expo.modules.notifications",
6
- "version": "0.31.1",
6
+ "version": "0.31.3",
7
7
  "attributes": {
8
8
  "org.gradle.status": "release"
9
9
  }
@@ -24,13 +24,13 @@
24
24
  },
25
25
  "files": [
26
26
  {
27
- "name": "expo.modules.notifications-0.31.1.aar",
28
- "url": "expo.modules.notifications-0.31.1.aar",
29
- "size": 384834,
30
- "sha512": "615ff8e2a6ec1796aa71c2a84c0fa512ebde4d0747454179743afd17f13f079c5d6fa38623556a1a5f4f8f3bacb78f7d48da2e5fd9852a66098701f772802c18",
31
- "sha256": "23a9be6663f1b507bea568cef65e01b7bf357f7cf7903fe562ad557d54501f4b",
32
- "sha1": "5676c7b003206808674304465cfd69c3e1a519b6",
33
- "md5": "5c2a94f4f0a6d8180e989e79827fa52b"
27
+ "name": "expo.modules.notifications-0.31.3.aar",
28
+ "url": "expo.modules.notifications-0.31.3.aar",
29
+ "size": 385766,
30
+ "sha512": "3d4d78ea43b434e2dc1f98753fe0df9c2231bb9c36ce7049dfad0b96588e754cfbf68dd256de9bb93a4e8724284c14108d1ddbdc5ad334f494cf7e7aa06867cd",
31
+ "sha256": "c8e1f39d0b9ee62d8d1ad90195d6ac343b2fc5b5c31680ef91d005b91db0152e",
32
+ "sha1": "e885d81269fd205458059aabf26175be02dab3c6",
33
+ "md5": "0ce7216475af7c010849e878ed7def3d"
34
34
  }
35
35
  ]
36
36
  },
@@ -122,13 +122,13 @@
122
122
  ],
123
123
  "files": [
124
124
  {
125
- "name": "expo.modules.notifications-0.31.1.aar",
126
- "url": "expo.modules.notifications-0.31.1.aar",
127
- "size": 384834,
128
- "sha512": "615ff8e2a6ec1796aa71c2a84c0fa512ebde4d0747454179743afd17f13f079c5d6fa38623556a1a5f4f8f3bacb78f7d48da2e5fd9852a66098701f772802c18",
129
- "sha256": "23a9be6663f1b507bea568cef65e01b7bf357f7cf7903fe562ad557d54501f4b",
130
- "sha1": "5676c7b003206808674304465cfd69c3e1a519b6",
131
- "md5": "5c2a94f4f0a6d8180e989e79827fa52b"
125
+ "name": "expo.modules.notifications-0.31.3.aar",
126
+ "url": "expo.modules.notifications-0.31.3.aar",
127
+ "size": 385766,
128
+ "sha512": "3d4d78ea43b434e2dc1f98753fe0df9c2231bb9c36ce7049dfad0b96588e754cfbf68dd256de9bb93a4e8724284c14108d1ddbdc5ad334f494cf7e7aa06867cd",
129
+ "sha256": "c8e1f39d0b9ee62d8d1ad90195d6ac343b2fc5b5c31680ef91d005b91db0152e",
130
+ "sha1": "e885d81269fd205458059aabf26175be02dab3c6",
131
+ "md5": "0ce7216475af7c010849e878ed7def3d"
132
132
  }
133
133
  ]
134
134
  },
@@ -142,13 +142,13 @@
142
142
  },
143
143
  "files": [
144
144
  {
145
- "name": "expo.modules.notifications-0.31.1-sources.jar",
146
- "url": "expo.modules.notifications-0.31.1-sources.jar",
147
- "size": 99335,
148
- "sha512": "fa1238b48d02574d49ce1d350cd2798799108c9cebf2d0c31b1935aa5df1a5bb0aeda971929615e6ac80337262610fc35a17c98698ed9297ee0c877895d624ea",
149
- "sha256": "c025165651c595088ed4caf14c37e475a573774a65fe3a4ac00426efa8f241ab",
150
- "sha1": "7bf0d3fa2df89a4ab7bd6896781ef76c3354f678",
151
- "md5": "f903db2d952ca23cb0bc9f01a8cd60a9"
145
+ "name": "expo.modules.notifications-0.31.3-sources.jar",
146
+ "url": "expo.modules.notifications-0.31.3-sources.jar",
147
+ "size": 99407,
148
+ "sha512": "ad96d4d7ea7b0cecbdea1ce64b28e4dbf5267074af9d7d352bd9f866d67cc32310347a9e68712e8502b55a815890002007a154ca508c0451a61acee82865eb9e",
149
+ "sha256": "3d445a8ee9d150d620fafe8a452c8c74427a5d835ab1263cec7d4f0743ac8f3d",
150
+ "sha1": "0e7782673df063a4fb10df6a346945f0367e43ba",
151
+ "md5": "aa0446afdc9c4a1fc05d65f48e6cc53b"
152
152
  }
153
153
  ]
154
154
  }
@@ -0,0 +1 @@
1
+ 71fc4b2de46dd78caafd4210cacd43e2d58735abc5e918f9f85abcdeab1e1620
@@ -0,0 +1 @@
1
+ 5b9c5e96c269bb7d6a04310bad28b32bb1cfaf4edd58f4fe112d65f961f5b75a0421bdf43d59357d7ed606a380e5825ff25701c3af91aee495c035e20c030397
@@ -9,7 +9,7 @@
9
9
  <modelVersion>4.0.0</modelVersion>
10
10
  <groupId>host.exp.exponent</groupId>
11
11
  <artifactId>expo.modules.notifications</artifactId>
12
- <version>0.31.1</version>
12
+ <version>0.31.3</version>
13
13
  <packaging>aar</packaging>
14
14
  <name>expo.modules.notifications</name>
15
15
  <url>https://github.com/expo/expo</url>
@@ -0,0 +1 @@
1
+ 9a4e083b3b2653be74088b134b0b0d9bb64a201be7f19fcdd9f2724a29a9ee2d
@@ -0,0 +1 @@
1
+ 102e85ddfb2f724c2ec4191b7203c5110ef0ee82c66be7e9547216a0907e87d0d9b69997e3b2299a08d3ead2e1a23fd748340152856c4a75405e740b70bb868c
@@ -3,11 +3,11 @@
3
3
  <groupId>host.exp.exponent</groupId>
4
4
  <artifactId>expo.modules.notifications</artifactId>
5
5
  <versioning>
6
- <latest>0.31.1</latest>
7
- <release>0.31.1</release>
6
+ <latest>0.31.3</latest>
7
+ <release>0.31.3</release>
8
8
  <versions>
9
- <version>0.31.1</version>
9
+ <version>0.31.3</version>
10
10
  </versions>
11
- <lastUpdated>20250430211459</lastUpdated>
11
+ <lastUpdated>20250604230414</lastUpdated>
12
12
  </versioning>
13
13
  </metadata>
@@ -1 +1 @@
1
- 46626b2a0b9b0ba9e9d9a6d7a31ef32e
1
+ 77f73fe71c81c171ef0a91cc7faee8af
@@ -1 +1 @@
1
- 9c7800b076a655604b07eabcdc11d18bff6e7ba7
1
+ 5195df31a3bb8973d9a010f526c2d8faf47de875
@@ -1 +1 @@
1
- a7e1c52a49caf1edfdac1ca93cd9572663d3e744f287d958ce029cdc1ccb183a
1
+ 498e6debf2f496f9c3b4554a233ce14c62718e474d6ee4b5a7289d557be3761b
@@ -1 +1 @@
1
- 85e6c58bfc54827437dfd8a69e9773012f5edc240665396f94954ce8819e482693652a1dcd8359346a0b6bb720a76c46fa951b928cf1c25f624e990c773b042e
1
+ 5a4c46130e31b3213aba4aa018e1e2c61a57a95b964f3a15b6223ddc26e929d1129bb6aaa8d1fa3f99c68ca109d9eee0d139a8676b0f6871e282537ba2115a0f
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-notifications",
3
- "version": "0.31.1",
3
+ "version": "0.31.3",
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",
@@ -48,10 +48,10 @@
48
48
  "assert": "^2.0.0",
49
49
  "badgin": "^1.1.5",
50
50
  "expo-application": "~6.1.4",
51
- "expo-constants": "~17.1.4"
51
+ "expo-constants": "~17.1.6"
52
52
  },
53
53
  "devDependencies": {
54
- "expo-module-scripts": "^4.1.6",
54
+ "expo-module-scripts": "^4.1.7",
55
55
  "memfs": "^3.2.0"
56
56
  },
57
57
  "peerDependencies": {
@@ -59,5 +59,5 @@
59
59
  "react": "*",
60
60
  "react-native": "*"
61
61
  },
62
- "gitHead": "84355076bc31a356aa3d23257f387f221885f53d"
62
+ "gitHead": "7638c800b57fe78f57cc7f129022f58e84a523c5"
63
63
  }
@@ -41,7 +41,7 @@ export async function getPermissionsAsync() {
41
41
  * import * as Notifications from 'expo-notifications';
42
42
  *
43
43
  * export function requestPermissionsAsync() {
44
- * return await Notifications.requestPermissionsAsync({
44
+ * return Notifications.requestPermissionsAsync({
45
45
  * ios: {
46
46
  * allowAlert: true,
47
47
  * allowBadge: true,
@@ -129,10 +129,21 @@ export function removeNotificationSubscription(subscription: EventSubscription)
129
129
  * - a [`NotificationResponse`](#notificationresponse) object - if a notification response was received
130
130
  */
131
131
  export async function getLastNotificationResponseAsync(): Promise<NotificationResponse | null> {
132
- if (!NotificationsEmitterModule.getLastNotificationResponseAsync) {
133
- throw new UnavailabilityError('ExpoNotifications', 'getLastNotificationResponseAsync');
132
+ return getLastNotificationResponse();
133
+ }
134
+
135
+ /**
136
+ * Gets the notification response that was received most recently
137
+ * (a notification response designates an interaction with a notification, such as tapping on it).
138
+ *
139
+ * - `null` - if no notification response has been received yet
140
+ * - a [`NotificationResponse`](#notificationresponse) object - if a notification response was received
141
+ */
142
+ export function getLastNotificationResponse(): NotificationResponse | null {
143
+ if (!NotificationsEmitterModule.getLastNotificationResponse) {
144
+ throw new UnavailabilityError('ExpoNotifications', 'getLastNotificationResponse');
134
145
  }
135
- const response = await NotificationsEmitterModule.getLastNotificationResponseAsync();
146
+ const response = NotificationsEmitterModule.getLastNotificationResponse();
136
147
  const mappedResponse = response ? mapNotificationResponse(response) : response;
137
148
  return mappedResponse;
138
149
  }
@@ -148,10 +159,23 @@ export async function getLastNotificationResponseAsync(): Promise<NotificationRe
148
159
  * @return A promise that resolves if the native call was successful.
149
160
  */
150
161
  export async function clearLastNotificationResponseAsync(): Promise<void> {
151
- if (!NotificationsEmitterModule.clearLastNotificationResponseAsync) {
152
- throw new UnavailabilityError('ExpoNotifications', 'getLastNotificationResponseAsync');
162
+ clearLastNotificationResponse();
163
+ }
164
+
165
+ /**
166
+ * Clears the notification response that was received most recently. May be used
167
+ * when an app selects a route based on the notification response, and it is undesirable
168
+ * to continue selecting the route after the response has already been handled.
169
+ *
170
+ * If a component is using the [`useLastNotificationResponse`](#uselastnotificationresponse) hook,
171
+ * this call will also clear the value returned by the hook.
172
+ *
173
+ */
174
+ export function clearLastNotificationResponse(): void {
175
+ if (!NotificationsEmitterModule.clearLastNotificationResponse) {
176
+ throw new UnavailabilityError('ExpoNotifications', 'clearLastNotificationResponse');
153
177
  }
154
- await NotificationsEmitterModule.clearLastNotificationResponseAsync();
178
+ NotificationsEmitterModule.clearLastNotificationResponse();
155
179
  // Emit event to clear any useLastNotificationResponse hooks, after native call succeeds
156
180
  emitter.emit(didClearNotificationResponseEventName, []);
157
181
  }
@@ -3,5 +3,6 @@ import { ProxyNativeModule } from 'expo-modules-core';
3
3
  import { NotificationResponse } from './Notifications.types';
4
4
 
5
5
  export interface NotificationsEmitterModule extends ProxyNativeModule {
6
- getLastNotificationResponseAsync?: () => Promise<NotificationResponse | null>;
6
+ getLastNotificationResponse?: () => NotificationResponse | null;
7
+ clearLastNotificationResponse?: () => void;
7
8
  }
@@ -46,7 +46,7 @@ async function _subscribeDeviceToPushNotificationsAsync(): Promise<DevicePushTok
46
46
  if (!serviceWorkerPath) {
47
47
  throw new CodedError(
48
48
  'ERR_NOTIFICATIONS_PUSH_MISSING_CONFIGURATION',
49
- 'You must specify `notification.serviceWorkerPath` in `app.json` to use push notifications on the web. Please provide the path to the service worker that will handle notifications.'
49
+ 'You must specify `notification.serviceWorkerPath` in `app.json` to use push notifications on the web. Provide the path to the service worker that will handle notifications.'
50
50
  );
51
51
  }
52
52
  guardPermission();
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { isRunningInExpoGo } from 'expo';
2
2
 
3
3
  function areWeTestingWithJest() {
4
- return process.env.JEST_WORKER_ID !== undefined || process.env.NODE_ENV === 'TEST';
4
+ return process.env.JEST_WORKER_ID !== undefined || process.env.NODE_ENV?.toLowerCase() === 'test';
5
5
  }
6
6
 
7
7
  if (isRunningInExpoGo() && !areWeTestingWithJest()) {
@@ -19,7 +19,7 @@ import {
19
19
 
20
20
  /**
21
21
  * Schedules a notification to be triggered in the future.
22
- * > **Note:** Please note that this does not mean that the notification will be presented when it is triggered.
22
+ * > **Note:** This does not mean that the notification will be presented when it is triggered.
23
23
  * For the notification to be presented you have to set a notification handler with [`setNotificationHandler`](#setnotificationhandlerhandler)
24
24
  * that will return an appropriate notification behavior. For more information see the example below.
25
25
  * @param request An object describing the notification to be triggered.
@@ -1 +0,0 @@
1
- c025165651c595088ed4caf14c37e475a573774a65fe3a4ac00426efa8f241ab
@@ -1 +0,0 @@
1
- fa1238b48d02574d49ce1d350cd2798799108c9cebf2d0c31b1935aa5df1a5bb0aeda971929615e6ac80337262610fc35a17c98698ed9297ee0c877895d624ea
@@ -1 +0,0 @@
1
- 23a9be6663f1b507bea568cef65e01b7bf357f7cf7903fe562ad557d54501f4b
@@ -1 +0,0 @@
1
- 615ff8e2a6ec1796aa71c2a84c0fa512ebde4d0747454179743afd17f13f079c5d6fa38623556a1a5f4f8f3bacb78f7d48da2e5fd9852a66098701f772802c18
@@ -1 +0,0 @@
1
- 9e269bb96bffb329f45ff9e5fb4c97b7c325636d26aa0f130ece03f3cb3b6ca2
@@ -1 +0,0 @@
1
- 74ec3e3e4fa15d75b8e354d9d35a1dfa425f417fedbdd392de6f98ac8bd3c682797074e57e4264787cb6bd574c5b2ef60a507825f66b785037874a28b58f2432
@@ -1 +0,0 @@
1
- 44373687b388be5228511aae0ead74fb04e4296550509b5a9696d2147df1c9b1
@@ -1 +0,0 @@
1
- f5d295ae91c6a922f5039ad6fbdf82103671d1d5620ba853fd289d4d1f80c8645a15f4cbf8af0d3e85cd998c0d4b701225aeef0c68ab2fd24faa2692ff9736df