@aws-amplify/notifications 2.0.1-api-v6-models.9351bcf.0 → 2.0.1-api-v6-models.58f2536.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (287) hide show
  1. package/in-app-messaging/package.json +4 -4
  2. package/lib/eventListeners/eventListeners.js +19 -37
  3. package/lib/eventListeners/index.js +4 -3
  4. package/lib/eventListeners/types.d.ts +2 -2
  5. package/lib/inAppMessaging/errors/InAppMessagingError.js +8 -11
  6. package/lib/inAppMessaging/errors/assertServiceError.js +3 -2
  7. package/lib/inAppMessaging/errors/assertValidationError.js +5 -4
  8. package/lib/inAppMessaging/errors/index.js +6 -5
  9. package/lib/inAppMessaging/errors/validation.js +7 -7
  10. package/lib/inAppMessaging/index.d.ts +2 -1
  11. package/lib/inAppMessaging/index.js +12 -10
  12. package/lib/inAppMessaging/providers/pinpoint/apis/clearMessages.d.ts +13 -0
  13. package/lib/inAppMessaging/providers/pinpoint/apis/clearMessages.js +26 -0
  14. package/lib/inAppMessaging/providers/pinpoint/apis/dispatchEvent.js +26 -38
  15. package/lib/inAppMessaging/providers/pinpoint/apis/identifyUser.d.ts +2 -1
  16. package/lib/inAppMessaging/providers/pinpoint/apis/identifyUser.js +24 -35
  17. package/lib/inAppMessaging/providers/pinpoint/apis/index.d.ts +1 -0
  18. package/lib/inAppMessaging/providers/pinpoint/apis/index.js +13 -10
  19. package/lib/inAppMessaging/providers/pinpoint/apis/initializeInAppMessaging.js +21 -21
  20. package/lib/inAppMessaging/providers/pinpoint/apis/notifyMessageInteraction.js +6 -6
  21. package/lib/inAppMessaging/providers/pinpoint/apis/onMessageActionTaken.js +5 -4
  22. package/lib/inAppMessaging/providers/pinpoint/apis/onMessageDismissed.js +5 -4
  23. package/lib/inAppMessaging/providers/pinpoint/apis/onMessageDisplayed.js +5 -4
  24. package/lib/inAppMessaging/providers/pinpoint/apis/onMessageReceived.js +5 -4
  25. package/lib/inAppMessaging/providers/pinpoint/apis/setConflictHandler.js +6 -6
  26. package/lib/inAppMessaging/providers/pinpoint/apis/syncMessages.js +46 -76
  27. package/lib/inAppMessaging/providers/pinpoint/index.d.ts +1 -1
  28. package/lib/inAppMessaging/providers/pinpoint/index.js +12 -10
  29. package/lib/inAppMessaging/providers/pinpoint/types/index.js +2 -1
  30. package/lib/inAppMessaging/providers/pinpoint/types/inputs.d.ts +8 -8
  31. package/lib/inAppMessaging/providers/pinpoint/types/options.d.ts +1 -1
  32. package/lib/inAppMessaging/providers/pinpoint/types/outputs.d.ts +4 -4
  33. package/lib/inAppMessaging/providers/pinpoint/types/types.d.ts +6 -6
  34. package/lib/inAppMessaging/providers/pinpoint/types/types.js +1 -0
  35. package/lib/inAppMessaging/providers/pinpoint/utils/constants.js +1 -0
  36. package/lib/inAppMessaging/providers/pinpoint/utils/helpers.d.ts +3 -3
  37. package/lib/inAppMessaging/providers/pinpoint/utils/helpers.js +114 -110
  38. package/lib/inAppMessaging/providers/pinpoint/utils/index.js +11 -10
  39. package/lib/inAppMessaging/providers/pinpoint/utils/messageProcessingHelpers.js +116 -191
  40. package/lib/inAppMessaging/providers/pinpoint/utils/resolveConfig.js +9 -8
  41. package/lib/inAppMessaging/providers/pinpoint/utils/resolveCredentials.d.ts +1 -1
  42. package/lib/inAppMessaging/providers/pinpoint/utils/resolveCredentials.js +9 -15
  43. package/lib/inAppMessaging/providers/pinpoint/utils/userAgent.js +6 -5
  44. package/lib/inAppMessaging/types/event.d.ts +2 -2
  45. package/lib/inAppMessaging/types/inputs.d.ts +1 -1
  46. package/lib/inAppMessaging/types/message.d.ts +3 -3
  47. package/lib/inAppMessaging/types/options.d.ts +1 -1
  48. package/lib/inAppMessaging/utils/index.js +4 -3
  49. package/lib/inAppMessaging/utils/statusHelpers.js +8 -5
  50. package/lib/index.js +1 -0
  51. package/lib/pushNotifications/errors/PushNotificationError.js +8 -11
  52. package/lib/pushNotifications/errors/errorHelpers.js +14 -13
  53. package/lib/pushNotifications/errors/index.js +4 -3
  54. package/lib/pushNotifications/index.d.ts +1 -1
  55. package/lib/pushNotifications/index.js +13 -12
  56. package/lib/pushNotifications/providers/pinpoint/apis/getBadgeCount.js +4 -2
  57. package/lib/pushNotifications/providers/pinpoint/apis/getBadgeCount.native.js +9 -10
  58. package/lib/pushNotifications/providers/pinpoint/apis/getLaunchNotification.js +4 -2
  59. package/lib/pushNotifications/providers/pinpoint/apis/getLaunchNotification.native.js +7 -5
  60. package/lib/pushNotifications/providers/pinpoint/apis/getPermissionStatus.js +4 -2
  61. package/lib/pushNotifications/providers/pinpoint/apis/getPermissionStatus.native.js +7 -5
  62. package/lib/pushNotifications/providers/pinpoint/apis/identifyUser.js +4 -2
  63. package/lib/pushNotifications/providers/pinpoint/apis/identifyUser.native.js +25 -36
  64. package/lib/pushNotifications/providers/pinpoint/apis/index.js +12 -11
  65. package/lib/pushNotifications/providers/pinpoint/apis/initializePushNotifications.js +4 -2
  66. package/lib/pushNotifications/providers/pinpoint/apis/initializePushNotifications.native.d.ts +1 -1
  67. package/lib/pushNotifications/providers/pinpoint/apis/initializePushNotifications.native.js +90 -115
  68. package/lib/pushNotifications/providers/pinpoint/apis/onNotificationOpened.js +4 -2
  69. package/lib/pushNotifications/providers/pinpoint/apis/onNotificationOpened.native.js +7 -5
  70. package/lib/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInBackground.js +4 -2
  71. package/lib/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInBackground.native.js +7 -5
  72. package/lib/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInForeground.js +4 -2
  73. package/lib/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInForeground.native.js +7 -5
  74. package/lib/pushNotifications/providers/pinpoint/apis/onTokenReceived.js +4 -2
  75. package/lib/pushNotifications/providers/pinpoint/apis/onTokenReceived.native.js +7 -5
  76. package/lib/pushNotifications/providers/pinpoint/apis/requestPermissions.js +4 -2
  77. package/lib/pushNotifications/providers/pinpoint/apis/requestPermissions.native.js +7 -5
  78. package/lib/pushNotifications/providers/pinpoint/apis/setBadgeCount.js +4 -2
  79. package/lib/pushNotifications/providers/pinpoint/apis/setBadgeCount.native.js +7 -5
  80. package/lib/pushNotifications/providers/pinpoint/index.d.ts +1 -1
  81. package/lib/pushNotifications/providers/pinpoint/index.js +12 -11
  82. package/lib/pushNotifications/providers/pinpoint/types/analytics.d.ts +3 -3
  83. package/lib/pushNotifications/providers/pinpoint/types/apis.d.ts +11 -11
  84. package/lib/pushNotifications/providers/pinpoint/types/inputs.d.ts +7 -7
  85. package/lib/pushNotifications/providers/pinpoint/types/options.d.ts +1 -1
  86. package/lib/pushNotifications/providers/pinpoint/types/outputs.d.ts +8 -8
  87. package/lib/pushNotifications/providers/pinpoint/types/pushNotifications.d.ts +1 -1
  88. package/lib/pushNotifications/providers/pinpoint/utils/createMessageEventRecorder.d.ts +3 -2
  89. package/lib/pushNotifications/providers/pinpoint/utils/createMessageEventRecorder.js +33 -49
  90. package/lib/pushNotifications/providers/pinpoint/utils/getAnalyticsEvent.d.ts +3 -2
  91. package/lib/pushNotifications/providers/pinpoint/utils/getAnalyticsEvent.js +17 -13
  92. package/lib/pushNotifications/providers/pinpoint/utils/getChannelType.d.ts +2 -1
  93. package/lib/pushNotifications/providers/pinpoint/utils/getChannelType.js +9 -7
  94. package/lib/pushNotifications/providers/pinpoint/utils/index.d.ts +2 -1
  95. package/lib/pushNotifications/providers/pinpoint/utils/index.js +7 -4
  96. package/lib/pushNotifications/providers/pinpoint/utils/resolveConfig.js +17 -0
  97. package/lib/pushNotifications/types/errors.js +1 -0
  98. package/lib/pushNotifications/types/index.d.ts +1 -0
  99. package/lib/pushNotifications/types/index.js +20 -2
  100. package/lib/pushNotifications/types/inputs.d.ts +9 -8
  101. package/lib/pushNotifications/types/module.d.ts +31 -0
  102. package/lib/pushNotifications/types/options.d.ts +1 -1
  103. package/lib/pushNotifications/types/outputs.d.ts +8 -8
  104. package/lib/pushNotifications/types/pushNotifications.d.ts +4 -5
  105. package/lib/pushNotifications/utils/getPushNotificationUserAgentString.js +11 -0
  106. package/lib/pushNotifications/utils/index.d.ts +1 -1
  107. package/lib/pushNotifications/utils/index.js +8 -7
  108. package/lib/pushNotifications/utils/initializationManager.js +8 -9
  109. package/lib/pushNotifications/utils/resolveCredentials.d.ts +1 -1
  110. package/lib/pushNotifications/utils/resolveCredentials.js +9 -15
  111. package/lib/pushNotifications/utils/tokenManager.js +6 -3
  112. package/lib/tsconfig.tsbuildinfo +1 -0
  113. package/lib-esm/eventListeners/eventListeners.js +15 -37
  114. package/lib-esm/eventListeners/types.d.ts +2 -2
  115. package/lib-esm/eventListeners/types.js +1 -0
  116. package/lib-esm/inAppMessaging/errors/InAppMessagingError.js +6 -11
  117. package/lib-esm/inAppMessaging/errors/assertValidationError.js +2 -2
  118. package/lib-esm/inAppMessaging/errors/validation.js +6 -7
  119. package/lib-esm/inAppMessaging/index.d.ts +2 -1
  120. package/lib-esm/inAppMessaging/index.js +1 -1
  121. package/lib-esm/inAppMessaging/providers/pinpoint/apis/clearMessages.d.ts +13 -0
  122. package/lib-esm/inAppMessaging/providers/pinpoint/apis/clearMessages.js +22 -0
  123. package/lib-esm/inAppMessaging/providers/pinpoint/apis/dispatchEvent.js +15 -31
  124. package/lib-esm/inAppMessaging/providers/pinpoint/apis/identifyUser.d.ts +2 -1
  125. package/lib-esm/inAppMessaging/providers/pinpoint/apis/identifyUser.js +18 -31
  126. package/lib-esm/inAppMessaging/providers/pinpoint/apis/index.d.ts +1 -0
  127. package/lib-esm/inAppMessaging/providers/pinpoint/apis/index.js +1 -0
  128. package/lib-esm/inAppMessaging/providers/pinpoint/apis/initializeInAppMessaging.js +5 -6
  129. package/lib-esm/inAppMessaging/providers/pinpoint/apis/notifyMessageInteraction.js +1 -2
  130. package/lib-esm/inAppMessaging/providers/pinpoint/apis/setConflictHandler.js +4 -5
  131. package/lib-esm/inAppMessaging/providers/pinpoint/apis/syncMessages.js +38 -69
  132. package/lib-esm/inAppMessaging/providers/pinpoint/index.d.ts +1 -1
  133. package/lib-esm/inAppMessaging/providers/pinpoint/index.js +1 -1
  134. package/lib-esm/inAppMessaging/providers/pinpoint/types/inputs.d.ts +8 -8
  135. package/lib-esm/inAppMessaging/providers/pinpoint/types/inputs.js +1 -0
  136. package/lib-esm/inAppMessaging/providers/pinpoint/types/options.d.ts +1 -1
  137. package/lib-esm/inAppMessaging/providers/pinpoint/types/options.js +1 -0
  138. package/lib-esm/inAppMessaging/providers/pinpoint/types/outputs.d.ts +4 -4
  139. package/lib-esm/inAppMessaging/providers/pinpoint/types/outputs.js +1 -0
  140. package/lib-esm/inAppMessaging/providers/pinpoint/types/types.d.ts +6 -6
  141. package/lib-esm/inAppMessaging/providers/pinpoint/utils/constants.js +4 -4
  142. package/lib-esm/inAppMessaging/providers/pinpoint/utils/helpers.d.ts +3 -3
  143. package/lib-esm/inAppMessaging/providers/pinpoint/utils/helpers.js +85 -97
  144. package/lib-esm/inAppMessaging/providers/pinpoint/utils/messageProcessingHelpers.js +111 -187
  145. package/lib-esm/inAppMessaging/providers/pinpoint/utils/resolveConfig.js +3 -4
  146. package/lib-esm/inAppMessaging/providers/pinpoint/utils/resolveCredentials.d.ts +1 -1
  147. package/lib-esm/inAppMessaging/providers/pinpoint/utils/resolveCredentials.js +5 -13
  148. package/lib-esm/inAppMessaging/providers/pinpoint/utils/userAgent.js +2 -2
  149. package/lib-esm/inAppMessaging/types/event.d.ts +2 -2
  150. package/lib-esm/inAppMessaging/types/event.js +1 -0
  151. package/lib-esm/inAppMessaging/types/index.js +1 -0
  152. package/lib-esm/inAppMessaging/types/inputs.d.ts +1 -1
  153. package/lib-esm/inAppMessaging/types/inputs.js +1 -0
  154. package/lib-esm/inAppMessaging/types/message.d.ts +3 -3
  155. package/lib-esm/inAppMessaging/types/message.js +1 -0
  156. package/lib-esm/inAppMessaging/types/options.d.ts +1 -1
  157. package/lib-esm/inAppMessaging/types/options.js +1 -0
  158. package/lib-esm/inAppMessaging/utils/statusHelpers.js +3 -3
  159. package/lib-esm/index.js +1 -0
  160. package/lib-esm/pushNotifications/errors/PushNotificationError.js +6 -11
  161. package/lib-esm/pushNotifications/errors/errorHelpers.js +8 -9
  162. package/lib-esm/pushNotifications/index.d.ts +1 -1
  163. package/lib-esm/pushNotifications/providers/pinpoint/apis/getBadgeCount.js +1 -1
  164. package/lib-esm/pushNotifications/providers/pinpoint/apis/getBadgeCount.native.js +5 -8
  165. package/lib-esm/pushNotifications/providers/pinpoint/apis/getLaunchNotification.js +1 -1
  166. package/lib-esm/pushNotifications/providers/pinpoint/apis/getLaunchNotification.native.js +2 -2
  167. package/lib-esm/pushNotifications/providers/pinpoint/apis/getPermissionStatus.js +1 -1
  168. package/lib-esm/pushNotifications/providers/pinpoint/apis/getPermissionStatus.native.js +2 -2
  169. package/lib-esm/pushNotifications/providers/pinpoint/apis/identifyUser.js +1 -1
  170. package/lib-esm/pushNotifications/providers/pinpoint/apis/identifyUser.native.js +20 -33
  171. package/lib-esm/pushNotifications/providers/pinpoint/apis/initializePushNotifications.js +1 -1
  172. package/lib-esm/pushNotifications/providers/pinpoint/apis/initializePushNotifications.native.d.ts +1 -1
  173. package/lib-esm/pushNotifications/providers/pinpoint/apis/initializePushNotifications.native.js +76 -103
  174. package/lib-esm/pushNotifications/providers/pinpoint/apis/onNotificationOpened.js +1 -1
  175. package/lib-esm/pushNotifications/providers/pinpoint/apis/onNotificationOpened.native.js +1 -1
  176. package/lib-esm/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInBackground.js +1 -1
  177. package/lib-esm/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInBackground.native.js +1 -1
  178. package/lib-esm/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInForeground.js +1 -1
  179. package/lib-esm/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInForeground.native.js +1 -1
  180. package/lib-esm/pushNotifications/providers/pinpoint/apis/onTokenReceived.js +1 -1
  181. package/lib-esm/pushNotifications/providers/pinpoint/apis/onTokenReceived.native.js +1 -1
  182. package/lib-esm/pushNotifications/providers/pinpoint/apis/requestPermissions.js +1 -1
  183. package/lib-esm/pushNotifications/providers/pinpoint/apis/requestPermissions.native.js +2 -2
  184. package/lib-esm/pushNotifications/providers/pinpoint/apis/setBadgeCount.js +1 -1
  185. package/lib-esm/pushNotifications/providers/pinpoint/apis/setBadgeCount.native.js +2 -2
  186. package/lib-esm/pushNotifications/providers/pinpoint/index.d.ts +1 -1
  187. package/lib-esm/pushNotifications/providers/pinpoint/types/analytics.d.ts +3 -3
  188. package/lib-esm/pushNotifications/providers/pinpoint/types/analytics.js +1 -0
  189. package/lib-esm/pushNotifications/providers/pinpoint/types/apis.d.ts +11 -11
  190. package/lib-esm/pushNotifications/providers/pinpoint/types/apis.js +1 -0
  191. package/lib-esm/pushNotifications/providers/pinpoint/types/index.js +1 -0
  192. package/lib-esm/pushNotifications/providers/pinpoint/types/inputs.d.ts +7 -7
  193. package/lib-esm/pushNotifications/providers/pinpoint/types/inputs.js +1 -0
  194. package/lib-esm/pushNotifications/providers/pinpoint/types/options.d.ts +1 -1
  195. package/lib-esm/pushNotifications/providers/pinpoint/types/options.js +1 -0
  196. package/lib-esm/pushNotifications/providers/pinpoint/types/outputs.d.ts +8 -8
  197. package/lib-esm/pushNotifications/providers/pinpoint/types/outputs.js +1 -0
  198. package/lib-esm/pushNotifications/providers/pinpoint/types/pushNotifications.d.ts +1 -1
  199. package/lib-esm/pushNotifications/providers/pinpoint/types/pushNotifications.js +1 -0
  200. package/lib-esm/pushNotifications/providers/pinpoint/utils/createMessageEventRecorder.d.ts +3 -2
  201. package/lib-esm/pushNotifications/providers/pinpoint/utils/createMessageEventRecorder.js +27 -45
  202. package/lib-esm/pushNotifications/providers/pinpoint/utils/getAnalyticsEvent.d.ts +3 -2
  203. package/lib-esm/pushNotifications/providers/pinpoint/utils/getAnalyticsEvent.js +15 -13
  204. package/lib-esm/pushNotifications/providers/pinpoint/utils/getChannelType.d.ts +2 -1
  205. package/lib-esm/pushNotifications/providers/pinpoint/utils/getChannelType.js +5 -5
  206. package/lib-esm/pushNotifications/providers/pinpoint/utils/index.d.ts +2 -1
  207. package/lib-esm/pushNotifications/providers/pinpoint/utils/index.js +2 -1
  208. package/lib-esm/pushNotifications/{utils → providers/pinpoint/utils}/resolveConfig.js +4 -5
  209. package/lib-esm/pushNotifications/types/index.d.ts +1 -0
  210. package/lib-esm/pushNotifications/types/index.js +5 -0
  211. package/lib-esm/pushNotifications/types/inputs.d.ts +9 -8
  212. package/lib-esm/pushNotifications/types/inputs.js +1 -0
  213. package/lib-esm/pushNotifications/types/module.d.ts +31 -0
  214. package/lib-esm/pushNotifications/{Platform/types.js → types/module.js} +1 -0
  215. package/lib-esm/pushNotifications/types/options.d.ts +1 -1
  216. package/lib-esm/pushNotifications/types/options.js +1 -0
  217. package/lib-esm/pushNotifications/types/outputs.d.ts +8 -8
  218. package/lib-esm/pushNotifications/types/outputs.js +1 -0
  219. package/lib-esm/pushNotifications/types/pushNotifications.d.ts +4 -5
  220. package/lib-esm/pushNotifications/types/pushNotifications.js +1 -0
  221. package/lib-esm/pushNotifications/{providers/pinpoint/utils → utils}/getPushNotificationUserAgentString.js +4 -6
  222. package/lib-esm/pushNotifications/utils/index.d.ts +1 -1
  223. package/lib-esm/pushNotifications/utils/index.js +1 -1
  224. package/lib-esm/pushNotifications/utils/initializationManager.js +5 -9
  225. package/lib-esm/pushNotifications/utils/resolveCredentials.d.ts +1 -1
  226. package/lib-esm/pushNotifications/utils/resolveCredentials.js +5 -13
  227. package/lib-esm/pushNotifications/utils/tokenManager.js +3 -3
  228. package/lib-esm/tsconfig.tsbuildinfo +1 -0
  229. package/package.json +63 -30
  230. package/src/inAppMessaging/index.ts +12 -0
  231. package/src/inAppMessaging/providers/pinpoint/apis/clearMessages.ts +26 -0
  232. package/src/inAppMessaging/providers/pinpoint/apis/index.ts +1 -0
  233. package/src/inAppMessaging/providers/pinpoint/index.ts +1 -0
  234. package/src/inAppMessaging/providers/pinpoint/utils/helpers.ts +38 -28
  235. package/src/inAppMessaging/providers/pinpoint/utils/messageProcessingHelpers.ts +25 -9
  236. package/src/inAppMessaging/providers/pinpoint/utils/resolveConfig.ts +1 -1
  237. package/src/pushNotifications/index.ts +1 -0
  238. package/src/pushNotifications/providers/pinpoint/apis/getBadgeCount.ts +1 -1
  239. package/src/pushNotifications/providers/pinpoint/apis/getLaunchNotification.native.ts +1 -1
  240. package/src/pushNotifications/providers/pinpoint/apis/getLaunchNotification.ts +1 -1
  241. package/src/pushNotifications/providers/pinpoint/apis/getPermissionStatus.native.ts +1 -1
  242. package/src/pushNotifications/providers/pinpoint/apis/getPermissionStatus.ts +1 -1
  243. package/src/pushNotifications/providers/pinpoint/apis/identifyUser.native.ts +5 -2
  244. package/src/pushNotifications/providers/pinpoint/apis/identifyUser.ts +1 -1
  245. package/src/pushNotifications/providers/pinpoint/apis/initializePushNotifications.native.ts +51 -41
  246. package/src/pushNotifications/providers/pinpoint/apis/requestPermissions.native.ts +1 -1
  247. package/src/pushNotifications/providers/pinpoint/apis/requestPermissions.ts +1 -1
  248. package/src/pushNotifications/providers/pinpoint/index.ts +1 -0
  249. package/src/pushNotifications/providers/pinpoint/utils/createMessageEventRecorder.ts +5 -4
  250. package/src/pushNotifications/providers/pinpoint/utils/getAnalyticsEvent.ts +7 -4
  251. package/src/pushNotifications/providers/pinpoint/utils/getChannelType.ts +1 -1
  252. package/src/pushNotifications/providers/pinpoint/utils/index.ts +2 -1
  253. package/src/pushNotifications/{utils → providers/pinpoint/utils}/resolveConfig.ts +2 -2
  254. package/src/pushNotifications/types/index.ts +1 -0
  255. package/src/pushNotifications/types/inputs.ts +1 -1
  256. package/src/pushNotifications/types/module.ts +42 -0
  257. package/src/pushNotifications/types/outputs.ts +1 -1
  258. package/src/pushNotifications/types/pushNotifications.ts +2 -7
  259. package/src/pushNotifications/utils/index.ts +1 -1
  260. package/lib/inAppMessaging/providers/index.d.ts +0 -2
  261. package/lib/inAppMessaging/providers/index.js +0 -15
  262. package/lib/pushNotifications/Platform/index.d.ts +0 -2
  263. package/lib/pushNotifications/Platform/index.js +0 -25
  264. package/lib/pushNotifications/Platform/index.native.d.ts +0 -2
  265. package/lib/pushNotifications/Platform/index.native.js +0 -7
  266. package/lib/pushNotifications/Platform/types.d.ts +0 -5
  267. package/lib/pushNotifications/providers/pinpoint/utils/getPushNotificationUserAgentString.js +0 -11
  268. package/lib/pushNotifications/utils/resolveConfig.js +0 -16
  269. package/lib/tsconfig.build.tsbuildinfo +0 -8667
  270. package/lib-esm/inAppMessaging/providers/index.d.ts +0 -2
  271. package/lib-esm/inAppMessaging/providers/index.js +0 -3
  272. package/lib-esm/pushNotifications/Platform/index.d.ts +0 -2
  273. package/lib-esm/pushNotifications/Platform/index.js +0 -23
  274. package/lib-esm/pushNotifications/Platform/index.native.d.ts +0 -2
  275. package/lib-esm/pushNotifications/Platform/index.native.js +0 -5
  276. package/lib-esm/pushNotifications/Platform/types.d.ts +0 -5
  277. package/lib-esm/tsconfig.build.tsbuildinfo +0 -7115
  278. package/src/inAppMessaging/providers/index.ts +0 -38
  279. package/src/pushNotifications/Platform/index.native.ts +0 -9
  280. package/src/pushNotifications/Platform/index.ts +0 -22
  281. package/src/pushNotifications/Platform/types.ts +0 -15
  282. /package/lib/pushNotifications/{utils → providers/pinpoint/utils}/resolveConfig.d.ts +0 -0
  283. /package/lib/pushNotifications/{Platform/types.js → types/module.js} +0 -0
  284. /package/lib/pushNotifications/{providers/pinpoint/utils → utils}/getPushNotificationUserAgentString.d.ts +0 -0
  285. /package/lib-esm/pushNotifications/{utils → providers/pinpoint/utils}/resolveConfig.d.ts +0 -0
  286. /package/lib-esm/pushNotifications/{providers/pinpoint/utils → utils}/getPushNotificationUserAgentString.d.ts +0 -0
  287. /package/src/pushNotifications/{providers/pinpoint/utils → utils}/getPushNotificationUserAgentString.ts +0 -0
@@ -2,17 +2,18 @@
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.PushNotificationError = exports.setBadgeCount = exports.requestPermissions = exports.onTokenReceived = exports.onNotificationReceivedInForeground = exports.onNotificationReceivedInBackground = exports.onNotificationOpened = exports.initializePushNotifications = exports.identifyUser = exports.getPermissionStatus = exports.getLaunchNotification = exports.getBadgeCount = void 0;
5
6
  var pinpoint_1 = require("./providers/pinpoint");
6
- exports.getBadgeCount = pinpoint_1.getBadgeCount;
7
- exports.getLaunchNotification = pinpoint_1.getLaunchNotification;
8
- exports.getPermissionStatus = pinpoint_1.getPermissionStatus;
9
- exports.identifyUser = pinpoint_1.identifyUser;
10
- exports.initializePushNotifications = pinpoint_1.initializePushNotifications;
11
- exports.onNotificationOpened = pinpoint_1.onNotificationOpened;
12
- exports.onNotificationReceivedInBackground = pinpoint_1.onNotificationReceivedInBackground;
13
- exports.onNotificationReceivedInForeground = pinpoint_1.onNotificationReceivedInForeground;
14
- exports.onTokenReceived = pinpoint_1.onTokenReceived;
15
- exports.requestPermissions = pinpoint_1.requestPermissions;
16
- exports.setBadgeCount = pinpoint_1.setBadgeCount;
7
+ Object.defineProperty(exports, "getBadgeCount", { enumerable: true, get: function () { return pinpoint_1.getBadgeCount; } });
8
+ Object.defineProperty(exports, "getLaunchNotification", { enumerable: true, get: function () { return pinpoint_1.getLaunchNotification; } });
9
+ Object.defineProperty(exports, "getPermissionStatus", { enumerable: true, get: function () { return pinpoint_1.getPermissionStatus; } });
10
+ Object.defineProperty(exports, "identifyUser", { enumerable: true, get: function () { return pinpoint_1.identifyUser; } });
11
+ Object.defineProperty(exports, "initializePushNotifications", { enumerable: true, get: function () { return pinpoint_1.initializePushNotifications; } });
12
+ Object.defineProperty(exports, "onNotificationOpened", { enumerable: true, get: function () { return pinpoint_1.onNotificationOpened; } });
13
+ Object.defineProperty(exports, "onNotificationReceivedInBackground", { enumerable: true, get: function () { return pinpoint_1.onNotificationReceivedInBackground; } });
14
+ Object.defineProperty(exports, "onNotificationReceivedInForeground", { enumerable: true, get: function () { return pinpoint_1.onNotificationReceivedInForeground; } });
15
+ Object.defineProperty(exports, "onTokenReceived", { enumerable: true, get: function () { return pinpoint_1.onTokenReceived; } });
16
+ Object.defineProperty(exports, "requestPermissions", { enumerable: true, get: function () { return pinpoint_1.requestPermissions; } });
17
+ Object.defineProperty(exports, "setBadgeCount", { enumerable: true, get: function () { return pinpoint_1.setBadgeCount; } });
17
18
  var errors_1 = require("./errors");
18
- exports.PushNotificationError = errors_1.PushNotificationError;
19
+ Object.defineProperty(exports, "PushNotificationError", { enumerable: true, get: function () { return errors_1.PushNotificationError; } });
@@ -2,7 +2,8 @@
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- var utils_1 = require("@aws-amplify/core/internals/utils");
5
+ exports.getBadgeCount = void 0;
6
+ const utils_1 = require("@aws-amplify/core/internals/utils");
6
7
  /**
7
8
  * Returns the current badge count (the number next to your app's icon). This function is safe to call (but will be
8
9
  * ignored) even when your React Native app is running on platforms where badges are not supported.
@@ -15,6 +16,7 @@ var utils_1 = require("@aws-amplify/core/internals/utils");
15
16
  * const badgeCount = await getBadgeCount();
16
17
  * ```
17
18
  */
18
- exports.getBadgeCount = function () {
19
+ const getBadgeCount = async () => {
19
20
  throw new utils_1.PlatformNotSupportedError();
20
21
  };
22
+ exports.getBadgeCount = getBadgeCount;
@@ -2,13 +2,12 @@
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- var tslib_1 = require("tslib");
6
- var react_native_1 = require("@aws-amplify/react-native");
7
- var errorHelpers_1 = require("../../../errors/errorHelpers");
8
- var getBadgeCountNative = react_native_1.loadAmplifyPushNotification().getBadgeCount;
9
- exports.getBadgeCount = function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
10
- return tslib_1.__generator(this, function (_a) {
11
- errorHelpers_1.assertIsInitialized();
12
- return [2 /*return*/, getBadgeCountNative()];
13
- });
14
- }); };
5
+ exports.getBadgeCount = void 0;
6
+ const react_native_1 = require("@aws-amplify/react-native");
7
+ const errorHelpers_1 = require("../../../errors/errorHelpers");
8
+ const { getBadgeCount: getBadgeCountNative } = (0, react_native_1.loadAmplifyPushNotification)();
9
+ const getBadgeCount = async () => {
10
+ (0, errorHelpers_1.assertIsInitialized)();
11
+ return getBadgeCountNative();
12
+ };
13
+ exports.getBadgeCount = getBadgeCount;
@@ -2,7 +2,8 @@
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- var utils_1 = require("@aws-amplify/core/internals/utils");
5
+ exports.getLaunchNotification = void 0;
6
+ const utils_1 = require("@aws-amplify/core/internals/utils");
6
7
  /**
7
8
  * Returns the notification which launched your app from a terminated state. The launch notification is consumed by
8
9
  * calls to this function and will yield a null result if:
@@ -19,6 +20,7 @@ var utils_1 = require("@aws-amplify/core/internals/utils");
19
20
  * const launchNotification = await getLaunchNotification();
20
21
  * ```
21
22
  */
22
- exports.getLaunchNotification = function () {
23
+ const getLaunchNotification = async () => {
23
24
  throw new utils_1.PlatformNotSupportedError();
24
25
  };
26
+ exports.getLaunchNotification = getLaunchNotification;
@@ -2,10 +2,12 @@
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- var react_native_1 = require("@aws-amplify/react-native");
6
- var errorHelpers_1 = require("../../../errors/errorHelpers");
7
- var getLaunchNotificationNative = react_native_1.loadAmplifyPushNotification().getLaunchNotification;
8
- exports.getLaunchNotification = function () {
9
- errorHelpers_1.assertIsInitialized();
5
+ exports.getLaunchNotification = void 0;
6
+ const react_native_1 = require("@aws-amplify/react-native");
7
+ const errorHelpers_1 = require("../../../errors/errorHelpers");
8
+ const { getLaunchNotification: getLaunchNotificationNative } = (0, react_native_1.loadAmplifyPushNotification)();
9
+ const getLaunchNotification = async () => {
10
+ (0, errorHelpers_1.assertIsInitialized)();
10
11
  return getLaunchNotificationNative();
11
12
  };
13
+ exports.getLaunchNotification = getLaunchNotification;
@@ -2,7 +2,8 @@
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- var utils_1 = require("@aws-amplify/core/internals/utils");
5
+ exports.getPermissionStatus = void 0;
6
+ const utils_1 = require("@aws-amplify/core/internals/utils");
6
7
  /**
7
8
  * Returns a string representing the current status of user permissions to display push notifications. The possible
8
9
  * statuses are as follows:
@@ -28,6 +29,7 @@ var utils_1 = require("@aws-amplify/core/internals/utils");
28
29
  * ```ts
29
30
  * const permissionStatus = await getPermissionStatus();
30
31
  */
31
- exports.getPermissionStatus = function () {
32
+ const getPermissionStatus = async () => {
32
33
  throw new utils_1.PlatformNotSupportedError();
33
34
  };
35
+ exports.getPermissionStatus = getPermissionStatus;
@@ -2,10 +2,12 @@
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- var react_native_1 = require("@aws-amplify/react-native");
6
- var errorHelpers_1 = require("../../../errors/errorHelpers");
7
- var getPermissionStatusNative = react_native_1.loadAmplifyPushNotification().getPermissionStatus;
8
- exports.getPermissionStatus = function () {
9
- errorHelpers_1.assertIsInitialized();
5
+ exports.getPermissionStatus = void 0;
6
+ const react_native_1 = require("@aws-amplify/react-native");
7
+ const errorHelpers_1 = require("../../../errors/errorHelpers");
8
+ const { getPermissionStatus: getPermissionStatusNative } = (0, react_native_1.loadAmplifyPushNotification)();
9
+ const getPermissionStatus = async () => {
10
+ (0, errorHelpers_1.assertIsInitialized)();
10
11
  return getPermissionStatusNative();
11
12
  };
13
+ exports.getPermissionStatus = getPermissionStatus;
@@ -2,7 +2,8 @@
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- var utils_1 = require("@aws-amplify/core/internals/utils");
5
+ exports.identifyUser = void 0;
6
+ const utils_1 = require("@aws-amplify/core/internals/utils");
6
7
  /**
7
8
  * Sends information about a user to Pinpoint. Sending user information allows you to associate a user to their user
8
9
  * profile and activities or actions in your application. Activity can be tracked across devices & platforms by using
@@ -54,6 +55,7 @@ var utils_1 = require("@aws-amplify/core/internals/utils");
54
55
  * },
55
56
  * });
56
57
  */
57
- exports.identifyUser = function () {
58
+ const identifyUser = async () => {
58
59
  throw new utils_1.PlatformNotSupportedError();
59
60
  };
61
+ exports.identifyUser = identifyUser;
@@ -2,41 +2,30 @@
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- var tslib_1 = require("tslib");
6
- var utils_1 = require("@aws-amplify/core/internals/utils");
7
- var pinpoint_1 = require("@aws-amplify/core/internals/providers/pinpoint");
8
- var errorHelpers_1 = require("../../../errors/errorHelpers");
9
- var utils_2 = require("../../../utils");
10
- var utils_3 = require("../utils");
11
- exports.identifyUser = function (_a) {
12
- var userId = _a.userId, userProfile = _a.userProfile, options = _a.options;
13
- return tslib_1.__awaiter(void 0, void 0, void 0, function () {
14
- var _b, credentials, identityId, _c, appId, region, _d, address, optOut, userAttributes;
15
- return tslib_1.__generator(this, function (_e) {
16
- switch (_e.label) {
17
- case 0:
18
- errorHelpers_1.assertIsInitialized();
19
- return [4 /*yield*/, utils_2.resolveCredentials()];
20
- case 1:
21
- _b = _e.sent(), credentials = _b.credentials, identityId = _b.identityId;
22
- _c = utils_2.resolveConfig(), appId = _c.appId, region = _c.region;
23
- _d = options !== null && options !== void 0 ? options : {}, address = _d.address, optOut = _d.optOut, userAttributes = _d.userAttributes;
24
- pinpoint_1.updateEndpoint({
25
- address: address,
26
- channelType: utils_3.getChannelType(),
27
- optOut: optOut,
28
- appId: appId,
29
- category: 'PushNotification',
30
- credentials: credentials,
31
- identityId: identityId,
32
- region: region,
33
- userAttributes: userAttributes,
34
- userId: userId,
35
- userProfile: userProfile,
36
- userAgentValue: utils_3.getPushNotificationUserAgentString(utils_1.PushNotificationAction.IdentifyUser),
37
- });
38
- return [2 /*return*/];
39
- }
40
- });
5
+ exports.identifyUser = void 0;
6
+ const utils_1 = require("@aws-amplify/core/internals/utils");
7
+ const pinpoint_1 = require("@aws-amplify/core/internals/providers/pinpoint");
8
+ const errorHelpers_1 = require("../../../errors/errorHelpers");
9
+ const utils_2 = require("../../../utils");
10
+ const utils_3 = require("../utils");
11
+ const identifyUser = async ({ userId, userProfile, options, }) => {
12
+ (0, errorHelpers_1.assertIsInitialized)();
13
+ const { credentials, identityId } = await (0, utils_2.resolveCredentials)();
14
+ const { appId, region } = (0, utils_3.resolveConfig)();
15
+ const { address, optOut, userAttributes } = options ?? {};
16
+ (0, pinpoint_1.updateEndpoint)({
17
+ address,
18
+ channelType: (0, utils_3.getChannelType)(),
19
+ optOut,
20
+ appId,
21
+ category: 'PushNotification',
22
+ credentials,
23
+ identityId,
24
+ region,
25
+ userAttributes,
26
+ userId,
27
+ userProfile,
28
+ userAgentValue: (0, utils_2.getPushNotificationUserAgentString)(utils_1.PushNotificationAction.IdentifyUser),
41
29
  });
42
30
  };
31
+ exports.identifyUser = identifyUser;
@@ -2,25 +2,26 @@
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.setBadgeCount = exports.requestPermissions = exports.onTokenReceived = exports.onNotificationReceivedInForeground = exports.onNotificationReceivedInBackground = exports.onNotificationOpened = exports.initializePushNotifications = exports.identifyUser = exports.getPermissionStatus = exports.getLaunchNotification = exports.getBadgeCount = void 0;
5
6
  var getBadgeCount_1 = require("./getBadgeCount");
6
- exports.getBadgeCount = getBadgeCount_1.getBadgeCount;
7
+ Object.defineProperty(exports, "getBadgeCount", { enumerable: true, get: function () { return getBadgeCount_1.getBadgeCount; } });
7
8
  var getLaunchNotification_1 = require("./getLaunchNotification");
8
- exports.getLaunchNotification = getLaunchNotification_1.getLaunchNotification;
9
+ Object.defineProperty(exports, "getLaunchNotification", { enumerable: true, get: function () { return getLaunchNotification_1.getLaunchNotification; } });
9
10
  var getPermissionStatus_1 = require("./getPermissionStatus");
10
- exports.getPermissionStatus = getPermissionStatus_1.getPermissionStatus;
11
+ Object.defineProperty(exports, "getPermissionStatus", { enumerable: true, get: function () { return getPermissionStatus_1.getPermissionStatus; } });
11
12
  var identifyUser_1 = require("./identifyUser");
12
- exports.identifyUser = identifyUser_1.identifyUser;
13
+ Object.defineProperty(exports, "identifyUser", { enumerable: true, get: function () { return identifyUser_1.identifyUser; } });
13
14
  var initializePushNotifications_1 = require("./initializePushNotifications");
14
- exports.initializePushNotifications = initializePushNotifications_1.initializePushNotifications;
15
+ Object.defineProperty(exports, "initializePushNotifications", { enumerable: true, get: function () { return initializePushNotifications_1.initializePushNotifications; } });
15
16
  var onNotificationOpened_1 = require("./onNotificationOpened");
16
- exports.onNotificationOpened = onNotificationOpened_1.onNotificationOpened;
17
+ Object.defineProperty(exports, "onNotificationOpened", { enumerable: true, get: function () { return onNotificationOpened_1.onNotificationOpened; } });
17
18
  var onNotificationReceivedInBackground_1 = require("./onNotificationReceivedInBackground");
18
- exports.onNotificationReceivedInBackground = onNotificationReceivedInBackground_1.onNotificationReceivedInBackground;
19
+ Object.defineProperty(exports, "onNotificationReceivedInBackground", { enumerable: true, get: function () { return onNotificationReceivedInBackground_1.onNotificationReceivedInBackground; } });
19
20
  var onNotificationReceivedInForeground_1 = require("./onNotificationReceivedInForeground");
20
- exports.onNotificationReceivedInForeground = onNotificationReceivedInForeground_1.onNotificationReceivedInForeground;
21
+ Object.defineProperty(exports, "onNotificationReceivedInForeground", { enumerable: true, get: function () { return onNotificationReceivedInForeground_1.onNotificationReceivedInForeground; } });
21
22
  var onTokenReceived_1 = require("./onTokenReceived");
22
- exports.onTokenReceived = onTokenReceived_1.onTokenReceived;
23
+ Object.defineProperty(exports, "onTokenReceived", { enumerable: true, get: function () { return onTokenReceived_1.onTokenReceived; } });
23
24
  var requestPermissions_1 = require("./requestPermissions");
24
- exports.requestPermissions = requestPermissions_1.requestPermissions;
25
+ Object.defineProperty(exports, "requestPermissions", { enumerable: true, get: function () { return requestPermissions_1.requestPermissions; } });
25
26
  var setBadgeCount_1 = require("./setBadgeCount");
26
- exports.setBadgeCount = setBadgeCount_1.setBadgeCount;
27
+ Object.defineProperty(exports, "setBadgeCount", { enumerable: true, get: function () { return setBadgeCount_1.setBadgeCount; } });
@@ -2,7 +2,8 @@
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- var utils_1 = require("@aws-amplify/core/internals/utils");
5
+ exports.initializePushNotifications = void 0;
6
+ const utils_1 = require("@aws-amplify/core/internals/utils");
6
7
  /**
7
8
  * Initialize and set up the push notification category. The category must be first initialized before all other
8
9
  * functionalities become available.
@@ -18,6 +19,7 @@ var utils_1 = require("@aws-amplify/core/internals/utils");
18
19
  * initializePushNotifications();
19
20
  * ```
20
21
  */
21
- exports.initializePushNotifications = function () {
22
+ const initializePushNotifications = () => {
22
23
  throw new utils_1.PlatformNotSupportedError();
23
24
  };
25
+ exports.initializePushNotifications = initializePushNotifications;
@@ -1 +1 @@
1
- export declare const initializePushNotifications: () => Promise<void>;
1
+ export declare const initializePushNotifications: () => void;
@@ -2,157 +2,132 @@
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- var tslib_1 = require("tslib");
6
- var core_1 = require("@aws-amplify/core");
7
- var utils_1 = require("@aws-amplify/core/internals/utils");
8
- var pinpoint_1 = require("@aws-amplify/core/internals/providers/pinpoint");
9
- var react_native_1 = require("@aws-amplify/react-native");
10
- var eventListeners_1 = require("../../../../eventListeners");
11
- var utils_2 = require("../../../utils");
12
- var utils_3 = require("../utils");
13
- var _a = react_native_1.loadAmplifyPushNotification(), addMessageEventListener = _a.addMessageEventListener, addTokenEventListener = _a.addTokenEventListener, completeNotification = _a.completeNotification, getConstants = _a.getConstants, registerHeadlessTask = _a.registerHeadlessTask;
14
- var logger = new core_1.ConsoleLogger('Notifications.PushNotification');
15
- var BACKGROUND_TASK_TIMEOUT = 25; // seconds
16
- exports.initializePushNotifications = function () {
17
- if (utils_2.isInitialized()) {
5
+ exports.initializePushNotifications = void 0;
6
+ const core_1 = require("@aws-amplify/core");
7
+ const utils_1 = require("@aws-amplify/core/internals/utils");
8
+ const pinpoint_1 = require("@aws-amplify/core/internals/providers/pinpoint");
9
+ const react_native_1 = require("@aws-amplify/react-native");
10
+ const eventListeners_1 = require("../../../../eventListeners");
11
+ const utils_2 = require("../../../utils");
12
+ const utils_3 = require("../utils");
13
+ const { addMessageEventListener, addTokenEventListener, completeNotification, getConstants, registerHeadlessTask, } = (0, react_native_1.loadAmplifyPushNotification)();
14
+ const logger = new core_1.ConsoleLogger('Notifications.PushNotification');
15
+ const BACKGROUND_TASK_TIMEOUT = 25; // seconds
16
+ const initializePushNotifications = () => {
17
+ if ((0, utils_2.isInitialized)()) {
18
18
  logger.info('Push notifications have already been enabled');
19
19
  return;
20
20
  }
21
21
  addNativeListeners();
22
22
  addAnalyticsListeners();
23
- utils_2.initialize();
23
+ (0, utils_2.initialize)();
24
24
  };
25
- var addAnalyticsListeners = function () {
26
- var launchNotificationOpenedListenerRemover;
27
- // wire up default Pinpoint message event handling
28
- eventListeners_1.addEventListener('backgroundMessageReceived', utils_3.createMessageEventRecorder('backgroundMessageReceived'));
29
- eventListeners_1.addEventListener('foregroundMessageReceived', utils_3.createMessageEventRecorder('foregroundMessageReceived'));
30
- launchNotificationOpenedListenerRemover = eventListeners_1.addEventListener('launchNotificationsOpened', utils_3.createMessageEventRecorder('notificationOpened',
31
- // once we are done with it we can remove the listener
32
- launchNotificationOpenedListenerRemover === null ||
33
- // once we are done with it we can remove the listener
34
- launchNotificationOpenedListenerRemover === void 0 ? void 0 :
35
- // once we are done with it we can remove the listener
36
- launchNotificationOpenedListenerRemover.remove));
37
- eventListeners_1.addEventListener('notificationOpened', utils_3.createMessageEventRecorder('notificationOpened',
38
- // if we are in this state, we no longer need the listener as the app was launched via some other means
39
- launchNotificationOpenedListenerRemover === null ||
40
- // if we are in this state, we no longer need the listener as the app was launched via some other means
41
- launchNotificationOpenedListenerRemover === void 0 ? void 0 :
42
- // if we are in this state, we no longer need the listener as the app was launched via some other means
43
- launchNotificationOpenedListenerRemover.remove));
44
- };
45
- var addNativeListeners = function () {
46
- var _a = getConstants(), NativeEvent = _a.NativeEvent, NativeHeadlessTaskKey = _a.NativeHeadlessTaskKey;
47
- var BACKGROUND_MESSAGE_RECEIVED = NativeEvent.BACKGROUND_MESSAGE_RECEIVED, FOREGROUND_MESSAGE_RECEIVED = NativeEvent.FOREGROUND_MESSAGE_RECEIVED, LAUNCH_NOTIFICATION_OPENED = NativeEvent.LAUNCH_NOTIFICATION_OPENED, NOTIFICATION_OPENED = NativeEvent.NOTIFICATION_OPENED, TOKEN_RECEIVED = NativeEvent.TOKEN_RECEIVED;
25
+ exports.initializePushNotifications = initializePushNotifications;
26
+ const addNativeListeners = () => {
27
+ let launchNotificationOpenedListener;
28
+ const { NativeEvent, NativeHeadlessTaskKey } = getConstants();
29
+ const { BACKGROUND_MESSAGE_RECEIVED, FOREGROUND_MESSAGE_RECEIVED, LAUNCH_NOTIFICATION_OPENED, NOTIFICATION_OPENED, TOKEN_RECEIVED, } = NativeEvent;
48
30
  // on platforms that can handle headless tasks, register one to broadcast background message received to
49
31
  // library listeners
50
32
  if (NativeHeadlessTaskKey) {
51
- registerHeadlessTask(function (message) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
52
- return tslib_1.__generator(this, function (_a) {
53
- switch (_a.label) {
54
- case 0:
55
- // keep headless task running until handlers have completed their work
56
- return [4 /*yield*/, eventListeners_1.notifyEventListenersAndAwaitHandlers('backgroundMessageReceived', message)];
57
- case 1:
58
- // keep headless task running until handlers have completed their work
59
- _a.sent();
60
- return [2 /*return*/];
61
- }
62
- });
63
- }); });
33
+ registerHeadlessTask(async (message) => {
34
+ // keep headless task running until handlers have completed their work
35
+ await (0, eventListeners_1.notifyEventListenersAndAwaitHandlers)('backgroundMessageReceived', message);
36
+ });
64
37
  }
65
38
  else if (BACKGROUND_MESSAGE_RECEIVED) {
66
39
  // on platforms that can't handle headless tasks, listen for native background message received event and
67
40
  // broadcast to library listeners
68
- addMessageEventListener(BACKGROUND_MESSAGE_RECEIVED, function (message, completionHandlerId) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
69
- var err_1;
70
- return tslib_1.__generator(this, function (_a) {
71
- switch (_a.label) {
72
- case 0:
73
- _a.trys.push([0, 2, 3, 4]);
74
- return [4 /*yield*/, Promise.race([
75
- eventListeners_1.notifyEventListenersAndAwaitHandlers('backgroundMessageReceived', message),
76
- // background tasks will get suspended and all future tasks be deprioritized by the OS if they run for
77
- // more than 30 seconds so we reject with a error in a shorter amount of time to prevent this from
78
- // happening
79
- new Promise(function (_, reject) {
80
- setTimeout(function () {
81
- return reject("onNotificationReceivedInBackground handlers should complete their work within " + BACKGROUND_TASK_TIMEOUT + " seconds, but they did not.");
82
- }, BACKGROUND_TASK_TIMEOUT * 1000);
83
- }),
84
- ])];
85
- case 1:
86
- _a.sent();
87
- return [3 /*break*/, 4];
88
- case 2:
89
- err_1 = _a.sent();
90
- logger.error(err_1);
91
- return [3 /*break*/, 4];
92
- case 3:
93
- // notify native module that handlers have completed their work (or timed out)
94
- completeNotification(completionHandlerId);
95
- return [7 /*endfinally*/];
96
- case 4: return [2 /*return*/];
41
+ addMessageEventListener(BACKGROUND_MESSAGE_RECEIVED, async (message, completionHandlerId) => {
42
+ // keep background task running until handlers have completed their work
43
+ try {
44
+ await Promise.race([
45
+ (0, eventListeners_1.notifyEventListenersAndAwaitHandlers)('backgroundMessageReceived', message),
46
+ // background tasks will get suspended and all future tasks be deprioritized by the OS if they run for
47
+ // more than 30 seconds so we reject with a error in a shorter amount of time to prevent this from
48
+ // happening
49
+ new Promise((_, reject) => {
50
+ setTimeout(() => reject(`onNotificationReceivedInBackground handlers should complete their work within ${BACKGROUND_TASK_TIMEOUT} seconds, but they did not.`), BACKGROUND_TASK_TIMEOUT * 1000);
51
+ }),
52
+ ]);
53
+ }
54
+ catch (err) {
55
+ logger.error(err);
56
+ }
57
+ finally {
58
+ // notify native module that handlers have completed their work (or timed out)
59
+ if (completionHandlerId) {
60
+ completeNotification(completionHandlerId);
97
61
  }
98
- });
99
- }); });
62
+ }
63
+ });
100
64
  }
101
65
  addMessageEventListener(
102
66
  // listen for native foreground message received event and broadcast to library listeners
103
- FOREGROUND_MESSAGE_RECEIVED, function (message) {
104
- eventListeners_1.notifyEventListeners('foregroundMessageReceived', message);
67
+ FOREGROUND_MESSAGE_RECEIVED, message => {
68
+ (0, eventListeners_1.notifyEventListeners)('foregroundMessageReceived', message);
105
69
  });
106
- var launchNotificationOpenedListener = LAUNCH_NOTIFICATION_OPENED
70
+ launchNotificationOpenedListener = LAUNCH_NOTIFICATION_OPENED
107
71
  ? addMessageEventListener(
108
72
  // listen for native notification opened app (user tapped on notification, opening the app from quit -
109
73
  // not background - state) event. This is broadcasted to an internal listener only as it is not intended
110
74
  // for use otherwise as it produces inconsistent results when used within React Native app context
111
- LAUNCH_NOTIFICATION_OPENED, function (message) {
112
- eventListeners_1.notifyEventListeners('launchNotificationsOpened', message);
75
+ LAUNCH_NOTIFICATION_OPENED, message => {
76
+ (0, eventListeners_1.notifyEventListeners)('launchNotificationOpened', message);
113
77
  // once we are done with it we can remove the listener
114
- launchNotificationOpenedListener === null || launchNotificationOpenedListener === void 0 ? void 0 : launchNotificationOpenedListener.remove();
78
+ launchNotificationOpenedListener?.remove();
115
79
  })
116
80
  : null;
117
81
  addMessageEventListener(
118
82
  // listen for native notification opened (user tapped on notification, opening the app from background -
119
83
  // not quit - state) event and broadcast to library listeners
120
- NOTIFICATION_OPENED, function (message) {
121
- eventListeners_1.notifyEventListeners('notificationOpened', message);
84
+ NOTIFICATION_OPENED, message => {
85
+ (0, eventListeners_1.notifyEventListeners)('notificationOpened', message);
122
86
  // if we are in this state, we no longer need the listener as the app was launched via some other means
123
- launchNotificationOpenedListener === null || launchNotificationOpenedListener === void 0 ? void 0 : launchNotificationOpenedListener.remove();
87
+ launchNotificationOpenedListener?.remove();
124
88
  });
125
89
  addTokenEventListener(
126
90
  // listen for native new token event, automatically re-register device with provider using new token and
127
91
  // broadcast to library listeners
128
- TOKEN_RECEIVED, function (token) {
92
+ TOKEN_RECEIVED, async (token) => {
129
93
  // avoid a race condition where two endpoints are created with the same token on a fresh install
130
- if (utils_2.getToken() === token) {
94
+ if ((0, utils_2.getToken)() === token) {
131
95
  return;
132
96
  }
133
- utils_2.setToken(token);
134
- registerDevice();
135
- eventListeners_1.notifyEventListeners('tokenReceived', token);
97
+ (0, utils_2.setToken)(token);
98
+ (0, eventListeners_1.notifyEventListeners)('tokenReceived', token);
99
+ try {
100
+ await registerDevice(token);
101
+ }
102
+ catch (err) {
103
+ logger.error('Failed to register device for push notifications', err);
104
+ throw err;
105
+ }
136
106
  });
137
107
  };
138
- var registerDevice = function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
139
- var _a, credentials, identityId, _b, appId, region;
140
- return tslib_1.__generator(this, function (_c) {
141
- switch (_c.label) {
142
- case 0: return [4 /*yield*/, utils_2.resolveCredentials()];
143
- case 1:
144
- _a = _c.sent(), credentials = _a.credentials, identityId = _a.identityId;
145
- _b = utils_2.resolveConfig(), appId = _b.appId, region = _b.region;
146
- return [2 /*return*/, pinpoint_1.updateEndpoint({
147
- address: utils_2.getToken(),
148
- appId: appId,
149
- category: 'PushNotification',
150
- credentials: credentials,
151
- region: region,
152
- channelType: utils_3.getChannelType(),
153
- identityId: identityId,
154
- userAgentValue: utils_3.getPushNotificationUserAgentString(utils_1.PushNotificationAction.InitializePushNotifications),
155
- })];
156
- }
108
+ const addAnalyticsListeners = () => {
109
+ let launchNotificationOpenedListenerRemover;
110
+ // wire up default Pinpoint message event handling
111
+ (0, eventListeners_1.addEventListener)('backgroundMessageReceived', (0, utils_3.createMessageEventRecorder)('received_background'));
112
+ (0, eventListeners_1.addEventListener)('foregroundMessageReceived', (0, utils_3.createMessageEventRecorder)('received_foreground'));
113
+ launchNotificationOpenedListenerRemover = (0, eventListeners_1.addEventListener)('launchNotificationOpened', (0, utils_3.createMessageEventRecorder)('opened_notification',
114
+ // once we are done with it we can remove the listener
115
+ launchNotificationOpenedListenerRemover?.remove));
116
+ (0, eventListeners_1.addEventListener)('notificationOpened', (0, utils_3.createMessageEventRecorder)('opened_notification',
117
+ // if we are in this state, we no longer need the listener as the app was launched via some other means
118
+ launchNotificationOpenedListenerRemover?.remove));
119
+ };
120
+ const registerDevice = async (address) => {
121
+ const { credentials, identityId } = await (0, utils_2.resolveCredentials)();
122
+ const { appId, region } = (0, utils_3.resolveConfig)();
123
+ await (0, pinpoint_1.updateEndpoint)({
124
+ address,
125
+ appId,
126
+ category: 'PushNotification',
127
+ credentials,
128
+ region,
129
+ channelType: (0, utils_3.getChannelType)(),
130
+ identityId,
131
+ userAgentValue: (0, utils_2.getPushNotificationUserAgentString)(utils_1.PushNotificationAction.InitializePushNotifications),
157
132
  });
158
- }); };
133
+ };
@@ -2,7 +2,8 @@
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- var utils_1 = require("@aws-amplify/core/internals/utils");
5
+ exports.onNotificationOpened = void 0;
6
+ const utils_1 = require("@aws-amplify/core/internals/utils");
6
7
  /**
7
8
  * Registers a listener that will be triggered when a notification is opened by user.
8
9
  *
@@ -28,6 +29,7 @@ var utils_1 = require("@aws-amplify/core/internals/utils");
28
29
  * });
29
30
  * ```
30
31
  */
31
- exports.onNotificationOpened = function () {
32
+ const onNotificationOpened = () => {
32
33
  throw new utils_1.PlatformNotSupportedError();
33
34
  };
35
+ exports.onNotificationOpened = onNotificationOpened;
@@ -2,9 +2,11 @@
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- var eventListeners_1 = require("../../../../eventListeners");
6
- var errorHelpers_1 = require("../../../errors/errorHelpers");
7
- exports.onNotificationOpened = function (input) {
8
- errorHelpers_1.assertIsInitialized();
9
- return eventListeners_1.addEventListener('notificationOpened', input);
5
+ exports.onNotificationOpened = void 0;
6
+ const eventListeners_1 = require("../../../../eventListeners");
7
+ const errorHelpers_1 = require("../../../errors/errorHelpers");
8
+ const onNotificationOpened = input => {
9
+ (0, errorHelpers_1.assertIsInitialized)();
10
+ return (0, eventListeners_1.addEventListener)('notificationOpened', input);
10
11
  };
12
+ exports.onNotificationOpened = onNotificationOpened;