@amazon-devices/expo-notifications 2.0.9000000000-rn-83

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 (686) hide show
  1. package/.eslintrc.js +2 -0
  2. package/CHANGELOG.md +478 -0
  3. package/LICENSE +7 -0
  4. package/README.kepler.md +3 -0
  5. package/README.md +2003 -0
  6. package/THIRD_PARTY_NOTICES.txt +4 -0
  7. package/android/build.gradle +125 -0
  8. package/android/src/main/AndroidManifest.xml +39 -0
  9. package/android/src/main/java/expo/modules/notifications/Exceptions.kt +22 -0
  10. package/android/src/main/java/expo/modules/notifications/NotificationsPackage.java +34 -0
  11. package/android/src/main/java/expo/modules/notifications/Utils.kt +19 -0
  12. package/android/src/main/java/expo/modules/notifications/badge/BadgeHelper.kt +24 -0
  13. package/android/src/main/java/expo/modules/notifications/badge/BadgeModule.kt +22 -0
  14. package/android/src/main/java/expo/modules/notifications/notifications/ArgumentsNotificationContentBuilder.java +149 -0
  15. package/android/src/main/java/expo/modules/notifications/notifications/JSONNotificationContentBuilder.java +203 -0
  16. package/android/src/main/java/expo/modules/notifications/notifications/NotificationManager.java +119 -0
  17. package/android/src/main/java/expo/modules/notifications/notifications/NotificationSerializer.java +202 -0
  18. package/android/src/main/java/expo/modules/notifications/notifications/RemoteMessageSerializer.java +104 -0
  19. package/android/src/main/java/expo/modules/notifications/notifications/SoundResolver.java +58 -0
  20. package/android/src/main/java/expo/modules/notifications/notifications/background/BackgroundRemoteNotificationTaskConsumer.java +123 -0
  21. package/android/src/main/java/expo/modules/notifications/notifications/background/ExpoBackgroundNotificationTasksModule.kt +33 -0
  22. package/android/src/main/java/expo/modules/notifications/notifications/categories/ExpoNotificationCategoriesModule.kt +149 -0
  23. package/android/src/main/java/expo/modules/notifications/notifications/categories/serializers/ExpoNotificationsCategoriesSerializer.java +67 -0
  24. package/android/src/main/java/expo/modules/notifications/notifications/categories/serializers/NotificationsCategoriesSerializer.java +11 -0
  25. package/android/src/main/java/expo/modules/notifications/notifications/channels/AbstractNotificationsChannelsProvider.java +81 -0
  26. package/android/src/main/java/expo/modules/notifications/notifications/channels/AndroidXNotificationsChannelsProvider.java +38 -0
  27. package/android/src/main/java/expo/modules/notifications/notifications/channels/InvalidVibrationPatternException.java +14 -0
  28. package/android/src/main/java/expo/modules/notifications/notifications/channels/NotificationChannelGroupManagerModule.kt +70 -0
  29. package/android/src/main/java/expo/modules/notifications/notifications/channels/NotificationChannelManagerModule.kt +83 -0
  30. package/android/src/main/java/expo/modules/notifications/notifications/channels/NotificationsChannelsProvider.java +13 -0
  31. package/android/src/main/java/expo/modules/notifications/notifications/channels/managers/AndroidXNotificationsChannelGroupManager.java +67 -0
  32. package/android/src/main/java/expo/modules/notifications/notifications/channels/managers/AndroidXNotificationsChannelManager.java +196 -0
  33. package/android/src/main/java/expo/modules/notifications/notifications/channels/managers/NotificationsChannelGroupManager.java +28 -0
  34. package/android/src/main/java/expo/modules/notifications/notifications/channels/managers/NotificationsChannelManager.java +28 -0
  35. package/android/src/main/java/expo/modules/notifications/notifications/channels/serializers/ExpoNotificationsChannelGroupSerializer.java +55 -0
  36. package/android/src/main/java/expo/modules/notifications/notifications/channels/serializers/ExpoNotificationsChannelSerializer.java +101 -0
  37. package/android/src/main/java/expo/modules/notifications/notifications/channels/serializers/NotificationsChannelGroupSerializer.java +20 -0
  38. package/android/src/main/java/expo/modules/notifications/notifications/channels/serializers/NotificationsChannelSerializer.java +35 -0
  39. package/android/src/main/java/expo/modules/notifications/notifications/emitting/NotificationsEmitter.kt +78 -0
  40. package/android/src/main/java/expo/modules/notifications/notifications/enums/AudioContentType.java +45 -0
  41. package/android/src/main/java/expo/modules/notifications/notifications/enums/AudioUsage.java +55 -0
  42. package/android/src/main/java/expo/modules/notifications/notifications/enums/NotificationImportance.java +48 -0
  43. package/android/src/main/java/expo/modules/notifications/notifications/enums/NotificationPriority.java +51 -0
  44. package/android/src/main/java/expo/modules/notifications/notifications/enums/NotificationVisibility.java +44 -0
  45. package/android/src/main/java/expo/modules/notifications/notifications/handling/NotificationsHandler.kt +127 -0
  46. package/android/src/main/java/expo/modules/notifications/notifications/handling/SingleNotificationHandlerTask.java +131 -0
  47. package/android/src/main/java/expo/modules/notifications/notifications/interfaces/NotificationBuilder.java +35 -0
  48. package/android/src/main/java/expo/modules/notifications/notifications/interfaces/NotificationListener.java +37 -0
  49. package/android/src/main/java/expo/modules/notifications/notifications/interfaces/NotificationManager.java +22 -0
  50. package/android/src/main/java/expo/modules/notifications/notifications/interfaces/NotificationPresentationEffect.java +11 -0
  51. package/android/src/main/java/expo/modules/notifications/notifications/interfaces/NotificationPresentationEffectsManager.java +7 -0
  52. package/android/src/main/java/expo/modules/notifications/notifications/interfaces/NotificationTrigger.java +19 -0
  53. package/android/src/main/java/expo/modules/notifications/notifications/interfaces/SchedulableNotificationTrigger.java +20 -0
  54. package/android/src/main/java/expo/modules/notifications/notifications/model/Notification.java +59 -0
  55. package/android/src/main/java/expo/modules/notifications/notifications/model/NotificationAction.java +63 -0
  56. package/android/src/main/java/expo/modules/notifications/notifications/model/NotificationBehavior.java +84 -0
  57. package/android/src/main/java/expo/modules/notifications/notifications/model/NotificationCategory.java +61 -0
  58. package/android/src/main/java/expo/modules/notifications/notifications/model/NotificationContent.java +356 -0
  59. package/android/src/main/java/expo/modules/notifications/notifications/model/NotificationRequest.java +66 -0
  60. package/android/src/main/java/expo/modules/notifications/notifications/model/NotificationResponse.java +60 -0
  61. package/android/src/main/java/expo/modules/notifications/notifications/model/TextInputNotificationAction.java +42 -0
  62. package/android/src/main/java/expo/modules/notifications/notifications/model/TextInputNotificationResponse.java +42 -0
  63. package/android/src/main/java/expo/modules/notifications/notifications/model/triggers/FirebaseNotificationTrigger.java +61 -0
  64. package/android/src/main/java/expo/modules/notifications/notifications/presentation/ExpoNotificationPresentationEffectsManager.java +63 -0
  65. package/android/src/main/java/expo/modules/notifications/notifications/presentation/ExpoNotificationPresentationModule.kt +113 -0
  66. package/android/src/main/java/expo/modules/notifications/notifications/presentation/builders/BaseNotificationBuilder.java +50 -0
  67. package/android/src/main/java/expo/modules/notifications/notifications/presentation/builders/CategoryAwareNotificationBuilder.java +80 -0
  68. package/android/src/main/java/expo/modules/notifications/notifications/presentation/builders/ChannelAwareNotificationBuilder.java +135 -0
  69. package/android/src/main/java/expo/modules/notifications/notifications/presentation/builders/ExpoNotificationBuilder.java +295 -0
  70. package/android/src/main/java/expo/modules/notifications/notifications/presentation/effects/BaseNotificationEffect.java +53 -0
  71. package/android/src/main/java/expo/modules/notifications/notifications/scheduling/NotificationScheduler.kt +235 -0
  72. package/android/src/main/java/expo/modules/notifications/notifications/triggers/ChannelAwareTrigger.java +49 -0
  73. package/android/src/main/java/expo/modules/notifications/notifications/triggers/DailyTrigger.java +76 -0
  74. package/android/src/main/java/expo/modules/notifications/notifications/triggers/DateTrigger.java +64 -0
  75. package/android/src/main/java/expo/modules/notifications/notifications/triggers/TimeIntervalTrigger.java +87 -0
  76. package/android/src/main/java/expo/modules/notifications/notifications/triggers/WeeklyTrigger.java +85 -0
  77. package/android/src/main/java/expo/modules/notifications/notifications/triggers/YearlyTrigger.java +94 -0
  78. package/android/src/main/java/expo/modules/notifications/permissions/NotificationPermissionsModule.kt +124 -0
  79. package/android/src/main/java/expo/modules/notifications/serverregistration/InstallationId.java +134 -0
  80. package/android/src/main/java/expo/modules/notifications/serverregistration/RegistrationInfo.kt +24 -0
  81. package/android/src/main/java/expo/modules/notifications/serverregistration/ServerRegistrationModule.kt +32 -0
  82. package/android/src/main/java/expo/modules/notifications/service/ExpoFirebaseMessagingService.kt +15 -0
  83. package/android/src/main/java/expo/modules/notifications/service/NotificationForwarderActivity.kt +33 -0
  84. package/android/src/main/java/expo/modules/notifications/service/NotificationsService.kt +780 -0
  85. package/android/src/main/java/expo/modules/notifications/service/delegates/Base64Serialization.kt +33 -0
  86. package/android/src/main/java/expo/modules/notifications/service/delegates/ExpoCategoriesDelegate.kt +21 -0
  87. package/android/src/main/java/expo/modules/notifications/service/delegates/ExpoHandlingDelegate.kt +146 -0
  88. package/android/src/main/java/expo/modules/notifications/service/delegates/ExpoPresentationDelegate.kt +193 -0
  89. package/android/src/main/java/expo/modules/notifications/service/delegates/ExpoSchedulingDelegate.kt +117 -0
  90. package/android/src/main/java/expo/modules/notifications/service/delegates/FirebaseMessagingDelegate.kt +126 -0
  91. package/android/src/main/java/expo/modules/notifications/service/delegates/SharedPreferencesNotificationCategoriesStore.kt +106 -0
  92. package/android/src/main/java/expo/modules/notifications/service/delegates/SharedPreferencesNotificationsStore.kt +119 -0
  93. package/android/src/main/java/expo/modules/notifications/service/interfaces/CategoriesDelegate.kt +14 -0
  94. package/android/src/main/java/expo/modules/notifications/service/interfaces/FirebaseMessagingDelegate.kt +20 -0
  95. package/android/src/main/java/expo/modules/notifications/service/interfaces/HandlingDelegate.kt +10 -0
  96. package/android/src/main/java/expo/modules/notifications/service/interfaces/PresentationDelegate.kt +11 -0
  97. package/android/src/main/java/expo/modules/notifications/service/interfaces/SchedulingDelegate.kt +13 -0
  98. package/android/src/main/java/expo/modules/notifications/tokens/PushTokenManager.java +88 -0
  99. package/android/src/main/java/expo/modules/notifications/tokens/PushTokenModule.kt +91 -0
  100. package/android/src/main/java/expo/modules/notifications/tokens/interfaces/FirebaseTokenListener.java +16 -0
  101. package/android/src/main/java/expo/modules/notifications/tokens/interfaces/PushTokenListener.java +14 -0
  102. package/android/src/main/java/expo/modules/notifications/tokens/interfaces/PushTokenManager.java +22 -0
  103. package/android/src/main/res/values/strings.xml +4 -0
  104. package/app.plugin.js +1 -0
  105. package/build/BackgroundNotificationTasksModule.d.ts +4 -0
  106. package/build/BackgroundNotificationTasksModule.d.ts.map +1 -0
  107. package/build/BackgroundNotificationTasksModule.js +7 -0
  108. package/build/BackgroundNotificationTasksModule.js.map +1 -0
  109. package/build/BackgroundNotificationTasksModule.kepler.d.ts +3 -0
  110. package/build/BackgroundNotificationTasksModule.kepler.d.ts.map +1 -0
  111. package/build/BackgroundNotificationTasksModule.kepler.js +9 -0
  112. package/build/BackgroundNotificationTasksModule.kepler.js.map +1 -0
  113. package/build/BackgroundNotificationTasksModule.native.d.ts +4 -0
  114. package/build/BackgroundNotificationTasksModule.native.d.ts.map +1 -0
  115. package/build/BackgroundNotificationTasksModule.native.js +3 -0
  116. package/build/BackgroundNotificationTasksModule.native.js.map +1 -0
  117. package/build/BackgroundNotificationTasksModule.types.d.ts +11 -0
  118. package/build/BackgroundNotificationTasksModule.types.d.ts.map +1 -0
  119. package/build/BackgroundNotificationTasksModule.types.js +7 -0
  120. package/build/BackgroundNotificationTasksModule.types.js.map +1 -0
  121. package/build/BackgroundNotificationTasksModule.web.d.ts +6 -0
  122. package/build/BackgroundNotificationTasksModule.web.d.ts.map +1 -0
  123. package/build/BackgroundNotificationTasksModule.web.js +9 -0
  124. package/build/BackgroundNotificationTasksModule.web.js.map +1 -0
  125. package/build/BadgeModule.d.ts +4 -0
  126. package/build/BadgeModule.d.ts.map +1 -0
  127. package/build/BadgeModule.js +5 -0
  128. package/build/BadgeModule.js.map +1 -0
  129. package/build/BadgeModule.kepler.d.ts +3 -0
  130. package/build/BadgeModule.kepler.d.ts.map +1 -0
  131. package/build/BadgeModule.kepler.js +9 -0
  132. package/build/BadgeModule.kepler.js.map +1 -0
  133. package/build/BadgeModule.native.d.ts +4 -0
  134. package/build/BadgeModule.native.d.ts.map +1 -0
  135. package/build/BadgeModule.native.js +12 -0
  136. package/build/BadgeModule.native.js.map +1 -0
  137. package/build/BadgeModule.types.d.ts +10 -0
  138. package/build/BadgeModule.types.d.ts.map +1 -0
  139. package/build/BadgeModule.types.js +2 -0
  140. package/build/BadgeModule.types.js.map +1 -0
  141. package/build/BadgeModule.web.d.ts +4 -0
  142. package/build/BadgeModule.web.d.ts.map +1 -0
  143. package/build/BadgeModule.web.js +26 -0
  144. package/build/BadgeModule.web.js.map +1 -0
  145. package/build/DevicePushTokenAutoRegistration.fx.d.ts +15 -0
  146. package/build/DevicePushTokenAutoRegistration.fx.d.ts.map +1 -0
  147. package/build/DevicePushTokenAutoRegistration.fx.js +87 -0
  148. package/build/DevicePushTokenAutoRegistration.fx.js.map +1 -0
  149. package/build/NotificationCategoriesModule.d.ts +4 -0
  150. package/build/NotificationCategoriesModule.d.ts.map +1 -0
  151. package/build/NotificationCategoriesModule.js +13 -0
  152. package/build/NotificationCategoriesModule.js.map +1 -0
  153. package/build/NotificationCategoriesModule.kepler.d.ts +3 -0
  154. package/build/NotificationCategoriesModule.kepler.d.ts.map +1 -0
  155. package/build/NotificationCategoriesModule.kepler.js +10 -0
  156. package/build/NotificationCategoriesModule.kepler.js.map +1 -0
  157. package/build/NotificationCategoriesModule.native.d.ts +4 -0
  158. package/build/NotificationCategoriesModule.native.d.ts.map +1 -0
  159. package/build/NotificationCategoriesModule.native.js +3 -0
  160. package/build/NotificationCategoriesModule.native.js.map +1 -0
  161. package/build/NotificationCategoriesModule.types.d.ts +17 -0
  162. package/build/NotificationCategoriesModule.types.d.ts.map +1 -0
  163. package/build/NotificationCategoriesModule.types.js +2 -0
  164. package/build/NotificationCategoriesModule.types.js.map +1 -0
  165. package/build/NotificationCategoriesModule.web.d.ts +8 -0
  166. package/build/NotificationCategoriesModule.web.d.ts.map +1 -0
  167. package/build/NotificationCategoriesModule.web.js +12 -0
  168. package/build/NotificationCategoriesModule.web.js.map +1 -0
  169. package/build/NotificationChannelGroupManager.d.ts +4 -0
  170. package/build/NotificationChannelGroupManager.d.ts.map +1 -0
  171. package/build/NotificationChannelGroupManager.js +5 -0
  172. package/build/NotificationChannelGroupManager.js.map +1 -0
  173. package/build/NotificationChannelGroupManager.kepler.d.ts +3 -0
  174. package/build/NotificationChannelGroupManager.kepler.d.ts.map +1 -0
  175. package/build/NotificationChannelGroupManager.kepler.js +9 -0
  176. package/build/NotificationChannelGroupManager.kepler.js.map +1 -0
  177. package/build/NotificationChannelGroupManager.native.d.ts +4 -0
  178. package/build/NotificationChannelGroupManager.native.d.ts.map +1 -0
  179. package/build/NotificationChannelGroupManager.native.js +3 -0
  180. package/build/NotificationChannelGroupManager.native.js.map +1 -0
  181. package/build/NotificationChannelGroupManager.types.d.ts +28 -0
  182. package/build/NotificationChannelGroupManager.types.d.ts.map +1 -0
  183. package/build/NotificationChannelGroupManager.types.js +2 -0
  184. package/build/NotificationChannelGroupManager.types.js.map +1 -0
  185. package/build/NotificationChannelManager.d.ts +4 -0
  186. package/build/NotificationChannelManager.d.ts.map +1 -0
  187. package/build/NotificationChannelManager.js +5 -0
  188. package/build/NotificationChannelManager.js.map +1 -0
  189. package/build/NotificationChannelManager.kepler.d.ts +3 -0
  190. package/build/NotificationChannelManager.kepler.d.ts.map +1 -0
  191. package/build/NotificationChannelManager.kepler.js +9 -0
  192. package/build/NotificationChannelManager.kepler.js.map +1 -0
  193. package/build/NotificationChannelManager.native.d.ts +4 -0
  194. package/build/NotificationChannelManager.native.d.ts.map +1 -0
  195. package/build/NotificationChannelManager.native.js +3 -0
  196. package/build/NotificationChannelManager.native.js.map +1 -0
  197. package/build/NotificationChannelManager.types.d.ts +91 -0
  198. package/build/NotificationChannelManager.types.d.ts.map +1 -0
  199. package/build/NotificationChannelManager.types.js +53 -0
  200. package/build/NotificationChannelManager.types.js.map +1 -0
  201. package/build/NotificationPermissions.d.ts +56 -0
  202. package/build/NotificationPermissions.d.ts.map +1 -0
  203. package/build/NotificationPermissions.js +79 -0
  204. package/build/NotificationPermissions.js.map +1 -0
  205. package/build/NotificationPermissions.types.d.ts +94 -0
  206. package/build/NotificationPermissions.types.d.ts.map +1 -0
  207. package/build/NotificationPermissions.types.js +21 -0
  208. package/build/NotificationPermissions.types.js.map +1 -0
  209. package/build/NotificationPermissionsModule.d.ts +4 -0
  210. package/build/NotificationPermissionsModule.d.ts.map +1 -0
  211. package/build/NotificationPermissionsModule.js +67 -0
  212. package/build/NotificationPermissionsModule.js.map +1 -0
  213. package/build/NotificationPermissionsModule.kepler.d.ts +3 -0
  214. package/build/NotificationPermissionsModule.kepler.d.ts.map +1 -0
  215. package/build/NotificationPermissionsModule.kepler.js +9 -0
  216. package/build/NotificationPermissionsModule.kepler.js.map +1 -0
  217. package/build/NotificationPermissionsModule.native.d.ts +4 -0
  218. package/build/NotificationPermissionsModule.native.d.ts.map +1 -0
  219. package/build/NotificationPermissionsModule.native.js +3 -0
  220. package/build/NotificationPermissionsModule.native.js.map +1 -0
  221. package/build/NotificationPermissionsModule.types.d.ts +7 -0
  222. package/build/NotificationPermissionsModule.types.d.ts.map +1 -0
  223. package/build/NotificationPermissionsModule.types.js +2 -0
  224. package/build/NotificationPermissionsModule.types.js.map +1 -0
  225. package/build/NotificationPresenterModule.d.ts +4 -0
  226. package/build/NotificationPresenterModule.d.ts.map +1 -0
  227. package/build/NotificationPresenterModule.js +5 -0
  228. package/build/NotificationPresenterModule.js.map +1 -0
  229. package/build/NotificationPresenterModule.kepler.d.ts +4 -0
  230. package/build/NotificationPresenterModule.kepler.d.ts.map +1 -0
  231. package/build/NotificationPresenterModule.kepler.js +55 -0
  232. package/build/NotificationPresenterModule.kepler.js.map +1 -0
  233. package/build/NotificationPresenterModule.native.d.ts +4 -0
  234. package/build/NotificationPresenterModule.native.d.ts.map +1 -0
  235. package/build/NotificationPresenterModule.native.js +3 -0
  236. package/build/NotificationPresenterModule.native.js.map +1 -0
  237. package/build/NotificationPresenterModule.types.d.ts +9 -0
  238. package/build/NotificationPresenterModule.types.d.ts.map +1 -0
  239. package/build/NotificationPresenterModule.types.js +2 -0
  240. package/build/NotificationPresenterModule.types.js.map +1 -0
  241. package/build/NotificationScheduler.d.ts +4 -0
  242. package/build/NotificationScheduler.d.ts.map +1 -0
  243. package/build/NotificationScheduler.js +5 -0
  244. package/build/NotificationScheduler.js.map +1 -0
  245. package/build/NotificationScheduler.kepler.d.ts +4 -0
  246. package/build/NotificationScheduler.kepler.d.ts.map +1 -0
  247. package/build/NotificationScheduler.kepler.js +50 -0
  248. package/build/NotificationScheduler.kepler.js.map +1 -0
  249. package/build/NotificationScheduler.native.d.ts +4 -0
  250. package/build/NotificationScheduler.native.d.ts.map +1 -0
  251. package/build/NotificationScheduler.native.js +3 -0
  252. package/build/NotificationScheduler.native.js.map +1 -0
  253. package/build/NotificationScheduler.types.d.ts +65 -0
  254. package/build/NotificationScheduler.types.d.ts.map +1 -0
  255. package/build/NotificationScheduler.types.js +2 -0
  256. package/build/NotificationScheduler.types.js.map +1 -0
  257. package/build/Notifications.types.d.ts +666 -0
  258. package/build/Notifications.types.d.ts.map +1 -0
  259. package/build/Notifications.types.js +12 -0
  260. package/build/Notifications.types.js.map +1 -0
  261. package/build/NotificationsEmitter.d.ts +75 -0
  262. package/build/NotificationsEmitter.d.ts.map +1 -0
  263. package/build/NotificationsEmitter.js +95 -0
  264. package/build/NotificationsEmitter.js.map +1 -0
  265. package/build/NotificationsEmitterModule.d.ts +4 -0
  266. package/build/NotificationsEmitterModule.d.ts.map +1 -0
  267. package/build/NotificationsEmitterModule.js +12 -0
  268. package/build/NotificationsEmitterModule.js.map +1 -0
  269. package/build/NotificationsEmitterModule.kepler.d.ts +3 -0
  270. package/build/NotificationsEmitterModule.kepler.d.ts.map +1 -0
  271. package/build/NotificationsEmitterModule.kepler.js +9 -0
  272. package/build/NotificationsEmitterModule.kepler.js.map +1 -0
  273. package/build/NotificationsEmitterModule.native.d.ts +4 -0
  274. package/build/NotificationsEmitterModule.native.d.ts.map +1 -0
  275. package/build/NotificationsEmitterModule.native.js +3 -0
  276. package/build/NotificationsEmitterModule.native.js.map +1 -0
  277. package/build/NotificationsEmitterModule.types.d.ts +6 -0
  278. package/build/NotificationsEmitterModule.types.d.ts.map +1 -0
  279. package/build/NotificationsEmitterModule.types.js +2 -0
  280. package/build/NotificationsEmitterModule.types.js.map +1 -0
  281. package/build/NotificationsHandler.d.ts +60 -0
  282. package/build/NotificationsHandler.d.ts.map +1 -0
  283. package/build/NotificationsHandler.js +72 -0
  284. package/build/NotificationsHandler.js.map +1 -0
  285. package/build/NotificationsHandlerModule.d.ts +4 -0
  286. package/build/NotificationsHandlerModule.d.ts.map +1 -0
  287. package/build/NotificationsHandlerModule.js +12 -0
  288. package/build/NotificationsHandlerModule.js.map +1 -0
  289. package/build/NotificationsHandlerModule.kepler.d.ts +3 -0
  290. package/build/NotificationsHandlerModule.kepler.d.ts.map +1 -0
  291. package/build/NotificationsHandlerModule.kepler.js +9 -0
  292. package/build/NotificationsHandlerModule.kepler.js.map +1 -0
  293. package/build/NotificationsHandlerModule.native.d.ts +4 -0
  294. package/build/NotificationsHandlerModule.native.d.ts.map +1 -0
  295. package/build/NotificationsHandlerModule.native.js +3 -0
  296. package/build/NotificationsHandlerModule.native.js.map +1 -0
  297. package/build/NotificationsHandlerModule.types.d.ts +6 -0
  298. package/build/NotificationsHandlerModule.types.d.ts.map +1 -0
  299. package/build/NotificationsHandlerModule.types.js +2 -0
  300. package/build/NotificationsHandlerModule.types.js.map +1 -0
  301. package/build/PushTokenManager.d.ts +4 -0
  302. package/build/PushTokenManager.d.ts.map +1 -0
  303. package/build/PushTokenManager.js +12 -0
  304. package/build/PushTokenManager.js.map +1 -0
  305. package/build/PushTokenManager.kepler.d.ts +3 -0
  306. package/build/PushTokenManager.kepler.d.ts.map +1 -0
  307. package/build/PushTokenManager.kepler.js +9 -0
  308. package/build/PushTokenManager.kepler.js.map +1 -0
  309. package/build/PushTokenManager.native.d.ts +4 -0
  310. package/build/PushTokenManager.native.d.ts.map +1 -0
  311. package/build/PushTokenManager.native.js +3 -0
  312. package/build/PushTokenManager.native.js.map +1 -0
  313. package/build/PushTokenManager.types.d.ts +6 -0
  314. package/build/PushTokenManager.types.d.ts.map +1 -0
  315. package/build/PushTokenManager.types.js +2 -0
  316. package/build/PushTokenManager.types.js.map +1 -0
  317. package/build/ServerRegistrationModule.d.ts +4 -0
  318. package/build/ServerRegistrationModule.d.ts.map +1 -0
  319. package/build/ServerRegistrationModule.js +5 -0
  320. package/build/ServerRegistrationModule.js.map +1 -0
  321. package/build/ServerRegistrationModule.kepler.d.ts +3 -0
  322. package/build/ServerRegistrationModule.kepler.d.ts.map +1 -0
  323. package/build/ServerRegistrationModule.kepler.js +9 -0
  324. package/build/ServerRegistrationModule.kepler.js.map +1 -0
  325. package/build/ServerRegistrationModule.native.d.ts +4 -0
  326. package/build/ServerRegistrationModule.native.d.ts.map +1 -0
  327. package/build/ServerRegistrationModule.native.js +3 -0
  328. package/build/ServerRegistrationModule.native.js.map +1 -0
  329. package/build/ServerRegistrationModule.types.d.ts +7 -0
  330. package/build/ServerRegistrationModule.types.d.ts.map +1 -0
  331. package/build/ServerRegistrationModule.types.js +2 -0
  332. package/build/ServerRegistrationModule.types.js.map +1 -0
  333. package/build/ServerRegistrationModule.web.d.ts +4 -0
  334. package/build/ServerRegistrationModule.web.d.ts.map +1 -0
  335. package/build/ServerRegistrationModule.web.js +50 -0
  336. package/build/ServerRegistrationModule.web.js.map +1 -0
  337. package/build/TokenEmitter.d.ts +42 -0
  338. package/build/TokenEmitter.d.ts.map +1 -0
  339. package/build/TokenEmitter.js +44 -0
  340. package/build/TokenEmitter.js.map +1 -0
  341. package/build/Tokens.types.d.ts +99 -0
  342. package/build/Tokens.types.d.ts.map +1 -0
  343. package/build/Tokens.types.js +2 -0
  344. package/build/Tokens.types.js.map +1 -0
  345. package/build/cancelAllScheduledNotificationsAsync.d.ts +7 -0
  346. package/build/cancelAllScheduledNotificationsAsync.d.ts.map +1 -0
  347. package/build/cancelAllScheduledNotificationsAsync.js +14 -0
  348. package/build/cancelAllScheduledNotificationsAsync.js.map +1 -0
  349. package/build/cancelScheduledNotificationAsync.d.ts +22 -0
  350. package/build/cancelScheduledNotificationAsync.d.ts.map +1 -0
  351. package/build/cancelScheduledNotificationAsync.js +29 -0
  352. package/build/cancelScheduledNotificationAsync.js.map +1 -0
  353. package/build/deleteNotificationCategoryAsync.d.ts +11 -0
  354. package/build/deleteNotificationCategoryAsync.d.ts.map +1 -0
  355. package/build/deleteNotificationCategoryAsync.js +19 -0
  356. package/build/deleteNotificationCategoryAsync.js.map +1 -0
  357. package/build/deleteNotificationChannelAsync.android.d.ts +2 -0
  358. package/build/deleteNotificationChannelAsync.android.d.ts.map +1 -0
  359. package/build/deleteNotificationChannelAsync.android.js +9 -0
  360. package/build/deleteNotificationChannelAsync.android.js.map +1 -0
  361. package/build/deleteNotificationChannelAsync.d.ts +9 -0
  362. package/build/deleteNotificationChannelAsync.d.ts.map +1 -0
  363. package/build/deleteNotificationChannelAsync.js +11 -0
  364. package/build/deleteNotificationChannelAsync.js.map +1 -0
  365. package/build/deleteNotificationChannelGroupAsync.android.d.ts +2 -0
  366. package/build/deleteNotificationChannelGroupAsync.android.d.ts.map +1 -0
  367. package/build/deleteNotificationChannelGroupAsync.android.js +9 -0
  368. package/build/deleteNotificationChannelGroupAsync.android.js.map +1 -0
  369. package/build/deleteNotificationChannelGroupAsync.d.ts +9 -0
  370. package/build/deleteNotificationChannelGroupAsync.d.ts.map +1 -0
  371. package/build/deleteNotificationChannelGroupAsync.js +11 -0
  372. package/build/deleteNotificationChannelGroupAsync.js.map +1 -0
  373. package/build/dismissAllNotificationsAsync.d.ts +7 -0
  374. package/build/dismissAllNotificationsAsync.d.ts.map +1 -0
  375. package/build/dismissAllNotificationsAsync.js +14 -0
  376. package/build/dismissAllNotificationsAsync.js.map +1 -0
  377. package/build/dismissNotificationAsync.d.ts +8 -0
  378. package/build/dismissNotificationAsync.d.ts.map +1 -0
  379. package/build/dismissNotificationAsync.js +15 -0
  380. package/build/dismissNotificationAsync.js.map +1 -0
  381. package/build/getAllScheduledNotificationsAsync.d.ts +8 -0
  382. package/build/getAllScheduledNotificationsAsync.d.ts.map +1 -0
  383. package/build/getAllScheduledNotificationsAsync.js +14 -0
  384. package/build/getAllScheduledNotificationsAsync.js.map +1 -0
  385. package/build/getBadgeCountAsync.d.ts +8 -0
  386. package/build/getBadgeCountAsync.d.ts.map +1 -0
  387. package/build/getBadgeCountAsync.js +15 -0
  388. package/build/getBadgeCountAsync.js.map +1 -0
  389. package/build/getDevicePushTokenAsync.d.ts +8 -0
  390. package/build/getDevicePushTokenAsync.d.ts.map +1 -0
  391. package/build/getDevicePushTokenAsync.js +27 -0
  392. package/build/getDevicePushTokenAsync.js.map +1 -0
  393. package/build/getDevicePushTokenAsync.web.d.ts +3 -0
  394. package/build/getDevicePushTokenAsync.web.d.ts.map +1 -0
  395. package/build/getDevicePushTokenAsync.web.js +84 -0
  396. package/build/getDevicePushTokenAsync.web.js.map +1 -0
  397. package/build/getExpoPushTokenAsync.d.ts +40 -0
  398. package/build/getExpoPushTokenAsync.d.ts.map +1 -0
  399. package/build/getExpoPushTokenAsync.js +177 -0
  400. package/build/getExpoPushTokenAsync.js.map +1 -0
  401. package/build/getNextTriggerDateAsync.d.ts +26 -0
  402. package/build/getNextTriggerDateAsync.d.ts.map +1 -0
  403. package/build/getNextTriggerDateAsync.js +33 -0
  404. package/build/getNextTriggerDateAsync.js.map +1 -0
  405. package/build/getNotificationCategoriesAsync.d.ts +11 -0
  406. package/build/getNotificationCategoriesAsync.d.ts.map +1 -0
  407. package/build/getNotificationCategoriesAsync.js +18 -0
  408. package/build/getNotificationCategoriesAsync.js.map +1 -0
  409. package/build/getNotificationChannelAsync.android.d.ts +3 -0
  410. package/build/getNotificationChannelAsync.android.d.ts.map +1 -0
  411. package/build/getNotificationChannelAsync.android.js +9 -0
  412. package/build/getNotificationChannelAsync.android.js.map +1 -0
  413. package/build/getNotificationChannelAsync.d.ts +11 -0
  414. package/build/getNotificationChannelAsync.d.ts.map +1 -0
  415. package/build/getNotificationChannelAsync.js +13 -0
  416. package/build/getNotificationChannelAsync.js.map +1 -0
  417. package/build/getNotificationChannelGroupAsync.android.d.ts +3 -0
  418. package/build/getNotificationChannelGroupAsync.android.d.ts.map +1 -0
  419. package/build/getNotificationChannelGroupAsync.android.js +9 -0
  420. package/build/getNotificationChannelGroupAsync.android.js.map +1 -0
  421. package/build/getNotificationChannelGroupAsync.d.ts +12 -0
  422. package/build/getNotificationChannelGroupAsync.d.ts.map +1 -0
  423. package/build/getNotificationChannelGroupAsync.js +14 -0
  424. package/build/getNotificationChannelGroupAsync.js.map +1 -0
  425. package/build/getNotificationChannelGroupsAsync.android.d.ts +3 -0
  426. package/build/getNotificationChannelGroupsAsync.android.d.ts.map +1 -0
  427. package/build/getNotificationChannelGroupsAsync.android.js +9 -0
  428. package/build/getNotificationChannelGroupsAsync.android.js.map +1 -0
  429. package/build/getNotificationChannelGroupsAsync.d.ts +10 -0
  430. package/build/getNotificationChannelGroupsAsync.d.ts.map +1 -0
  431. package/build/getNotificationChannelGroupsAsync.js +12 -0
  432. package/build/getNotificationChannelGroupsAsync.js.map +1 -0
  433. package/build/getNotificationChannelsAsync.android.d.ts +3 -0
  434. package/build/getNotificationChannelsAsync.android.d.ts.map +1 -0
  435. package/build/getNotificationChannelsAsync.android.js +9 -0
  436. package/build/getNotificationChannelsAsync.android.js.map +1 -0
  437. package/build/getNotificationChannelsAsync.d.ts +10 -0
  438. package/build/getNotificationChannelsAsync.d.ts.map +1 -0
  439. package/build/getNotificationChannelsAsync.js +12 -0
  440. package/build/getNotificationChannelsAsync.js.map +1 -0
  441. package/build/getPresentedNotificationsAsync.d.ts +9 -0
  442. package/build/getPresentedNotificationsAsync.d.ts.map +1 -0
  443. package/build/getPresentedNotificationsAsync.js +15 -0
  444. package/build/getPresentedNotificationsAsync.js.map +1 -0
  445. package/build/index.d.ts +39 -0
  446. package/build/index.d.ts.map +1 -0
  447. package/build/index.js +39 -0
  448. package/build/index.js.map +1 -0
  449. package/build/kepler/NotificationContent.d.ts +43 -0
  450. package/build/kepler/NotificationContent.d.ts.map +1 -0
  451. package/build/kepler/NotificationContent.js +96 -0
  452. package/build/kepler/NotificationContent.js.map +1 -0
  453. package/build/kepler/index.d.ts +3 -0
  454. package/build/kepler/index.d.ts.map +1 -0
  455. package/build/kepler/index.js +15 -0
  456. package/build/kepler/index.js.map +1 -0
  457. package/build/kepler/native-notification-manager.d.ts +3 -0
  458. package/build/kepler/native-notification-manager.d.ts.map +1 -0
  459. package/build/kepler/native-notification-manager.js +10 -0
  460. package/build/kepler/native-notification-manager.js.map +1 -0
  461. package/build/kepler/types/NotificationManagerTypes.d.ts +373 -0
  462. package/build/kepler/types/NotificationManagerTypes.d.ts.map +1 -0
  463. package/build/kepler/types/NotificationManagerTypes.js +279 -0
  464. package/build/kepler/types/NotificationManagerTypes.js.map +1 -0
  465. package/build/kepler/types/index.d.ts +3 -0
  466. package/build/kepler/types/index.d.ts.map +1 -0
  467. package/build/kepler/types/index.js +15 -0
  468. package/build/kepler/types/index.js.map +1 -0
  469. package/build/presentNotificationAsync.d.ts +11 -0
  470. package/build/presentNotificationAsync.d.ts.map +1 -0
  471. package/build/presentNotificationAsync.js +22 -0
  472. package/build/presentNotificationAsync.js.map +1 -0
  473. package/build/registerTaskAsync.d.ts +29 -0
  474. package/build/registerTaskAsync.d.ts.map +1 -0
  475. package/build/registerTaskAsync.js +37 -0
  476. package/build/registerTaskAsync.js.map +1 -0
  477. package/build/scheduleNotificationAsync.d.ts +60 -0
  478. package/build/scheduleNotificationAsync.d.ts.map +1 -0
  479. package/build/scheduleNotificationAsync.js +261 -0
  480. package/build/scheduleNotificationAsync.js.map +1 -0
  481. package/build/setBadgeCountAsync.d.ts +19 -0
  482. package/build/setBadgeCountAsync.d.ts.map +1 -0
  483. package/build/setBadgeCountAsync.js +19 -0
  484. package/build/setBadgeCountAsync.js.map +1 -0
  485. package/build/setNotificationCategoryAsync.d.ts +15 -0
  486. package/build/setNotificationCategoryAsync.d.ts.map +1 -0
  487. package/build/setNotificationCategoryAsync.js +22 -0
  488. package/build/setNotificationCategoryAsync.js.map +1 -0
  489. package/build/setNotificationChannelAsync.android.d.ts +3 -0
  490. package/build/setNotificationChannelAsync.android.d.ts.map +1 -0
  491. package/build/setNotificationChannelAsync.android.js +9 -0
  492. package/build/setNotificationChannelAsync.android.js.map +1 -0
  493. package/build/setNotificationChannelAsync.d.ts +22 -0
  494. package/build/setNotificationChannelAsync.d.ts.map +1 -0
  495. package/build/setNotificationChannelAsync.js +24 -0
  496. package/build/setNotificationChannelAsync.js.map +1 -0
  497. package/build/setNotificationChannelGroupAsync.android.d.ts +3 -0
  498. package/build/setNotificationChannelGroupAsync.android.d.ts.map +1 -0
  499. package/build/setNotificationChannelGroupAsync.android.js +9 -0
  500. package/build/setNotificationChannelGroupAsync.android.js.map +1 -0
  501. package/build/setNotificationChannelGroupAsync.d.ts +12 -0
  502. package/build/setNotificationChannelGroupAsync.d.ts.map +1 -0
  503. package/build/setNotificationChannelGroupAsync.js +14 -0
  504. package/build/setNotificationChannelGroupAsync.js.map +1 -0
  505. package/build/unregisterForNotificationsAsync.d.ts +2 -0
  506. package/build/unregisterForNotificationsAsync.d.ts.map +1 -0
  507. package/build/unregisterForNotificationsAsync.js +10 -0
  508. package/build/unregisterForNotificationsAsync.js.map +1 -0
  509. package/build/unregisterTaskAsync.d.ts +7 -0
  510. package/build/unregisterTaskAsync.d.ts.map +1 -0
  511. package/build/unregisterTaskAsync.js +15 -0
  512. package/build/unregisterTaskAsync.js.map +1 -0
  513. package/build/useLastNotificationResponse.d.ts +38 -0
  514. package/build/useLastNotificationResponse.d.ts.map +1 -0
  515. package/build/useLastNotificationResponse.js +63 -0
  516. package/build/useLastNotificationResponse.js.map +1 -0
  517. package/build/utils/keplerUuidUtils.d.ts +5 -0
  518. package/build/utils/keplerUuidUtils.d.ts.map +1 -0
  519. package/build/utils/keplerUuidUtils.js +15 -0
  520. package/build/utils/keplerUuidUtils.js.map +1 -0
  521. package/build/utils/updateDevicePushTokenAsync.d.ts +3 -0
  522. package/build/utils/updateDevicePushTokenAsync.d.ts.map +1 -0
  523. package/build/utils/updateDevicePushTokenAsync.js +115 -0
  524. package/build/utils/updateDevicePushTokenAsync.js.map +1 -0
  525. package/expo-module.config.json +20 -0
  526. package/ios/EXNotifications/Building/EXNotificationBuilder.h +19 -0
  527. package/ios/EXNotifications/Building/EXNotificationBuilder.m +91 -0
  528. package/ios/EXNotifications/EXBadgeModule.h +11 -0
  529. package/ios/EXNotifications/EXBadgeModule.m +36 -0
  530. package/ios/EXNotifications/EXServerRegistrationModule.h +19 -0
  531. package/ios/EXNotifications/EXServerRegistrationModule.m +194 -0
  532. package/ios/EXNotifications/Notifications/Background/EXBackgroundNotificationTasksModule.h +16 -0
  533. package/ios/EXNotifications/Notifications/Background/EXBackgroundNotificationTasksModule.m +62 -0
  534. package/ios/EXNotifications/Notifications/Background/EXBackgroundRemoteNotificationConsumer.h +14 -0
  535. package/ios/EXNotifications/Notifications/Background/EXBackgroundRemoteNotificationConsumer.m +51 -0
  536. package/ios/EXNotifications/Notifications/Categories/EXNotificationCategoriesModule.h +25 -0
  537. package/ios/EXNotifications/Notifications/Categories/EXNotificationCategoriesModule.m +217 -0
  538. package/ios/EXNotifications/Notifications/EXNotificationCenterDelegate.h +29 -0
  539. package/ios/EXNotifications/Notifications/EXNotificationCenterDelegate.m +209 -0
  540. package/ios/EXNotifications/Notifications/EXNotificationSerializer.h +16 -0
  541. package/ios/EXNotifications/Notifications/EXNotificationSerializer.m +232 -0
  542. package/ios/EXNotifications/Notifications/EXNotificationsDelegate.h +27 -0
  543. package/ios/EXNotifications/Notifications/Emitter/EXNotificationsEmitter.h +17 -0
  544. package/ios/EXNotifications/Notifications/Emitter/EXNotificationsEmitter.m +114 -0
  545. package/ios/EXNotifications/Notifications/Handler/EXNotificationsHandlerModule.h +12 -0
  546. package/ios/EXNotifications/Notifications/Handler/EXNotificationsHandlerModule.m +109 -0
  547. package/ios/EXNotifications/Notifications/Handler/EXSingleNotificationHandlerTask.h +33 -0
  548. package/ios/EXNotifications/Notifications/Handler/EXSingleNotificationHandlerTask.m +124 -0
  549. package/ios/EXNotifications/Notifications/NSDictionary+EXNotificationsVerifyingClass.h +7 -0
  550. package/ios/EXNotifications/Notifications/NSDictionary+EXNotificationsVerifyingClass.m +19 -0
  551. package/ios/EXNotifications/Notifications/Presenting/EXNotificationPresentationModule.h +13 -0
  552. package/ios/EXNotifications/Notifications/Presenting/EXNotificationPresentationModule.m +124 -0
  553. package/ios/EXNotifications/Notifications/Scheduling/EXNotificationSchedulerModule.h +21 -0
  554. package/ios/EXNotifications/Notifications/Scheduling/EXNotificationSchedulerModule.m +263 -0
  555. package/ios/EXNotifications/Permissions/EXLegacyRemoteNotificationPermissionRequester.h +13 -0
  556. package/ios/EXNotifications/Permissions/EXLegacyRemoteNotificationPermissionRequester.m +135 -0
  557. package/ios/EXNotifications/Permissions/EXNotificationPermissionsModule.h +8 -0
  558. package/ios/EXNotifications/Permissions/EXNotificationPermissionsModule.m +67 -0
  559. package/ios/EXNotifications/Permissions/EXRemoteNotificationPermissionSingletonModule.h +29 -0
  560. package/ios/EXNotifications/Permissions/EXRemoteNotificationPermissionSingletonModule.m +68 -0
  561. package/ios/EXNotifications/Permissions/EXUserFacingNotificationsPermissionsRequester.h +15 -0
  562. package/ios/EXNotifications/Permissions/EXUserFacingNotificationsPermissionsRequester.m +202 -0
  563. package/ios/EXNotifications/PushToken/EXPushTokenListener.h +14 -0
  564. package/ios/EXNotifications/PushToken/EXPushTokenManager.h +24 -0
  565. package/ios/EXNotifications/PushToken/EXPushTokenManager.m +63 -0
  566. package/ios/EXNotifications/PushToken/EXPushTokenModule.h +9 -0
  567. package/ios/EXNotifications/PushToken/EXPushTokenModule.m +154 -0
  568. package/ios/EXNotifications.podspec +25 -0
  569. package/package.json +67 -0
  570. package/plugin/build/withNotifications.d.ts +28 -0
  571. package/plugin/build/withNotifications.js +12 -0
  572. package/plugin/build/withNotificationsAndroid.d.ts +42 -0
  573. package/plugin/build/withNotificationsAndroid.js +184 -0
  574. package/plugin/build/withNotificationsIOS.d.ts +14 -0
  575. package/plugin/build/withNotificationsIOS.js +58 -0
  576. package/plugin/jest.config.js +1 -0
  577. package/plugin/src/withNotifications.ts +40 -0
  578. package/plugin/src/withNotificationsAndroid.ts +239 -0
  579. package/plugin/src/withNotificationsIOS.ts +78 -0
  580. package/plugin/tsconfig.json +9 -0
  581. package/src/BackgroundNotificationTasksModule.kepler.ts +8 -0
  582. package/src/BackgroundNotificationTasksModule.native.ts +7 -0
  583. package/src/BackgroundNotificationTasksModule.ts +8 -0
  584. package/src/BackgroundNotificationTasksModule.types.ts +12 -0
  585. package/src/BackgroundNotificationTasksModule.web.ts +8 -0
  586. package/src/BadgeModule.kepler.ts +8 -0
  587. package/src/BadgeModule.native.ts +15 -0
  588. package/src/BadgeModule.ts +6 -0
  589. package/src/BadgeModule.types.ts +11 -0
  590. package/src/BadgeModule.web.ts +28 -0
  591. package/src/DevicePushTokenAutoRegistration.fx.ts +119 -0
  592. package/src/NotificationCategoriesModule.kepler.ts +10 -0
  593. package/src/NotificationCategoriesModule.native.ts +7 -0
  594. package/src/NotificationCategoriesModule.ts +15 -0
  595. package/src/NotificationCategoriesModule.types.ts +22 -0
  596. package/src/NotificationCategoriesModule.web.ts +17 -0
  597. package/src/NotificationChannelGroupManager.kepler.ts +8 -0
  598. package/src/NotificationChannelGroupManager.native.ts +7 -0
  599. package/src/NotificationChannelGroupManager.ts +6 -0
  600. package/src/NotificationChannelGroupManager.types.ts +34 -0
  601. package/src/NotificationChannelManager.kepler.ts +8 -0
  602. package/src/NotificationChannelManager.native.ts +5 -0
  603. package/src/NotificationChannelManager.ts +6 -0
  604. package/src/NotificationChannelManager.types.ts +115 -0
  605. package/src/NotificationPermissions.ts +91 -0
  606. package/src/NotificationPermissions.types.ts +102 -0
  607. package/src/NotificationPermissionsModule.kepler.ts +8 -0
  608. package/src/NotificationPermissionsModule.native.ts +7 -0
  609. package/src/NotificationPermissionsModule.ts +83 -0
  610. package/src/NotificationPermissionsModule.types.ts +13 -0
  611. package/src/NotificationPresenterModule.kepler.ts +67 -0
  612. package/src/NotificationPresenterModule.native.ts +5 -0
  613. package/src/NotificationPresenterModule.ts +6 -0
  614. package/src/NotificationPresenterModule.types.ts +13 -0
  615. package/src/NotificationScheduler.kepler.ts +63 -0
  616. package/src/NotificationScheduler.native.ts +5 -0
  617. package/src/NotificationScheduler.ts +6 -0
  618. package/src/NotificationScheduler.types.ts +89 -0
  619. package/src/Notifications.types.ts +722 -0
  620. package/src/NotificationsEmitter.ts +111 -0
  621. package/src/NotificationsEmitterModule.kepler.ts +8 -0
  622. package/src/NotificationsEmitterModule.native.ts +5 -0
  623. package/src/NotificationsEmitterModule.ts +17 -0
  624. package/src/NotificationsEmitterModule.types.ts +7 -0
  625. package/src/NotificationsHandler.ts +120 -0
  626. package/src/NotificationsHandlerModule.kepler.ts +8 -0
  627. package/src/NotificationsHandlerModule.native.ts +5 -0
  628. package/src/NotificationsHandlerModule.ts +17 -0
  629. package/src/NotificationsHandlerModule.types.ts +10 -0
  630. package/src/PushTokenManager.kepler.ts +8 -0
  631. package/src/PushTokenManager.native.ts +5 -0
  632. package/src/PushTokenManager.ts +17 -0
  633. package/src/PushTokenManager.types.ts +6 -0
  634. package/src/ServerRegistrationModule.kepler.ts +8 -0
  635. package/src/ServerRegistrationModule.native.ts +7 -0
  636. package/src/ServerRegistrationModule.ts +6 -0
  637. package/src/ServerRegistrationModule.types.ts +7 -0
  638. package/src/ServerRegistrationModule.web.ts +56 -0
  639. package/src/TokenEmitter.ts +56 -0
  640. package/src/Tokens.types.ts +110 -0
  641. package/src/cancelAllScheduledNotificationsAsync.ts +16 -0
  642. package/src/cancelScheduledNotificationAsync.ts +31 -0
  643. package/src/deleteNotificationCategoryAsync.ts +23 -0
  644. package/src/deleteNotificationChannelAsync.android.ts +11 -0
  645. package/src/deleteNotificationChannelAsync.ts +10 -0
  646. package/src/deleteNotificationChannelGroupAsync.android.ts +11 -0
  647. package/src/deleteNotificationChannelGroupAsync.ts +10 -0
  648. package/src/dismissAllNotificationsAsync.ts +16 -0
  649. package/src/dismissNotificationAsync.ts +19 -0
  650. package/src/getAllScheduledNotificationsAsync.ts +17 -0
  651. package/src/getBadgeCountAsync.ts +17 -0
  652. package/src/getDevicePushTokenAsync.ts +31 -0
  653. package/src/getDevicePushTokenAsync.web.ts +122 -0
  654. package/src/getExpoPushTokenAsync.ts +238 -0
  655. package/src/getNextTriggerDateAsync.ts +38 -0
  656. package/src/getNotificationCategoriesAsync.ts +21 -0
  657. package/src/getNotificationChannelAsync.android.ts +13 -0
  658. package/src/getNotificationChannelAsync.ts +16 -0
  659. package/src/getNotificationChannelGroupAsync.android.ts +14 -0
  660. package/src/getNotificationChannelGroupAsync.ts +17 -0
  661. package/src/getNotificationChannelGroupsAsync.android.ts +13 -0
  662. package/src/getNotificationChannelGroupsAsync.ts +15 -0
  663. package/src/getNotificationChannelsAsync.android.ts +11 -0
  664. package/src/getNotificationChannelsAsync.ts +13 -0
  665. package/src/getPresentedNotificationsAsync.ts +18 -0
  666. package/src/index.ts +38 -0
  667. package/src/kepler/NotificationContent.ts +119 -0
  668. package/src/kepler/index.ts +16 -0
  669. package/src/kepler/native-notification-manager.ts +10 -0
  670. package/src/kepler/types/NotificationManagerTypes.ts +508 -0
  671. package/src/kepler/types/index.ts +16 -0
  672. package/src/presentNotificationAsync.ts +32 -0
  673. package/src/registerTaskAsync.ts +39 -0
  674. package/src/scheduleNotificationAsync.ts +335 -0
  675. package/src/setBadgeCountAsync.ts +32 -0
  676. package/src/setNotificationCategoryAsync.ts +37 -0
  677. package/src/setNotificationChannelAsync.android.ts +15 -0
  678. package/src/setNotificationChannelAsync.ts +28 -0
  679. package/src/setNotificationChannelGroupAsync.android.ts +18 -0
  680. package/src/setNotificationChannelGroupAsync.ts +21 -0
  681. package/src/unregisterForNotificationsAsync.ts +11 -0
  682. package/src/unregisterTaskAsync.ts +17 -0
  683. package/src/useLastNotificationResponse.ts +70 -0
  684. package/src/utils/keplerUuidUtils.ts +29 -0
  685. package/src/utils/updateDevicePushTokenAsync.ts +147 -0
  686. package/tsconfig.json +9 -0
@@ -0,0 +1,33 @@
1
+ package expo.modules.notifications.service.delegates
2
+
3
+ import android.util.Base64
4
+ import java.io.ByteArrayInputStream
5
+ import java.io.ByteArrayOutputStream
6
+ import java.io.IOException
7
+ import java.io.InvalidClassException
8
+ import java.io.ObjectInputStream
9
+ import java.io.ObjectOutputStream
10
+ import java.io.Serializable
11
+
12
+ @Throws(IOException::class)
13
+ fun Serializable.encodedInBase64(): String =
14
+ ByteArrayOutputStream().use { byteArrayOutputStream ->
15
+ ObjectOutputStream(byteArrayOutputStream).use { objectOutputStream ->
16
+ objectOutputStream.writeObject(this)
17
+ Base64.encodeToString(byteArrayOutputStream.toByteArray(), Base64.NO_WRAP)
18
+ }
19
+ }
20
+
21
+ @Throws(IOException::class, ClassNotFoundException::class, InvalidClassException::class)
22
+ inline fun <reified T> String.asBase64EncodedObject(): T =
23
+ ByteArrayInputStream(
24
+ Base64.decode(this, Base64.NO_WRAP)
25
+ ).use { byteArrayInputStream ->
26
+ ObjectInputStream(byteArrayInputStream).use { ois ->
27
+ val o = ois.readObject()
28
+ if (o is T) {
29
+ return o
30
+ }
31
+ throw InvalidClassException("Expected serialized object to be an instance of ${T::class.java}. Found: $o")
32
+ }
33
+ }
@@ -0,0 +1,21 @@
1
+ package expo.modules.notifications.service.delegates
2
+
3
+ import android.content.Context
4
+ import expo.modules.notifications.notifications.model.NotificationCategory
5
+ import expo.modules.notifications.service.interfaces.CategoriesDelegate
6
+
7
+ class ExpoCategoriesDelegate(protected val context: Context) : CategoriesDelegate {
8
+ private val mStore = SharedPreferencesNotificationCategoriesStore(context)
9
+
10
+ override fun getCategories(): Collection<NotificationCategory> {
11
+ return mStore.allNotificationCategories
12
+ }
13
+
14
+ override fun setCategory(category: NotificationCategory): NotificationCategory? {
15
+ return mStore.saveNotificationCategory(category)
16
+ }
17
+
18
+ override fun deleteCategory(identifier: String): Boolean {
19
+ return mStore.removeNotificationCategory(identifier)
20
+ }
21
+ }
@@ -0,0 +1,146 @@
1
+ package expo.modules.notifications.service.delegates
2
+
3
+ import android.app.PendingIntent
4
+ import android.content.Context
5
+ import android.content.Intent
6
+ import android.os.Build
7
+ import android.util.Log
8
+ import androidx.lifecycle.Lifecycle
9
+ import androidx.lifecycle.ProcessLifecycleOwner
10
+ import expo.modules.notifications.notifications.NotificationManager
11
+ import expo.modules.notifications.notifications.model.Notification
12
+ import expo.modules.notifications.notifications.model.NotificationResponse
13
+ import expo.modules.notifications.service.NotificationForwarderActivity
14
+ import expo.modules.notifications.service.NotificationsService
15
+ import expo.modules.notifications.service.interfaces.HandlingDelegate
16
+ import java.lang.ref.WeakReference
17
+ import java.util.*
18
+
19
+ class ExpoHandlingDelegate(protected val context: Context) : HandlingDelegate {
20
+ companion object {
21
+ const val OPEN_APP_INTENT_ACTION = "expo.modules.notifications.OPEN_APP_ACTION"
22
+
23
+ protected var sPendingNotificationResponses: MutableCollection<NotificationResponse> = ArrayList()
24
+
25
+ /**
26
+ * A weak map of listeners -> reference. Used to check quickly whether given listener
27
+ * is already registered and to iterate over when notifying of new token.
28
+ */
29
+ protected var sListenersReferences = WeakHashMap<NotificationManager, WeakReference<NotificationManager>>()
30
+
31
+ /**
32
+ * Used only by [NotificationManager] instances. If you look for a place to register
33
+ * your listener, use [NotificationManager] singleton module.
34
+ *
35
+ * Purposefully the argument is expected to be a [NotificationManager] and just a listener.
36
+ *
37
+ * This class doesn't hold strong references to listeners, so you need to own your listeners.
38
+ *
39
+ * @param listener A listener instance to be informed of new push device tokens.
40
+ */
41
+ fun addListener(listener: NotificationManager) {
42
+ if (sListenersReferences.containsKey(listener)) {
43
+ // Listener is already registered
44
+ return
45
+ }
46
+
47
+ sListenersReferences[listener] = WeakReference(listener)
48
+ if (!sPendingNotificationResponses.isEmpty()) {
49
+ val responseIterator = sPendingNotificationResponses.iterator()
50
+ while (responseIterator.hasNext()) {
51
+ listener.onNotificationResponseReceived(responseIterator.next())
52
+ responseIterator.remove()
53
+ }
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Create a PendingIntent to open app in foreground.
59
+ * We actually start two Activities
60
+ * - the foreground main Activity
61
+ * - the background [NotificationForwarderActivity] Activity that send notification clicked events through broadcast
62
+ */
63
+ fun createPendingIntentForOpeningApp(context: Context, broadcastIntent: Intent, notificationResponse: NotificationResponse): PendingIntent {
64
+ var intentFlags = PendingIntent.FLAG_UPDATE_CURRENT
65
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
66
+ // The intent may include `RemoteInput` from `TextInputNotificationAction`.
67
+ // For intent with RemoteInput, it should be mutable.
68
+ intentFlags = intentFlags or PendingIntent.FLAG_MUTABLE
69
+ }
70
+
71
+ val backgroundActivityIntent = Intent(context, NotificationForwarderActivity::class.java)
72
+ backgroundActivityIntent.data = broadcastIntent.data
73
+ backgroundActivityIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_MULTIPLE_TASK
74
+ backgroundActivityIntent.putExtras(broadcastIntent)
75
+ val requestCode = broadcastIntent.component?.className?.hashCode() ?: NotificationsService::class.java.hashCode()
76
+ return PendingIntent.getActivity(context, requestCode, backgroundActivityIntent, intentFlags)
77
+ }
78
+
79
+ fun openAppToForeground(context: Context, notificationResponse: NotificationResponse) {
80
+ (getNotificationActionLauncher(context) ?: getMainActivityLauncher(context))?.let { intent ->
81
+ NotificationsService.setNotificationResponseToIntent(intent, notificationResponse)
82
+ context.startActivity(intent)
83
+ return
84
+ }
85
+
86
+ Log.w("expo-notifications", "No launch intent found for application. Interacting with the notification won't open the app. The implementation uses `getLaunchIntentForPackage` to find appropriate activity.")
87
+ }
88
+
89
+ private fun getNotificationActionLauncher(context: Context): Intent? {
90
+ Intent(OPEN_APP_INTENT_ACTION).also { intent ->
91
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
92
+ intent.setPackage(context.applicationContext.packageName)
93
+ context.packageManager.resolveActivity(intent, 0)?.let {
94
+ return intent
95
+ }
96
+ }
97
+ return null
98
+ }
99
+
100
+ private fun getMainActivityLauncher(context: Context) =
101
+ context.packageManager.getLaunchIntentForPackage(context.packageName)
102
+ }
103
+
104
+ fun isAppInForeground() = ProcessLifecycleOwner.get().lifecycle.currentState.isAtLeast(Lifecycle.State.RESUMED)
105
+
106
+ fun getListeners() = sListenersReferences.values.mapNotNull { it.get() }
107
+
108
+ override fun handleNotification(notification: Notification) {
109
+ if (isAppInForeground()) {
110
+ getListeners().forEach {
111
+ it.onNotificationReceived(notification)
112
+ }
113
+ } else if (notification.shouldPresent()) {
114
+ NotificationsService.present(context, notification)
115
+ }
116
+ }
117
+
118
+ /**
119
+ * If the app is backgrounded, a notification is only presented if
120
+ * the title and or text is present. If both are null or empty, this is a "data-only" or "silent"
121
+ * notification that should not be presented to the user.
122
+ */
123
+ private fun Notification.shouldPresent(): Boolean {
124
+ return !(notificationRequest.content.title.isNullOrEmpty() && notificationRequest.content.text.isNullOrEmpty())
125
+ }
126
+
127
+ override fun handleNotificationResponse(notificationResponse: NotificationResponse) {
128
+ if (notificationResponse.action.opensAppToForeground()) {
129
+ openAppToForeground(context, notificationResponse)
130
+ }
131
+
132
+ if (getListeners().isEmpty()) {
133
+ sPendingNotificationResponses.add(notificationResponse)
134
+ } else {
135
+ getListeners().forEach {
136
+ it.onNotificationResponseReceived(notificationResponse)
137
+ }
138
+ }
139
+ }
140
+
141
+ override fun handleNotificationsDropped() {
142
+ getListeners().forEach {
143
+ it.onNotificationsDropped()
144
+ }
145
+ }
146
+ }
@@ -0,0 +1,193 @@
1
+ package expo.modules.notifications.service.delegates
2
+
3
+ import android.app.NotificationManager
4
+ import android.content.Context
5
+ import android.media.RingtoneManager
6
+ import android.net.Uri
7
+ import android.os.Bundle
8
+ import android.os.Parcel
9
+ import android.provider.Settings
10
+ import android.service.notification.StatusBarNotification
11
+ import android.util.Log
12
+ import android.util.Pair
13
+ import androidx.core.app.NotificationManagerCompat
14
+ import expo.modules.notifications.notifications.enums.NotificationPriority
15
+ import expo.modules.notifications.notifications.model.Notification
16
+ import expo.modules.notifications.notifications.model.NotificationBehavior
17
+ import expo.modules.notifications.notifications.model.NotificationContent
18
+ import expo.modules.notifications.notifications.model.NotificationRequest
19
+ import expo.modules.notifications.notifications.presentation.builders.CategoryAwareNotificationBuilder
20
+ import expo.modules.notifications.notifications.presentation.builders.ExpoNotificationBuilder
21
+ import expo.modules.notifications.service.interfaces.PresentationDelegate
22
+ import org.json.JSONException
23
+ import org.json.JSONObject
24
+ import java.util.*
25
+
26
+ open class ExpoPresentationDelegate(
27
+ protected val context: Context
28
+ ) : PresentationDelegate {
29
+ companion object {
30
+ protected const val ANDROID_NOTIFICATION_ID = 0
31
+
32
+ protected const val INTERNAL_IDENTIFIER_SCHEME = "expo-notifications"
33
+ protected const val INTERNAL_IDENTIFIER_AUTHORITY = "foreign_notifications"
34
+ protected const val INTERNAL_IDENTIFIER_TAG_KEY = "tag"
35
+ protected const val INTERNAL_IDENTIFIER_ID_KEY = "id"
36
+
37
+ /**
38
+ * Tries to parse given identifier as an internal foreign notification identifier
39
+ * created by us in [getInternalIdentifierKey].
40
+ *
41
+ * @param identifier String identifier of the notification
42
+ * @return Pair of (notification tag, notification id), if the identifier could be parsed. null otherwise.
43
+ */
44
+ fun parseNotificationIdentifier(identifier: String): Pair<String?, Int>? {
45
+ try {
46
+ val parsedIdentifier = Uri.parse(identifier)
47
+ if (INTERNAL_IDENTIFIER_SCHEME == parsedIdentifier.scheme && INTERNAL_IDENTIFIER_AUTHORITY == parsedIdentifier.authority) {
48
+ val tag = parsedIdentifier.getQueryParameter(INTERNAL_IDENTIFIER_TAG_KEY)
49
+ val id = parsedIdentifier.getQueryParameter(INTERNAL_IDENTIFIER_ID_KEY)!!.toInt()
50
+ return Pair(tag, id)
51
+ }
52
+ } catch (e: NullPointerException) {
53
+ Log.e("expo-notifications", "Malformed foreign notification identifier: $identifier", e)
54
+ } catch (e: NumberFormatException) {
55
+ Log.e("expo-notifications", "Malformed foreign notification identifier: $identifier", e)
56
+ } catch (e: UnsupportedOperationException) {
57
+ Log.e("expo-notifications", "Malformed foreign notification identifier: $identifier", e)
58
+ }
59
+ return null
60
+ }
61
+
62
+ /**
63
+ * Creates an identifier for given [StatusBarNotification]. It's supposed to be parsable
64
+ * by [parseNotificationIdentifier].
65
+ *
66
+ * @param notification Notification to be identified
67
+ * @return String identifier
68
+ */
69
+ protected fun getInternalIdentifierKey(notification: StatusBarNotification): String {
70
+ return with(Uri.parse("$INTERNAL_IDENTIFIER_SCHEME://$INTERNAL_IDENTIFIER_AUTHORITY").buildUpon()) {
71
+ notification.tag?.let {
72
+ this.appendQueryParameter(INTERNAL_IDENTIFIER_TAG_KEY, it)
73
+ }
74
+ this.appendQueryParameter(INTERNAL_IDENTIFIER_ID_KEY, notification.id.toString())
75
+ this.toString()
76
+ }
77
+ }
78
+ }
79
+
80
+ /**
81
+ * Callback called to present the system UI for a notification.
82
+ *
83
+ * If the notification behavior is set to not show any alert,
84
+ * we (may) play a sound, but then bail out early. You cannot
85
+ * set badge count without showing a notification.
86
+ */
87
+ override fun presentNotification(notification: Notification, behavior: NotificationBehavior?) {
88
+ if (behavior != null && !behavior.shouldShowAlert()) {
89
+ if (behavior.shouldPlaySound()) {
90
+ RingtoneManager.getRingtone(
91
+ context,
92
+ notification.notificationRequest.content.sound ?: Settings.System.DEFAULT_NOTIFICATION_URI
93
+ ).play()
94
+ }
95
+ return
96
+ }
97
+ NotificationManagerCompat.from(context).notify(
98
+ notification.notificationRequest.identifier,
99
+ getNotifyId(notification.notificationRequest),
100
+ createNotification(notification, behavior)
101
+ )
102
+ }
103
+
104
+ protected open fun getNotifyId(request: NotificationRequest?): Int {
105
+ return ANDROID_NOTIFICATION_ID
106
+ }
107
+
108
+ /**
109
+ * Callback called to fetch a collection of currently displayed notifications.
110
+ *
111
+ * **Note:** This feature is only supported on Android 23+.
112
+ *
113
+ * @return A collection of currently displayed notifications.
114
+ */
115
+ override fun getAllPresentedNotifications(): Collection<Notification> {
116
+ val notificationManager = (context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager)
117
+ return notificationManager.activeNotifications.mapNotNull { getNotification(it) }
118
+ }
119
+
120
+ override fun dismissNotifications(identifiers: Collection<String>) {
121
+ identifiers.forEach { identifier ->
122
+ val foreignNotification = parseNotificationIdentifier(identifier)
123
+ if (foreignNotification != null) {
124
+ // Foreign notification identified by us
125
+ NotificationManagerCompat.from(context).cancel(foreignNotification.first, foreignNotification.second)
126
+ } else {
127
+ // If the notification exists, let's assume it's ours, we have no reason to believe otherwise
128
+ val existingNotification = this.getAllPresentedNotifications().find { it.notificationRequest.identifier == identifier }
129
+ NotificationManagerCompat.from(context).cancel(identifier, getNotifyId(existingNotification?.notificationRequest))
130
+ }
131
+ }
132
+ }
133
+
134
+ override fun dismissAllNotifications() = NotificationManagerCompat.from(context).cancelAll()
135
+
136
+ protected open fun createNotification(notification: Notification, notificationBehavior: NotificationBehavior?): android.app.Notification =
137
+ CategoryAwareNotificationBuilder(context, SharedPreferencesNotificationCategoriesStore(context)).also {
138
+ it.setNotification(notification)
139
+ it.setAllowedBehavior(notificationBehavior)
140
+ }.build()
141
+
142
+ protected open fun getNotification(statusBarNotification: StatusBarNotification): Notification? {
143
+ val notification = statusBarNotification.notification
144
+ notification.extras.getByteArray(ExpoNotificationBuilder.EXTRAS_MARSHALLED_NOTIFICATION_REQUEST_KEY)?.let {
145
+ try {
146
+ with(Parcel.obtain()) {
147
+ this.unmarshall(it, 0, it.size)
148
+ this.setDataPosition(0)
149
+ val request: NotificationRequest = NotificationRequest.CREATOR.createFromParcel(this)
150
+ this.recycle()
151
+ val notificationDate = Date(statusBarNotification.postTime)
152
+ return Notification(request, notificationDate)
153
+ }
154
+ } catch (e: Exception) {
155
+ // Let's catch all the exceptions -- there's nothing we can do here
156
+ // and we'd rather return an array with a single, naively reconstructed notification
157
+ // than throw an exception and return none.
158
+ val message = "Could not have unmarshalled NotificationRequest from (${statusBarNotification.tag}, ${statusBarNotification.id})."
159
+ Log.e("expo-notifications", message)
160
+ }
161
+ }
162
+
163
+ // We weren't able to reconstruct the notification from our data, which means
164
+ // it's either not our notification or we couldn't have unmarshaled it from
165
+ // the byte array. Let's do what we can.
166
+ val content = NotificationContent.Builder()
167
+ .setTitle(notification.extras.getString(android.app.Notification.EXTRA_TITLE))
168
+ .setText(notification.extras.getString(android.app.Notification.EXTRA_TEXT))
169
+ .setSubtitle(notification.extras.getString(android.app.Notification.EXTRA_SUB_TEXT)) // using deprecated field
170
+ .setPriority(NotificationPriority.fromNativeValue(notification.priority)) // using deprecated field
171
+ .setVibrationPattern(notification.vibrate) // using deprecated field
172
+ .setSound(notification.sound)
173
+ .setAutoDismiss(notification.flags and android.app.Notification.FLAG_AUTO_CANCEL != 0)
174
+ .setSticky(notification.flags and android.app.Notification.FLAG_ONGOING_EVENT != 0)
175
+ .setBody(fromBundle(notification.extras))
176
+ .build()
177
+ val request = NotificationRequest(getInternalIdentifierKey(statusBarNotification), content, null)
178
+ return Notification(request, Date(statusBarNotification.postTime))
179
+ }
180
+
181
+ protected open fun fromBundle(bundle: Bundle): JSONObject {
182
+ return JSONObject().also { json ->
183
+ for (key in bundle.keySet()) {
184
+ try {
185
+ json.put(key, JSONObject.wrap(bundle[key]))
186
+ } catch (e: JSONException) {
187
+ // can't do anything about it apart from logging it
188
+ Log.d("expo-notifications", "Error encountered while serializing Android notification extras: " + key + " -> " + bundle[key], e)
189
+ }
190
+ }
191
+ }
192
+ }
193
+ }
@@ -0,0 +1,117 @@
1
+ package expo.modules.notifications.service.delegates
2
+
3
+ import android.app.AlarmManager
4
+ import android.app.PendingIntent
5
+ import android.content.Context
6
+ import android.os.Build
7
+ import android.util.Log
8
+ import androidx.core.app.AlarmManagerCompat
9
+ import expo.modules.notifications.notifications.interfaces.SchedulableNotificationTrigger
10
+ import expo.modules.notifications.notifications.model.Notification
11
+ import expo.modules.notifications.notifications.model.NotificationRequest
12
+ import expo.modules.notifications.service.NotificationsService
13
+ import expo.modules.notifications.service.interfaces.SchedulingDelegate
14
+ import java.io.IOException
15
+ import java.io.InvalidClassException
16
+
17
+ class ExpoSchedulingDelegate(protected val context: Context) : SchedulingDelegate {
18
+ protected val store = SharedPreferencesNotificationsStore(context)
19
+ protected val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager
20
+
21
+ override fun setupScheduledNotifications() {
22
+ store.allNotificationRequests.forEach {
23
+ try {
24
+ scheduleNotification(it)
25
+ } catch (e: Exception) {
26
+ Log.w("expo-notifications", "Notification ${it.identifier} could not have been scheduled: ${e.message}")
27
+ e.printStackTrace()
28
+ }
29
+ }
30
+ }
31
+
32
+ override fun getAllScheduledNotifications(): Collection<NotificationRequest> =
33
+ store.allNotificationRequests
34
+
35
+ override fun getScheduledNotification(identifier: String): NotificationRequest? = try {
36
+ store.getNotificationRequest(identifier)
37
+ } catch (e: IOException) {
38
+ null
39
+ } catch (e: ClassNotFoundException) {
40
+ null
41
+ } catch (e: NullPointerException) {
42
+ null
43
+ }
44
+
45
+ override fun scheduleNotification(request: NotificationRequest) {
46
+ // If the trigger is empty, handle receive immediately and return.
47
+ if (request.trigger == null) {
48
+ NotificationsService.receive(context, Notification(request))
49
+ return
50
+ }
51
+
52
+ if (request.trigger !is SchedulableNotificationTrigger) {
53
+ throw IllegalArgumentException("Notification request \"${request.identifier}\" does not have a schedulable trigger (it's ${request.trigger}). Refusing to schedule.")
54
+ }
55
+
56
+ (request.trigger as SchedulableNotificationTrigger).nextTriggerDate().let { nextTriggerDate ->
57
+ if (nextTriggerDate == null) {
58
+ Log.d("expo-notifications", "Notification request \"${request.identifier}\" will not trigger in the future, removing.")
59
+ NotificationsService.removeScheduledNotification(context, request.identifier)
60
+ } else {
61
+ store.saveNotificationRequest(request)
62
+ setupAlarm(nextTriggerDate.time, NotificationsService.createNotificationTrigger(context, request.identifier))
63
+ }
64
+ }
65
+ }
66
+
67
+ override fun triggerNotification(identifier: String) {
68
+ try {
69
+ val notificationRequest: NotificationRequest = store.getNotificationRequest(identifier)!!
70
+ NotificationsService.receive(context, Notification(notificationRequest))
71
+ NotificationsService.schedule(context, notificationRequest)
72
+ } catch (e: ClassNotFoundException) {
73
+ Log.e("expo-notifications", "An exception occurred while triggering notification " + identifier + ", removing. " + e.message)
74
+ e.printStackTrace()
75
+ NotificationsService.removeScheduledNotification(context, identifier)
76
+ } catch (e: InvalidClassException) {
77
+ Log.e("expo-notifications", "An exception occurred while triggering notification " + identifier + ", removing. " + e.message)
78
+ e.printStackTrace()
79
+ NotificationsService.removeScheduledNotification(context, identifier)
80
+ } catch (e: NullPointerException) {
81
+ Log.e("expo-notifications", "An exception occurred while triggering notification " + identifier + ", removing. " + e.message)
82
+ e.printStackTrace()
83
+ NotificationsService.removeScheduledNotification(context, identifier)
84
+ }
85
+ }
86
+
87
+ override fun removeScheduledNotifications(identifiers: Collection<String>) {
88
+ identifiers.forEach {
89
+ alarmManager.cancel(NotificationsService.createNotificationTrigger(context, it))
90
+ store.removeNotificationRequest(it)
91
+ }
92
+ }
93
+
94
+ override fun removeAllScheduledNotifications() {
95
+ store.removeAllNotificationRequests().forEach {
96
+ alarmManager.cancel(NotificationsService.createNotificationTrigger(context, it))
97
+ }
98
+ }
99
+
100
+ private fun setupAlarm(triggerAtMillis: Long, operation: PendingIntent) {
101
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S || alarmManager.canScheduleExactAlarms()) {
102
+ AlarmManagerCompat.setExactAndAllowWhileIdle(
103
+ alarmManager,
104
+ AlarmManager.RTC_WAKEUP,
105
+ triggerAtMillis,
106
+ operation
107
+ )
108
+ } else {
109
+ AlarmManagerCompat.setAndAllowWhileIdle(
110
+ alarmManager,
111
+ AlarmManager.RTC_WAKEUP,
112
+ triggerAtMillis,
113
+ operation
114
+ )
115
+ }
116
+ }
117
+ }
@@ -0,0 +1,126 @@
1
+ package expo.modules.notifications.service.delegates
2
+
3
+ import android.content.Context
4
+ import com.google.firebase.messaging.RemoteMessage
5
+ import expo.modules.notifications.notifications.JSONNotificationContentBuilder
6
+ import expo.modules.notifications.notifications.RemoteMessageSerializer
7
+ import expo.modules.notifications.notifications.background.BackgroundRemoteNotificationTaskConsumer
8
+ import expo.modules.notifications.notifications.model.Notification
9
+ import expo.modules.notifications.notifications.model.NotificationContent
10
+ import expo.modules.notifications.notifications.model.NotificationRequest
11
+ import expo.modules.notifications.notifications.model.triggers.FirebaseNotificationTrigger
12
+ import expo.modules.notifications.service.NotificationsService
13
+ import expo.modules.notifications.service.interfaces.FirebaseMessagingDelegate
14
+ import expo.modules.notifications.tokens.interfaces.FirebaseTokenListener
15
+ import org.json.JSONObject
16
+ import java.lang.ref.WeakReference
17
+ import java.util.*
18
+
19
+ open class FirebaseMessagingDelegate(protected val context: Context) : FirebaseMessagingDelegate {
20
+ companion object {
21
+ // Unfortunately we cannot save state between instances of a service other way
22
+ // than by static properties. Fortunately, using weak references we can
23
+ // be somehow sure instances of PushTokenListeners won't be leaked by this component.
24
+ /**
25
+ * We store this value to be able to inform new listeners of last known token.
26
+ */
27
+ protected var sLastToken: String? = null
28
+
29
+ /**
30
+ * A weak map of listeners -> reference. Used to check quickly whether given listener
31
+ * is already registered and to iterate over when notifying of new token.
32
+ */
33
+ protected val sTokenListenersReferences = WeakHashMap<FirebaseTokenListener, WeakReference<FirebaseTokenListener?>?>()
34
+
35
+ /**
36
+ * Used only by [FirebaseTokenListener] instances. If you look for a place to register
37
+ * your listener, use [FirebaseTokenListener] singleton module.
38
+ *
39
+ * Purposefully the argument is expected to be a [FirebaseTokenListener] and just a listener.
40
+ *
41
+ * This class doesn't hold strong references to listeners, so you need to own your listeners.
42
+ *
43
+ * @param listener A listener instance to be informed of new push device tokens.
44
+ */
45
+ @JvmStatic
46
+ fun addTokenListener(listener: FirebaseTokenListener) {
47
+ // Checks whether this listener has already been registered
48
+ if (!sTokenListenersReferences.containsKey(listener)) {
49
+ sTokenListenersReferences[listener] = WeakReference(listener)
50
+ // Since it's a new listener and we know of a last valid token, let's let them know.
51
+ if (sLastToken != null) {
52
+ listener.onNewToken(sLastToken)
53
+ }
54
+ }
55
+ }
56
+
57
+ /**
58
+ * A weak map of task consumers -> reference. Used to check quickly whether given task
59
+ * is already registered and to iterate over when notifying of new notification received
60
+ * while the app is not in the foreground.
61
+ */
62
+ protected var sBackgroundTaskConsumerReferences = WeakHashMap<BackgroundRemoteNotificationTaskConsumer, WeakReference<BackgroundRemoteNotificationTaskConsumer>>()
63
+
64
+ /**
65
+ * Background tasks are registered in [BackgroundRemoteNotificationTaskConsumer] instances.
66
+ *
67
+ * @param taskConsumer A task instance to be executed when a notification is received while the * app is not in the foreground
68
+ */
69
+ fun addBackgroundTaskConsumer(taskConsumer: BackgroundRemoteNotificationTaskConsumer) {
70
+ if (sBackgroundTaskConsumerReferences.containsKey(taskConsumer)) {
71
+ return
72
+ }
73
+ sBackgroundTaskConsumerReferences[taskConsumer] = WeakReference(taskConsumer)
74
+ }
75
+ }
76
+
77
+ /**
78
+ * Called on new token, dispatches it to [NotificationsService.sTokenListenersReferences].
79
+ *
80
+ * @param token New device push token.
81
+ */
82
+ override fun onNewToken(token: String) {
83
+ for (listenerReference in sTokenListenersReferences.values) {
84
+ listenerReference?.get()?.onNewToken(token)
85
+ }
86
+ sLastToken = token
87
+ }
88
+
89
+ fun getBackgroundTasks() = sBackgroundTaskConsumerReferences.values.mapNotNull { it.get() }
90
+
91
+ override fun onMessageReceived(remoteMessage: RemoteMessage) {
92
+ NotificationsService.receive(context, createNotification(remoteMessage))
93
+ getBackgroundTasks().forEach {
94
+ it.scheduleJob(RemoteMessageSerializer.toBundle(remoteMessage))
95
+ }
96
+ }
97
+
98
+ protected fun createNotification(remoteMessage: RemoteMessage): Notification {
99
+ val identifier = getNotificationIdentifier(remoteMessage)
100
+ val payload = JSONObject(remoteMessage.data as Map<*, *>)
101
+ val content = JSONNotificationContentBuilder(context).setPayload(payload).build()
102
+ val request = createNotificationRequest(identifier, content, FirebaseNotificationTrigger(remoteMessage))
103
+ return Notification(request, Date(remoteMessage.sentTime))
104
+ }
105
+
106
+ /**
107
+ * To match iOS behavior, we want to assign the remote message's tag as the notification ID.
108
+ * If a notification comes in with the same tag as a notification that is already in the tray,
109
+ * the existing notification is replaced, but the ID can remain constant.
110
+ */
111
+ protected fun getNotificationIdentifier(remoteMessage: RemoteMessage): String {
112
+ return remoteMessage.data?.get("tag") ?: remoteMessage.messageId ?: UUID.randomUUID().toString()
113
+ }
114
+
115
+ protected open fun createNotificationRequest(
116
+ identifier: String,
117
+ content: NotificationContent,
118
+ notificationTrigger: FirebaseNotificationTrigger
119
+ ): NotificationRequest {
120
+ return NotificationRequest(identifier, content, notificationTrigger)
121
+ }
122
+
123
+ override fun onDeletedMessages() {
124
+ NotificationsService.handleDropped(context)
125
+ }
126
+ }