@aws-amplify/notifications 1.0.25 → 1.0.26-unstable.1116fef.4

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 (208) hide show
  1. package/lib/InAppMessaging/InAppMessaging.d.ts +10 -8
  2. package/lib/InAppMessaging/InAppMessaging.js +9 -11
  3. package/lib/InAppMessaging/InAppMessaging.js.map +1 -1
  4. package/lib/InAppMessaging/Providers/AWSPinpointProvider/index.d.ts +5 -25
  5. package/lib/InAppMessaging/Providers/AWSPinpointProvider/index.js +37 -252
  6. package/lib/InAppMessaging/Providers/AWSPinpointProvider/index.js.map +1 -1
  7. package/lib/InAppMessaging/Providers/AWSPinpointProvider/types.d.ts +0 -9
  8. package/lib/InAppMessaging/Providers/AWSPinpointProvider/types.js.map +1 -1
  9. package/lib/InAppMessaging/Providers/AWSPinpointProvider/utils.js +3 -9
  10. package/lib/InAppMessaging/Providers/AWSPinpointProvider/utils.js.map +1 -1
  11. package/lib/InAppMessaging/index.d.ts +1 -3
  12. package/lib/InAppMessaging/index.js +0 -2
  13. package/lib/InAppMessaging/index.js.map +1 -1
  14. package/lib/InAppMessaging/types.d.ts +30 -42
  15. package/lib/InAppMessaging/types.js +2 -0
  16. package/lib/InAppMessaging/types.js.map +1 -1
  17. package/lib/Notifications.d.ts +6 -2
  18. package/lib/Notifications.js +45 -0
  19. package/lib/Notifications.js.map +1 -1
  20. package/lib/PushNotification/NotEnabledError.d.ts +3 -0
  21. package/lib/PushNotification/NotEnabledError.js +16 -0
  22. package/lib/PushNotification/NotEnabledError.js.map +1 -0
  23. package/lib/PushNotification/Platform/index.d.ts +2 -0
  24. package/lib/PushNotification/Platform/index.js +26 -0
  25. package/lib/PushNotification/Platform/index.js.map +1 -0
  26. package/lib/PushNotification/Platform/index.native.d.ts +2 -0
  27. package/lib/PushNotification/Platform/index.native.js +8 -0
  28. package/lib/PushNotification/Platform/index.native.js.map +1 -0
  29. package/lib/PushNotification/Platform/types.d.ts +5 -0
  30. package/lib/PushNotification/Platform/types.js +5 -0
  31. package/lib/PushNotification/Platform/types.js.map +1 -0
  32. package/lib/PushNotification/PlatformNotSupportedError.d.ts +3 -0
  33. package/lib/PushNotification/PlatformNotSupportedError.js +16 -0
  34. package/lib/PushNotification/PlatformNotSupportedError.js.map +1 -0
  35. package/lib/PushNotification/Providers/AWSPinpointProvider/index.d.ts +15 -0
  36. package/lib/PushNotification/Providers/AWSPinpointProvider/index.js +115 -0
  37. package/lib/PushNotification/Providers/AWSPinpointProvider/index.js.map +1 -0
  38. package/lib/PushNotification/Providers/AWSPinpointProvider/types.d.ts +9 -0
  39. package/lib/PushNotification/Providers/AWSPinpointProvider/types.js +16 -0
  40. package/lib/PushNotification/Providers/AWSPinpointProvider/types.js.map +1 -0
  41. package/lib/PushNotification/Providers/AWSPinpointProvider/utils.d.ts +7 -0
  42. package/lib/PushNotification/Providers/AWSPinpointProvider/utils.js +58 -0
  43. package/lib/PushNotification/Providers/AWSPinpointProvider/utils.js.map +1 -0
  44. package/lib/PushNotification/Providers/index.d.ts +1 -0
  45. package/lib/PushNotification/Providers/index.js +7 -0
  46. package/lib/PushNotification/Providers/index.js.map +1 -0
  47. package/lib/PushNotification/PushNotification.d.ts +39 -0
  48. package/lib/PushNotification/PushNotification.js +91 -0
  49. package/lib/PushNotification/PushNotification.js.map +1 -0
  50. package/lib/PushNotification/PushNotification.native.d.ts +63 -0
  51. package/lib/PushNotification/PushNotification.native.js +327 -0
  52. package/lib/PushNotification/PushNotification.native.js.map +1 -0
  53. package/lib/PushNotification/index.d.ts +2 -0
  54. package/lib/PushNotification/index.js +9 -0
  55. package/lib/PushNotification/index.js.map +1 -0
  56. package/lib/PushNotification/types.d.ts +77 -0
  57. package/lib/PushNotification/types.js +12 -0
  58. package/lib/PushNotification/types.js.map +1 -0
  59. package/lib/PushNotification/utils.d.ts +3 -0
  60. package/lib/PushNotification/utils.js +81 -0
  61. package/lib/PushNotification/utils.js.map +1 -0
  62. package/lib/common/AWSPinpointProviderCommon/index.d.ts +34 -0
  63. package/lib/common/AWSPinpointProviderCommon/index.js +281 -0
  64. package/lib/common/AWSPinpointProviderCommon/index.js.map +1 -0
  65. package/lib/common/AWSPinpointProviderCommon/types.d.ts +9 -0
  66. package/lib/common/AWSPinpointProviderCommon/types.js +5 -0
  67. package/lib/common/AWSPinpointProviderCommon/types.js.map +1 -0
  68. package/lib/common/constants.d.ts +1 -0
  69. package/lib/common/constants.js +6 -0
  70. package/lib/common/constants.js.map +1 -0
  71. package/lib/common/eventListeners/index.d.ts +4 -0
  72. package/lib/common/eventListeners/index.js +55 -0
  73. package/lib/common/eventListeners/index.js.map +1 -0
  74. package/lib/common/eventListeners/types.d.ts +7 -0
  75. package/lib/common/eventListeners/types.js +5 -0
  76. package/lib/common/eventListeners/types.js.map +1 -0
  77. package/lib/common/index.d.ts +4 -0
  78. package/lib/common/index.js +13 -0
  79. package/lib/common/index.js.map +1 -0
  80. package/lib/index.d.ts +5 -2
  81. package/lib/index.js +4 -0
  82. package/lib/index.js.map +1 -1
  83. package/lib/types.d.ts +34 -2
  84. package/lib/types.js +2 -0
  85. package/lib/types.js.map +1 -1
  86. package/lib-esm/InAppMessaging/InAppMessaging.d.ts +10 -8
  87. package/lib-esm/InAppMessaging/InAppMessaging.js +9 -11
  88. package/lib-esm/InAppMessaging/InAppMessaging.js.map +1 -1
  89. package/lib-esm/InAppMessaging/Providers/AWSPinpointProvider/index.d.ts +5 -25
  90. package/lib-esm/InAppMessaging/Providers/AWSPinpointProvider/index.js +39 -254
  91. package/lib-esm/InAppMessaging/Providers/AWSPinpointProvider/index.js.map +1 -1
  92. package/lib-esm/InAppMessaging/Providers/AWSPinpointProvider/types.d.ts +0 -9
  93. package/lib-esm/InAppMessaging/Providers/AWSPinpointProvider/types.js.map +1 -1
  94. package/lib-esm/InAppMessaging/Providers/AWSPinpointProvider/utils.js +2 -8
  95. package/lib-esm/InAppMessaging/Providers/AWSPinpointProvider/utils.js.map +1 -1
  96. package/lib-esm/InAppMessaging/index.d.ts +1 -3
  97. package/lib-esm/InAppMessaging/index.js +0 -1
  98. package/lib-esm/InAppMessaging/index.js.map +1 -1
  99. package/lib-esm/InAppMessaging/types.d.ts +30 -42
  100. package/lib-esm/InAppMessaging/types.js +2 -0
  101. package/lib-esm/InAppMessaging/types.js.map +1 -1
  102. package/lib-esm/Notifications.d.ts +6 -2
  103. package/lib-esm/Notifications.js +48 -3
  104. package/lib-esm/Notifications.js.map +1 -1
  105. package/lib-esm/PushNotification/NotEnabledError.d.ts +3 -0
  106. package/lib-esm/PushNotification/NotEnabledError.js +14 -0
  107. package/lib-esm/PushNotification/NotEnabledError.js.map +1 -0
  108. package/lib-esm/PushNotification/Platform/index.d.ts +2 -0
  109. package/lib-esm/PushNotification/Platform/index.js +24 -0
  110. package/lib-esm/PushNotification/Platform/index.js.map +1 -0
  111. package/lib-esm/PushNotification/Platform/index.native.d.ts +2 -0
  112. package/lib-esm/PushNotification/Platform/index.native.js +6 -0
  113. package/lib-esm/PushNotification/Platform/index.native.js.map +1 -0
  114. package/lib-esm/PushNotification/Platform/types.d.ts +5 -0
  115. package/lib-esm/PushNotification/Platform/types.js +3 -0
  116. package/lib-esm/PushNotification/Platform/types.js.map +1 -0
  117. package/lib-esm/PushNotification/PlatformNotSupportedError.d.ts +3 -0
  118. package/lib-esm/PushNotification/PlatformNotSupportedError.js +14 -0
  119. package/lib-esm/PushNotification/PlatformNotSupportedError.js.map +1 -0
  120. package/lib-esm/PushNotification/Providers/AWSPinpointProvider/index.d.ts +15 -0
  121. package/lib-esm/PushNotification/Providers/AWSPinpointProvider/index.js +113 -0
  122. package/lib-esm/PushNotification/Providers/AWSPinpointProvider/index.js.map +1 -0
  123. package/lib-esm/PushNotification/Providers/AWSPinpointProvider/types.d.ts +9 -0
  124. package/lib-esm/PushNotification/Providers/AWSPinpointProvider/types.js +14 -0
  125. package/lib-esm/PushNotification/Providers/AWSPinpointProvider/types.js.map +1 -0
  126. package/lib-esm/PushNotification/Providers/AWSPinpointProvider/utils.d.ts +7 -0
  127. package/lib-esm/PushNotification/Providers/AWSPinpointProvider/utils.js +56 -0
  128. package/lib-esm/PushNotification/Providers/AWSPinpointProvider/utils.js.map +1 -0
  129. package/lib-esm/PushNotification/Providers/index.d.ts +1 -0
  130. package/lib-esm/PushNotification/Providers/index.js +4 -0
  131. package/lib-esm/PushNotification/Providers/index.js.map +1 -0
  132. package/lib-esm/PushNotification/PushNotification.d.ts +39 -0
  133. package/lib-esm/PushNotification/PushNotification.js +89 -0
  134. package/lib-esm/PushNotification/PushNotification.js.map +1 -0
  135. package/lib-esm/PushNotification/PushNotification.native.d.ts +63 -0
  136. package/lib-esm/PushNotification/PushNotification.native.js +325 -0
  137. package/lib-esm/PushNotification/PushNotification.native.js.map +1 -0
  138. package/lib-esm/PushNotification/index.d.ts +2 -0
  139. package/lib-esm/PushNotification/index.js +5 -0
  140. package/lib-esm/PushNotification/index.js.map +1 -0
  141. package/lib-esm/PushNotification/types.d.ts +77 -0
  142. package/lib-esm/PushNotification/types.js +10 -0
  143. package/lib-esm/PushNotification/types.js.map +1 -0
  144. package/lib-esm/PushNotification/utils.d.ts +3 -0
  145. package/lib-esm/PushNotification/utils.js +79 -0
  146. package/lib-esm/PushNotification/utils.js.map +1 -0
  147. package/lib-esm/common/AWSPinpointProviderCommon/index.d.ts +34 -0
  148. package/lib-esm/common/AWSPinpointProviderCommon/index.js +279 -0
  149. package/lib-esm/common/AWSPinpointProviderCommon/index.js.map +1 -0
  150. package/lib-esm/common/AWSPinpointProviderCommon/types.d.ts +9 -0
  151. package/lib-esm/common/AWSPinpointProviderCommon/types.js +3 -0
  152. package/lib-esm/common/AWSPinpointProviderCommon/types.js.map +1 -0
  153. package/lib-esm/common/constants.d.ts +1 -0
  154. package/lib-esm/common/constants.js +4 -0
  155. package/lib-esm/common/constants.js.map +1 -0
  156. package/lib-esm/common/eventListeners/index.d.ts +4 -0
  157. package/lib-esm/common/eventListeners/index.js +53 -0
  158. package/lib-esm/common/eventListeners/index.js.map +1 -0
  159. package/lib-esm/common/eventListeners/types.d.ts +7 -0
  160. package/lib-esm/common/eventListeners/types.js +3 -0
  161. package/lib-esm/common/eventListeners/types.js.map +1 -0
  162. package/lib-esm/common/index.d.ts +4 -0
  163. package/lib-esm/common/index.js +6 -0
  164. package/lib-esm/common/index.js.map +1 -0
  165. package/lib-esm/index.d.ts +5 -2
  166. package/lib-esm/index.js +2 -0
  167. package/lib-esm/index.js.map +1 -1
  168. package/lib-esm/types.d.ts +34 -2
  169. package/lib-esm/types.js +2 -0
  170. package/lib-esm/types.js.map +1 -1
  171. package/package.json +11 -50
  172. package/src/InAppMessaging/InAppMessaging.ts +27 -36
  173. package/src/InAppMessaging/Providers/AWSPinpointProvider/index.ts +45 -245
  174. package/src/InAppMessaging/Providers/AWSPinpointProvider/types.ts +0 -12
  175. package/src/InAppMessaging/Providers/AWSPinpointProvider/utils.ts +3 -12
  176. package/src/InAppMessaging/index.ts +0 -3
  177. package/src/InAppMessaging/types.ts +52 -56
  178. package/src/Notifications.ts +42 -4
  179. package/src/PushNotification/NotEnabledError.ts +11 -0
  180. package/src/PushNotification/Platform/index.native.ts +9 -0
  181. package/src/PushNotification/Platform/index.ts +22 -0
  182. package/src/PushNotification/Platform/types.ts +15 -0
  183. package/src/PushNotification/PlatformNotSupportedError.ts +9 -0
  184. package/src/PushNotification/Providers/AWSPinpointProvider/index.ts +137 -0
  185. package/src/PushNotification/Providers/AWSPinpointProvider/types.ts +13 -0
  186. package/src/PushNotification/Providers/AWSPinpointProvider/utils.ts +79 -0
  187. package/src/PushNotification/Providers/index.ts +4 -0
  188. package/src/PushNotification/PushNotification.native.ts +381 -0
  189. package/src/PushNotification/PushNotification.ts +107 -0
  190. package/src/PushNotification/index.ts +9 -0
  191. package/src/PushNotification/types.ts +114 -0
  192. package/src/PushNotification/utils.ts +112 -0
  193. package/src/common/AWSPinpointProviderCommon/index.ts +295 -0
  194. package/src/common/AWSPinpointProviderCommon/types.ts +14 -0
  195. package/src/common/constants.ts +5 -0
  196. package/src/common/eventListeners/index.ts +44 -0
  197. package/src/common/eventListeners/types.ts +12 -0
  198. package/src/common/index.ts +11 -0
  199. package/src/index.ts +9 -3
  200. package/src/types.ts +47 -2
  201. package/CHANGELOG.md +0 -215
  202. package/lib/InAppMessaging/eventListeners.d.ts +0 -3
  203. package/lib/InAppMessaging/eventListeners.js +0 -28
  204. package/lib/InAppMessaging/eventListeners.js.map +0 -1
  205. package/lib-esm/InAppMessaging/eventListeners.d.ts +0 -3
  206. package/lib-esm/InAppMessaging/eventListeners.js +0 -26
  207. package/lib-esm/InAppMessaging/eventListeners.js.map +0 -1
  208. package/src/InAppMessaging/eventListeners.ts +0 -42
@@ -1,46 +1,38 @@
1
- import { NotificationsCategory } from '../types';
2
- import { AWSPinpointProviderConfig } from './Providers/AWSPinpointProvider/types';
3
- export declare type NotificationsSubcategory = 'InAppMessaging';
4
- export declare type UserInfo = {
5
- attributes?: Record<string, string[]>;
6
- demographic?: {
7
- appVersion?: string;
8
- locale?: string;
9
- make?: string;
10
- model?: string;
11
- modelVersion?: string;
12
- platform?: string;
13
- platformVersion?: string;
14
- timezone?: string;
15
- };
16
- location?: {
17
- city?: string;
18
- country?: string;
19
- latitude?: number;
20
- longitude?: number;
21
- postalCode?: string;
22
- region?: string;
23
- };
24
- metrics?: Record<string, number>;
25
- };
1
+ import { EventListener } from '../common';
2
+ import { AWSPinpointProviderConfig } from '../common/AWSPinpointProviderCommon/types';
3
+ import { NotificationsProvider, NotificationsSubCategory as NotificationsSubCategories, UserInfo } from '../types';
4
+ export declare type NotificationsSubCategory = Extract<NotificationsSubCategories, 'InAppMessaging'>;
5
+ export interface InAppMessagingInterface {
6
+ configure: (config: InAppMessagingConfig) => InAppMessagingConfig;
7
+ getModuleName: () => NotificationsSubCategory;
8
+ getPluggable: (providerName: string) => InAppMessagingProvider;
9
+ addPluggable: (pluggable: InAppMessagingProvider) => void;
10
+ removePluggable: (providerName: string) => void;
11
+ syncMessages: () => Promise<void[]>;
12
+ clearMessages: () => Promise<void[]>;
13
+ dispatchEvent: (event: InAppMessagingEvent) => Promise<void>;
14
+ identifyUser: (userId: string, userInfo: UserInfo) => Promise<void[]>;
15
+ onMessageReceived: (handler: OnMessageInteractionEventHandler) => EventListener<OnMessageInteractionEventHandler>;
16
+ onMessageDisplayed: (handler: OnMessageInteractionEventHandler) => EventListener<OnMessageInteractionEventHandler>;
17
+ onMessageDismissed: (handler: OnMessageInteractionEventHandler) => EventListener<OnMessageInteractionEventHandler>;
18
+ onMessageActionTaken: (handler: OnMessageInteractionEventHandler) => EventListener<OnMessageInteractionEventHandler>;
19
+ notifyMessageInteraction: (message: InAppMessage, type: InAppMessageInteractionEvent) => void;
20
+ setConflictHandler: (handler: InAppMessageConflictHandler) => void;
21
+ }
22
+ export interface InAppMessagingProvider extends NotificationsProvider {
23
+ getSubCategory(): NotificationsSubCategory;
24
+ getInAppMessages(): Promise<any>;
25
+ processInAppMessages(messages: InAppMessage[], event: InAppMessagingEvent): Promise<InAppMessage[]>;
26
+ }
27
+ export interface InAppMessagingConfig {
28
+ listenForAnalyticsEvents?: boolean;
29
+ AWSPinpoint?: AWSPinpointProviderConfig;
30
+ }
26
31
  export declare type InAppMessagingEvent = {
27
32
  name: string;
28
33
  attributes?: Record<string, string>;
29
34
  metrics?: Record<string, number>;
30
35
  };
31
- export interface InAppMessagingConfig {
32
- listenForAnalyticsEvents?: boolean;
33
- AWSPinpoint?: AWSPinpointProviderConfig;
34
- }
35
- export interface InAppMessagingProvider {
36
- configure(config: object): object;
37
- getCategory(): NotificationsCategory;
38
- getSubCategory(): NotificationsSubcategory;
39
- getProviderName(): string;
40
- getInAppMessages(): Promise<any>;
41
- processInAppMessages(messages: InAppMessage[], event: InAppMessagingEvent): Promise<InAppMessage[]>;
42
- identifyUser(userId: string, userInfo: UserInfo): Promise<void>;
43
- }
44
36
  export declare type InAppMessageLayout = 'BOTTOM_BANNER' | 'CAROUSEL' | 'FULL_SCREEN' | 'MIDDLE_BANNER' | 'MODAL' | 'TOP_BANNER';
45
37
  export declare type InAppMessageAction = 'CLOSE' | 'DEEP_LINK' | 'LINK';
46
38
  export declare type InAppMessageTextAlign = 'center' | 'left' | 'right';
@@ -85,10 +77,6 @@ export interface InAppMessage {
85
77
  metadata?: any;
86
78
  }
87
79
  export declare type OnMessageInteractionEventHandler = (message: InAppMessage) => any;
88
- export interface OnMessageInteractionEventListener {
89
- handleEvent: OnMessageInteractionEventHandler;
90
- remove: () => void;
91
- }
92
80
  export declare enum InAppMessageInteractionEvent {
93
81
  MESSAGE_RECEIVED = "MESSAGE_RECEIVED_EVENT",
94
82
  MESSAGE_DISPLAYED = "MESSAGE_DISPLAYED_EVENT",
@@ -1,3 +1,5 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
1
3
  export var InAppMessageInteractionEvent;
2
4
  (function (InAppMessageInteractionEvent) {
3
5
  InAppMessageInteractionEvent["MESSAGE_RECEIVED"] = "MESSAGE_RECEIVED_EVENT";
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/InAppMessaging/types.ts"],"names":[],"mappings":"AAwIA,MAAM,CAAN,IAAY,4BAKX;AALD,WAAY,4BAA4B;IACvC,2EAA2C,CAAA;IAC3C,6EAA6C,CAAA;IAC7C,6EAA6C,CAAA;IAC7C,mFAAmD,CAAA;AACpD,CAAC,EALW,4BAA4B,KAA5B,4BAA4B,QAKvC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/InAppMessaging/types.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAmItC,MAAM,CAAN,IAAY,4BAKX;AALD,WAAY,4BAA4B;IACvC,2EAA2C,CAAA;IAC3C,6EAA6C,CAAA;IAC7C,6EAA6C,CAAA;IAC7C,mFAAmD,CAAA;AACpD,CAAC,EALW,4BAA4B,KAA5B,4BAA4B,QAKvC"}
@@ -1,8 +1,10 @@
1
- import InAppMessaging from './InAppMessaging';
2
- import { NotificationsCategory, NotificationsConfig } from './types';
1
+ import { InAppMessagingInterface as InAppMessaging } from './InAppMessaging/types';
2
+ import { PushNotificationInterface as PushNotification } from './PushNotification/types';
3
+ import { NotificationsCategory, NotificationsConfig, UserInfo } from './types';
3
4
  declare class NotificationsClass {
4
5
  private config;
5
6
  private inAppMessaging;
7
+ private pushNotification?;
6
8
  constructor();
7
9
  /**
8
10
  * Get the name of the module category
@@ -15,6 +17,8 @@ declare class NotificationsClass {
15
17
  */
16
18
  configure: ({ Notifications: config }?: NotificationsConfig) => Record<string, any>;
17
19
  get InAppMessaging(): InAppMessaging;
20
+ get Push(): PushNotification;
21
+ identifyUser: (userId: string, userInfo: UserInfo) => Promise<void[]>;
18
22
  }
19
23
  declare const Notifications: NotificationsClass;
20
24
  export default Notifications;
@@ -1,8 +1,8 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import { __assign } from "tslib";
3
+ import { __assign, __awaiter, __generator } from "tslib";
4
4
  import { Amplify, ConsoleLogger as Logger } from '@aws-amplify/core';
5
- import InAppMessaging from './InAppMessaging';
5
+ import InAppMessagingClass from './InAppMessaging';
6
6
  var logger = new Logger('Notifications');
7
7
  var NotificationsClass = /** @class */ (function () {
8
8
  function NotificationsClass() {
@@ -18,9 +18,46 @@ var NotificationsClass = /** @class */ (function () {
18
18
  logger.debug('configure Notifications', config);
19
19
  // Configure sub-categories
20
20
  _this.inAppMessaging.configure(_this.config.InAppMessaging);
21
+ if (_this.config.Push) {
22
+ try {
23
+ var PushNotification = require('./PushNotification').default;
24
+ _this.pushNotification = new PushNotification();
25
+ _this.pushNotification.configure(_this.config.Push);
26
+ }
27
+ catch (err) {
28
+ logger.error(err);
29
+ }
30
+ }
21
31
  return _this.config;
22
32
  };
23
- this.inAppMessaging = new InAppMessaging();
33
+ this.identifyUser = function (userId, userInfo) {
34
+ var identifyFunctions = [];
35
+ if (_this.inAppMessaging) {
36
+ identifyFunctions.push(_this.inAppMessaging.identifyUser);
37
+ }
38
+ if (_this.pushNotification) {
39
+ identifyFunctions.push(_this.pushNotification.identifyUser);
40
+ }
41
+ return Promise.all(identifyFunctions.map(function (identifyFunction) { return __awaiter(_this, void 0, void 0, function () {
42
+ var err_1;
43
+ return __generator(this, function (_a) {
44
+ switch (_a.label) {
45
+ case 0:
46
+ _a.trys.push([0, 2, , 3]);
47
+ return [4 /*yield*/, identifyFunction(userId, userInfo)];
48
+ case 1:
49
+ _a.sent();
50
+ return [3 /*break*/, 3];
51
+ case 2:
52
+ err_1 = _a.sent();
53
+ logger.error('Failed to identify user', err_1);
54
+ throw err_1;
55
+ case 3: return [2 /*return*/];
56
+ }
57
+ });
58
+ }); }));
59
+ };
60
+ this.inAppMessaging = new InAppMessagingClass();
24
61
  }
25
62
  /**
26
63
  * Get the name of the module category
@@ -36,6 +73,14 @@ var NotificationsClass = /** @class */ (function () {
36
73
  enumerable: true,
37
74
  configurable: true
38
75
  });
76
+ Object.defineProperty(NotificationsClass.prototype, "Push", {
77
+ get: function () {
78
+ var _a;
79
+ return (_a = this.pushNotification) !== null && _a !== void 0 ? _a : {};
80
+ },
81
+ enumerable: true,
82
+ configurable: true
83
+ });
39
84
  return NotificationsClass;
40
85
  }());
41
86
  var Notifications = new NotificationsClass();
@@ -1 +1 @@
1
- {"version":3,"file":"Notifications.js","sourceRoot":"","sources":["../src/Notifications.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,EAAE,OAAO,EAAE,aAAa,IAAI,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAG9C,IAAM,MAAM,GAAG,IAAI,MAAM,CAAC,eAAe,CAAC,CAAC;AAE3C;IAIC;QAAA,iBAEC;QALO,WAAM,GAAwB,EAAE,CAAC;QAezC;;;WAGG;QACH,cAA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AE,CAAC;IACjD,CAAC;IAED;;;OAGG;IACH,0CAAa,GAAb;QACC,OAAO,eAAe,CAAC;IACxB,CAAC;IA2BD,sBAAI,8CAAc;aAAlB;YACC,OAAO,IAAI,CAAC,cAAc,CAAC;QAC5B,CAAC;;;OAAA;IAED,sBAAI,oCAAI;aAAR;;YACC,aAAO,IAAI,CAAC,gBAAgB,mCAAK,EAAuB,CAAC;QAC1D,CAAC;;;OAAA;IAqBF,yBAAC;AAAD,CAAC,AArED,IAqEC;AAED,IAAM,aAAa,GAAG,IAAI,kBAAkB,EAAE,CAAC;AAE/C,eAAe,aAAa,CAAC;AAC7B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export default class NotEnabledError extends Error {
2
+ constructor();
3
+ }
@@ -0,0 +1,14 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { __extends } from "tslib";
4
+ var NotEnabledError = /** @class */ (function (_super) {
5
+ __extends(NotEnabledError, _super);
6
+ function NotEnabledError() {
7
+ var _this = _super.call(this, 'Function is unavailable as Push has not been enabled. Please call `Push.enable` before calling this function.') || this;
8
+ _this.name = 'NotEnabledError';
9
+ return _this;
10
+ }
11
+ return NotEnabledError;
12
+ }(Error));
13
+ export default NotEnabledError;
14
+ //# sourceMappingURL=NotEnabledError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotEnabledError.js","sourceRoot":"","sources":["../../src/PushNotification/NotEnabledError.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC;IAA6C,mCAAK;IACjD;QAAA,YACC,kBACC,+GAA+G,CAC/G,SAED;QADA,KAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;;IAC/B,CAAC;IACF,sBAAC;AAAD,CAAC,AAPD,CAA6C,KAAK,GAOjD"}
@@ -0,0 +1,2 @@
1
+ import { Platform as PlatformInterface } from './types';
2
+ export declare const Platform: PlatformInterface;
@@ -0,0 +1,24 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ var userAgentIncludes = function (text) {
4
+ var _a;
5
+ return (_a = navigator === null || navigator === void 0 ? void 0 : navigator.userAgent) === null || _a === void 0 ? void 0 : _a.includes(text);
6
+ };
7
+ var getOS = function () {
8
+ if (userAgentIncludes('Android'))
9
+ return 'android';
10
+ if (userAgentIncludes('like Mac'))
11
+ return 'ios';
12
+ if (userAgentIncludes('Win'))
13
+ return 'windows';
14
+ if (userAgentIncludes('Mac'))
15
+ return 'macos';
16
+ if (userAgentIncludes('Linux'))
17
+ return 'linux';
18
+ if (userAgentIncludes('X11'))
19
+ return 'unix';
20
+ return 'unknown';
21
+ };
22
+ var OS = getOS();
23
+ export var Platform = { OS: OS };
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/PushNotification/Platform/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAItC,IAAM,iBAAiB,GAAG,UAAC,IAAY;;IACtC,aAAO,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,SAAS,0CAAE,QAAQ,CAAC,IAAI,EAAE;AAC7C,CAAC,CAAC;AAEF,IAAM,KAAK,GAAG;IACb,IAAI,iBAAiB,CAAC,SAAS,CAAC;QAAE,OAAO,SAAS,CAAC;IACnD,IAAI,iBAAiB,CAAC,UAAU,CAAC;QAAE,OAAO,KAAK,CAAC;IAChD,IAAI,iBAAiB,CAAC,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC/C,IAAI,iBAAiB,CAAC,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC;IAC7C,IAAI,iBAAiB,CAAC,OAAO,CAAC;QAAE,OAAO,OAAO,CAAC;IAC/C,IAAI,iBAAiB,CAAC,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC;IAC5C,OAAO,SAAS,CAAC;AAClB,CAAC,CAAC;AAEF,IAAM,EAAE,GAAG,KAAK,EAAE,CAAC;AAEnB,MAAM,CAAC,IAAM,QAAQ,GAAsB,EAAE,EAAE,IAAA,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { Platform as PlatformInterface } from './types';
2
+ export declare const Platform: PlatformInterface;
@@ -0,0 +1,6 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { Platform as NativePlatform } from 'react-native';
4
+ var OS = NativePlatform.OS;
5
+ export var Platform = { OS: OS };
6
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.native.js","sourceRoot":"","sources":["../../../src/PushNotification/Platform/index.native.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,cAAc,CAAC;AAGlD,IAAA,sBAAE,CAAoB;AAE9B,MAAM,CAAC,IAAM,QAAQ,GAAsB,EAAE,EAAE,IAAA,EAAE,CAAC"}
@@ -0,0 +1,5 @@
1
+ export interface Platform {
2
+ OS: KnownOS | 'unknown';
3
+ }
4
+ declare type KnownOS = 'windows' | 'macos' | 'unix' | 'linux' | 'ios' | 'android' | 'web';
5
+ export {};
@@ -0,0 +1,3 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/PushNotification/Platform/types.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC"}
@@ -0,0 +1,3 @@
1
+ export default class PlatformNotSupportedError extends Error {
2
+ constructor();
3
+ }
@@ -0,0 +1,14 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { __extends } from "tslib";
4
+ var PlatformNotSupportedError = /** @class */ (function (_super) {
5
+ __extends(PlatformNotSupportedError, _super);
6
+ function PlatformNotSupportedError() {
7
+ var _this = _super.call(this, 'Function not supported on current platform') || this;
8
+ _this.name = 'PlatformNotSupportedError';
9
+ return _this;
10
+ }
11
+ return PlatformNotSupportedError;
12
+ }(Error));
13
+ export default PlatformNotSupportedError;
14
+ //# sourceMappingURL=PlatformNotSupportedError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlatformNotSupportedError.js","sourceRoot":"","sources":["../../src/PushNotification/PlatformNotSupportedError.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC;IAAuD,6CAAK;IAC3D;QAAA,YACC,kBAAM,4CAA4C,CAAC,SAEnD;QADA,KAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;;IACzC,CAAC;IACF,gCAAC;AAAD,CAAC,AALD,CAAuD,KAAK,GAK3D"}
@@ -0,0 +1,15 @@
1
+ import { AWSPinpointProviderCommon } from '../../../common';
2
+ import { PushNotificationProvider, NotificationsSubCategory } from '../../types';
3
+ export default class AWSPinpointProvider extends AWSPinpointProviderCommon implements PushNotificationProvider {
4
+ static subCategory: NotificationsSubCategory;
5
+ private configured;
6
+ constructor();
7
+ /**
8
+ * get the sub-category of the plugin
9
+ */
10
+ getSubCategory(): "PushNotification";
11
+ configure: (config?: {}) => Record<string, any>;
12
+ registerDevice: (address: string) => Promise<void>;
13
+ private getChannelType;
14
+ private recordMessageEvent;
15
+ }
@@ -0,0 +1,113 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { __assign, __awaiter, __extends, __generator } from "tslib";
4
+ import { ChannelType } from '@aws-sdk/client-pinpoint';
5
+ import { addEventListener, AWSPinpointProviderCommon } from '../../../common';
6
+ import PlatformNotSupportedError from '../../PlatformNotSupportedError';
7
+ import { Platform } from '../../Platform';
8
+ import { AWSPinpointMessageEvent } from './types';
9
+ import { dispatchPushNotificationEvent, getAnalyticsEvent, logger, } from './utils';
10
+ var AWSPinpointProvider = /** @class */ (function (_super) {
11
+ __extends(AWSPinpointProvider, _super);
12
+ function AWSPinpointProvider() {
13
+ var _this = _super.call(this, logger) || this;
14
+ _this.configured = false;
15
+ _this.configure = function (config) {
16
+ if (config === void 0) { config = {}; }
17
+ _this.config = __assign(__assign({}, _super.prototype.configure.call(_this, config)), { endpointInfo: { channelType: _this.getChannelType() } });
18
+ // some configuration steps should not be re-run even if provider is re-configured for some reason
19
+ if (!_this.configured) {
20
+ // wire up default Pinpoint message event handling
21
+ addEventListener(0 /* BACKGROUND_MESSAGE_RECEIVED */, function (message) {
22
+ return _this.recordMessageEvent(message, AWSPinpointMessageEvent.BACKGROUND_MESSAGE_RECEIVED);
23
+ });
24
+ addEventListener(1 /* FOREGROUND_MESSAGE_RECEIVED */, function (message) {
25
+ return _this.recordMessageEvent(message, AWSPinpointMessageEvent.FOREGROUND_MESSAGE_RECEIVED);
26
+ });
27
+ var launchNotificationOpenedListener_1 = addEventListener(2 /* LAUNCH_NOTIFICATION_OPENED */, function (message) {
28
+ _this.recordMessageEvent(message, AWSPinpointMessageEvent.NOTIFICATION_OPENED);
29
+ // once we are done with it we can remove the listener
30
+ launchNotificationOpenedListener_1 === null || launchNotificationOpenedListener_1 === void 0 ? void 0 : launchNotificationOpenedListener_1.remove();
31
+ });
32
+ addEventListener(3 /* NOTIFICATION_OPENED */, function (message) {
33
+ _this.recordMessageEvent(message, AWSPinpointMessageEvent.NOTIFICATION_OPENED);
34
+ // if we are in this state, we no longer need the listener as the app was launched via some other means
35
+ launchNotificationOpenedListener_1 === null || launchNotificationOpenedListener_1 === void 0 ? void 0 : launchNotificationOpenedListener_1.remove();
36
+ });
37
+ }
38
+ _this.configured = true;
39
+ dispatchPushNotificationEvent('pinpointProvider_configured', null);
40
+ return _this.config;
41
+ };
42
+ _this.registerDevice = function (address) { return __awaiter(_this, void 0, void 0, function () {
43
+ var err_1;
44
+ return __generator(this, function (_a) {
45
+ switch (_a.label) {
46
+ case 0:
47
+ if (!!this.initialized) return [3 /*break*/, 2];
48
+ return [4 /*yield*/, this.init()];
49
+ case 1:
50
+ _a.sent();
51
+ _a.label = 2;
52
+ case 2:
53
+ _a.trys.push([2, 4, , 5]);
54
+ this.config.endpointInfo = __assign(__assign({}, this.config.endpointInfo), { address: address });
55
+ return [4 /*yield*/, this.updateEndpoint()];
56
+ case 3:
57
+ _a.sent();
58
+ return [3 /*break*/, 5];
59
+ case 4:
60
+ err_1 = _a.sent();
61
+ this.logger.error('Error registering device', err_1);
62
+ throw err_1;
63
+ case 5: return [2 /*return*/];
64
+ }
65
+ });
66
+ }); };
67
+ _this.getChannelType = function () {
68
+ switch (Platform.OS) {
69
+ case 'android': {
70
+ // FCM was previously known as GCM and continues to be the channel type in Pinpoint
71
+ return ChannelType.GCM;
72
+ }
73
+ case 'ios': {
74
+ // If building in debug mode, use the APNs sandbox
75
+ return global['__DEV__'] ? ChannelType.APNS_SANDBOX : ChannelType.APNS;
76
+ }
77
+ default: {
78
+ throw new PlatformNotSupportedError();
79
+ }
80
+ }
81
+ };
82
+ _this.recordMessageEvent = function (message, event) { return __awaiter(_this, void 0, void 0, function () {
83
+ var analyticsEvent;
84
+ return __generator(this, function (_a) {
85
+ switch (_a.label) {
86
+ case 0:
87
+ analyticsEvent = getAnalyticsEvent(message, event);
88
+ if (!analyticsEvent) {
89
+ logger.debug('A notification missing event information was not recorded');
90
+ return [2 /*return*/];
91
+ }
92
+ if (!!this.initialized) return [3 /*break*/, 2];
93
+ return [4 /*yield*/, this.init()];
94
+ case 1:
95
+ _a.sent();
96
+ _a.label = 2;
97
+ case 2: return [2 /*return*/, this.recordAnalyticsEvent(analyticsEvent)];
98
+ }
99
+ });
100
+ }); };
101
+ return _this;
102
+ }
103
+ /**
104
+ * get the sub-category of the plugin
105
+ */
106
+ AWSPinpointProvider.prototype.getSubCategory = function () {
107
+ return AWSPinpointProvider.subCategory;
108
+ };
109
+ AWSPinpointProvider.subCategory = 'PushNotification';
110
+ return AWSPinpointProvider;
111
+ }(AWSPinpointProviderCommon));
112
+ export default AWSPinpointProvider;
113
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/PushNotification/Providers/AWSPinpointProvider/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,yBAAyB,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAO1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EACN,6BAA6B,EAC7B,iBAAiB,EACjB,MAAM,GACN,MAAM,SAAS,CAAC;AAEjB;IACS,uCAAyB;IAOjC;QAAA,YACC,kBAAM,MAAM,CAAC,SACb;QAJO,gBAAU,GAAG,KAAK,CAAC;QAa3B,eAAS,GAAG,UAAC,MAAW;YAAX,uBAAA,EAAA,WAAW;YACvB,KAAI,CAAC,MAAM,yBACP,iBAAM,SAAS,aAAC,MAAM,CAAC,KAC1B,YAAY,EAAE,EAAE,WAAW,EAAE,KAAI,CAAC,cAAc,EAAE,EAAE,GACpD,CAAC;YAEF,kGAAkG;YAClG,IAAI,CAAC,KAAI,CAAC,UAAU,EAAE;gBACrB,kDAAkD;gBAClD,gBAAgB,sCAEf,UAAA,OAAO;oBACN,OAAA,KAAI,CAAC,kBAAkB,CACtB,OAAO,EACP,uBAAuB,CAAC,2BAA2B,CACnD;gBAHD,CAGC,CACF,CAAC;gBACF,gBAAgB,sCAEf,UAAA,OAAO;oBACN,OAAA,KAAI,CAAC,kBAAkB,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mF;oBACnF,OAAO,WAAW,CAAC,GAAG,CAAC;iBACvB;gBACD,KAAK,KAAK,CAAC,CAAC;oBACX,kDAAkD;oBAClD,OAAO,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC;iBACvE;gBACD,OAAO,CAAC,CAAC;oBACR,MAAM,IAAI,yBAAyB,EAAE,CAAC;iBACtC;aACD;QACF,CAAC,CAAC;QAEM,wBAAkB,GAAG,UAC5B,OAAgC,EAChC,KAA8B;;;;;wBAExB,cAAc,GAAG,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;wBACzD,IAAI,CAAC,cAAc,EAAE;4BACpB,MAAM,CAAC,KAAK,CAAC,2DAA2D,CAAC,CAAC;4BAC1E,sBAAO;yBACP;6BACG,CAAC,IAAI,CAAC,WAAW,EAAjB,wBAAiB;wBACpB,qBAAM,IAAI,CAAC,IAAI,EAAE,EAAA;;wBAAjB,SAAiB,CAAC;;4BAEnB,sBAAO,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,EAAC;;;aACjD,CAAC;;IAzGF,CAAC;IAED;;OAEG;IACH,4CAAc,GAAd;QACC,OAAO,mBAAmB,CAAC,WAAW,CAAC;IACxC,CAAC;IAbM,+BAAW,GAA6B,kBAAkB,CAAC;IAgHnE,0BAAC;CAAA,AApHD,CACS,yBAAyB,GAmHjC;eApHoB,mBAAmB"}
@@ -0,0 +1,9 @@
1
+ export declare enum AWSPinpointMessageEventSource {
2
+ CAMPAIGN = "_campaign",
3
+ JOURNEY = "_journey"
4
+ }
5
+ export declare enum AWSPinpointMessageEvent {
6
+ NOTIFICATION_OPENED = "opened_notification",
7
+ BACKGROUND_MESSAGE_RECEIVED = "received_background",
8
+ FOREGROUND_MESSAGE_RECEIVED = "received_foreground"
9
+ }
@@ -0,0 +1,14 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export var AWSPinpointMessageEventSource;
4
+ (function (AWSPinpointMessageEventSource) {
5
+ AWSPinpointMessageEventSource["CAMPAIGN"] = "_campaign";
6
+ AWSPinpointMessageEventSource["JOURNEY"] = "_journey";
7
+ })(AWSPinpointMessageEventSource || (AWSPinpointMessageEventSource = {}));
8
+ export var AWSPinpointMessageEvent;
9
+ (function (AWSPinpointMessageEvent) {
10
+ AWSPinpointMessageEvent["NOTIFICATION_OPENED"] = "opened_notification";
11
+ AWSPinpointMessageEvent["BACKGROUND_MESSAGE_RECEIVED"] = "received_background";
12
+ AWSPinpointMessageEvent["FOREGROUND_MESSAGE_RECEIVED"] = "received_foreground";
13
+ })(AWSPinpointMessageEvent || (AWSPinpointMessageEvent = {}));
14
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/PushNotification/Providers/AWSPinpointProvider/types.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,MAAM,CAAN,IAAY,6BAGX;AAHD,WAAY,6BAA6B;IACxC,uDAAsB,CAAA;IACtB,qDAAoB,CAAA;AACrB,CAAC,EAHW,6BAA6B,KAA7B,6BAA6B,QAGxC;AAED,MAAM,CAAN,IAAY,uBAIX;AAJD,WAAY,uBAAuB;IAClC,sEAA2C,CAAA;IAC3C,8EAAmD,CAAA;IACnD,8EAAmD,CAAA;AACpD,CAAC,EAJW,uBAAuB,KAAvB,uBAAuB,QAIlC"}
@@ -0,0 +1,7 @@
1
+ import { Event as AWSPinpointAnalyticsEvent } from '@aws-sdk/client-pinpoint';
2
+ import { ConsoleLogger } from '@aws-amplify/core';
3
+ import { PushNotificationMessage } from '../../types';
4
+ import { AWSPinpointMessageEvent } from './types';
5
+ export declare const logger: ConsoleLogger;
6
+ export declare const dispatchPushNotificationEvent: (event: string, data: any, message?: string) => void;
7
+ export declare const getAnalyticsEvent: ({ data }: PushNotificationMessage, event: AWSPinpointMessageEvent) => AWSPinpointAnalyticsEvent;
@@ -0,0 +1,56 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { ConsoleLogger, Hub } from '@aws-amplify/core';
4
+ import { AMPLIFY_SYMBOL } from '../../../common';
5
+ import { AWSPinpointMessageEventSource, } from './types';
6
+ var ANDROID_CAMPAIGN_ACTIVITY_ID_KEY = 'pinpoint.campaign.campaign_activity_id';
7
+ var ANDROID_CAMPAIGN_ID_KEY = 'pinpoint.campaign.campaign_id';
8
+ var ANDROID_CAMPAIGN_TREATMENT_ID_KEY = 'pinpoint.campaign.treatment_id';
9
+ export var logger = new ConsoleLogger('PushNotification.AWSPinpointProvider');
10
+ export var dispatchPushNotificationEvent = function (event, data, message) {
11
+ Hub.dispatch('pushNotification', { event: event, data: data, message: message }, 'PushNotification', AMPLIFY_SYMBOL);
12
+ };
13
+ export var getAnalyticsEvent = function (_a, event) {
14
+ var data = _a.data;
15
+ if (!data) {
16
+ return null;
17
+ }
18
+ var eventAttributes = getAnalyticsEventAttributes(data);
19
+ if (!eventAttributes) {
20
+ return null;
21
+ }
22
+ var source = eventAttributes.source, attributes = eventAttributes.attributes;
23
+ return {
24
+ Attributes: attributes,
25
+ EventType: source + "." + event,
26
+ Timestamp: new Date().toISOString(),
27
+ };
28
+ };
29
+ var getAnalyticsEventAttributes = function (data) {
30
+ if (data.hasOwnProperty(ANDROID_CAMPAIGN_ID_KEY)) {
31
+ return {
32
+ source: AWSPinpointMessageEventSource.CAMPAIGN,
33
+ attributes: {
34
+ campaign_activity_id: data[ANDROID_CAMPAIGN_ACTIVITY_ID_KEY],
35
+ campaign_id: data[ANDROID_CAMPAIGN_ID_KEY],
36
+ treatment_id: data[ANDROID_CAMPAIGN_TREATMENT_ID_KEY],
37
+ },
38
+ };
39
+ }
40
+ var pinpoint = typeof data.pinpoint === 'string'
41
+ ? JSON.parse(data.pinpoint)
42
+ : data.pinpoint;
43
+ if (pinpoint === null || pinpoint === void 0 ? void 0 : pinpoint.campaign) {
44
+ return {
45
+ source: AWSPinpointMessageEventSource.CAMPAIGN,
46
+ attributes: pinpoint.campaign,
47
+ };
48
+ }
49
+ if (pinpoint === null || pinpoint === void 0 ? void 0 : pinpoint.journey) {
50
+ return {
51
+ source: AWSPinpointMessageEventSource.JOURNEY,
52
+ attributes: pinpoint.journey,
53
+ };
54
+ }
55
+ };
56
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/PushNotification/Providers/AWSPinpointProvider/utils.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAGtC,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EACN,6BAA6B,GAE7B,MAAM,SAAS,CAAC;AAEjB,IAAM,gCAAgC,GACrC,wCAAwC,CAAC;AAC1C,IAAM,uBAAuB,GAAG,+BAA+B,CAAC;AAChE,IAAM,iCAAiC,GAAG,gCAAgC,CAAC;AAE3E,MAAM,CAAC,IAAM,MAAM,GAAG,IAAI,aAAa,CAAC,sCAAsC,CAAC,CAAC;AAEhF,MAAM,CAAC,IAAM,6BAA6B,GAAG,UAC5C,KAAa,EACb,IAAS,EACT,OAAgB;IAEhB,GAAG,CAAC,QAAQ,CACX,kBAAkB,EAClB,EAAE,KAAK,OAAA,EAAE,IAAI,MAAA,EAAE,OAAO,SAAA,EAAE,EACxB,kBAAkB,EAClB,cAAc,CACd,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,iBAAiB,GAAG,UAChC,EAAiC,EACjC,KAA8B;QAD5B,cAAI;IAGN,IAAI,CAAC,IAAI,EAAE;QACV,OAAO,IAAI,CAAC;KACZ;IACD,IAAM,eAAe,GAAG,2BAA2B,CAAC,IAAI,CAAC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iliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export { default as AWSPinpointProvider } from './AWSPinpointProvider';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/PushNotification/Providers/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { NotificationsSubCategory, OnPushNotificationMessageHandler, OnTokenReceivedHandler, PushNotificationConfig, PushNotificationInterface, PushNotificationMessage, PushNotificationPermissions, PushNotificationPermissionStatus, PushNotificationProvider } from './types';
2
+ export default class PushNotification implements PushNotificationInterface {
3
+ /**
4
+ * Configure PushNotification
5
+ * @param {Object} config - PushNotification configuration object
6
+ */
7
+ configure: (_?: PushNotificationConfig) => PushNotificationConfig;
8
+ /**
9
+ * Get the name of this module
10
+ * @returns {string} name of this module
11
+ */
12
+ getModuleName(): NotificationsSubCategory;
13
+ /**
14
+ * Get a plugin from added plugins
15
+ * @param {string} providerName - the name of the plugin to get
16
+ */
17
+ getPluggable: (_: string) => never;
18
+ /**
19
+ * Add plugin into PushNotification
20
+ * @param {PushNotificationProvider} pluggable - an instance of the plugin
21
+ */
22
+ addPluggable: (_: PushNotificationProvider) => void;
23
+ /**
24
+ * Remove a plugin from added plugins
25
+ * @param {string} providerName - the name of the plugin to remove
26
+ */
27
+ removePluggable: () => void;
28
+ enable: () => void;
29
+ identifyUser: () => Promise<void[]>;
30
+ getLaunchNotification: () => Promise<PushNotificationMessage>;
31
+ getBadgeCount: () => Promise<number>;
32
+ setBadgeCount: (_: number) => void;
33
+ getPermissionStatus: () => Promise<PushNotificationPermissionStatus>;
34
+ requestPermissions: (_?: PushNotificationPermissions) => Promise<boolean>;
35
+ onNotificationReceivedInBackground: (_: OnPushNotificationMessageHandler) => any;
36
+ onNotificationReceivedInForeground: (_: OnPushNotificationMessageHandler) => any;
37
+ onTokenReceived: (_: OnTokenReceivedHandler) => any;
38
+ onNotificationOpened: (_: OnPushNotificationMessageHandler) => any;
39
+ }