@aws-amplify/notifications 1.0.25 → 1.0.26-unstable.1b5840e.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/InAppMessaging/InAppMessaging.d.ts +10 -8
- package/lib/InAppMessaging/InAppMessaging.js +9 -11
- package/lib/InAppMessaging/InAppMessaging.js.map +1 -1
- package/lib/InAppMessaging/Providers/AWSPinpointProvider/index.d.ts +5 -25
- package/lib/InAppMessaging/Providers/AWSPinpointProvider/index.js +37 -252
- package/lib/InAppMessaging/Providers/AWSPinpointProvider/index.js.map +1 -1
- package/lib/InAppMessaging/Providers/AWSPinpointProvider/types.d.ts +0 -9
- package/lib/InAppMessaging/Providers/AWSPinpointProvider/types.js.map +1 -1
- package/lib/InAppMessaging/Providers/AWSPinpointProvider/utils.js +3 -9
- package/lib/InAppMessaging/Providers/AWSPinpointProvider/utils.js.map +1 -1
- package/lib/InAppMessaging/index.d.ts +1 -3
- package/lib/InAppMessaging/index.js +0 -2
- package/lib/InAppMessaging/index.js.map +1 -1
- package/lib/InAppMessaging/types.d.ts +30 -42
- package/lib/InAppMessaging/types.js +2 -0
- package/lib/InAppMessaging/types.js.map +1 -1
- package/lib/Notifications.d.ts +6 -2
- package/lib/Notifications.js +45 -0
- package/lib/Notifications.js.map +1 -1
- package/lib/PushNotification/NotEnabledError.d.ts +3 -0
- package/lib/PushNotification/NotEnabledError.js +16 -0
- package/lib/PushNotification/NotEnabledError.js.map +1 -0
- package/lib/PushNotification/Platform/index.d.ts +2 -0
- package/lib/PushNotification/Platform/index.js +26 -0
- package/lib/PushNotification/Platform/index.js.map +1 -0
- package/lib/PushNotification/Platform/index.native.d.ts +2 -0
- package/lib/PushNotification/Platform/index.native.js +8 -0
- package/lib/PushNotification/Platform/index.native.js.map +1 -0
- package/lib/PushNotification/Platform/types.d.ts +5 -0
- package/lib/PushNotification/Platform/types.js +5 -0
- package/lib/PushNotification/Platform/types.js.map +1 -0
- package/lib/PushNotification/PlatformNotSupportedError.d.ts +3 -0
- package/lib/PushNotification/PlatformNotSupportedError.js +16 -0
- package/lib/PushNotification/PlatformNotSupportedError.js.map +1 -0
- package/lib/PushNotification/Providers/AWSPinpointProvider/index.d.ts +15 -0
- package/lib/PushNotification/Providers/AWSPinpointProvider/index.js +115 -0
- package/lib/PushNotification/Providers/AWSPinpointProvider/index.js.map +1 -0
- package/lib/PushNotification/Providers/AWSPinpointProvider/types.d.ts +9 -0
- package/lib/PushNotification/Providers/AWSPinpointProvider/types.js +16 -0
- package/lib/PushNotification/Providers/AWSPinpointProvider/types.js.map +1 -0
- package/lib/PushNotification/Providers/AWSPinpointProvider/utils.d.ts +7 -0
- package/lib/PushNotification/Providers/AWSPinpointProvider/utils.js +58 -0
- package/lib/PushNotification/Providers/AWSPinpointProvider/utils.js.map +1 -0
- package/lib/PushNotification/Providers/index.d.ts +1 -0
- package/lib/PushNotification/Providers/index.js +7 -0
- package/lib/PushNotification/Providers/index.js.map +1 -0
- package/lib/PushNotification/PushNotification.d.ts +39 -0
- package/lib/PushNotification/PushNotification.js +91 -0
- package/lib/PushNotification/PushNotification.js.map +1 -0
- package/lib/PushNotification/PushNotification.native.d.ts +63 -0
- package/lib/PushNotification/PushNotification.native.js +327 -0
- package/lib/PushNotification/PushNotification.native.js.map +1 -0
- package/lib/PushNotification/index.d.ts +2 -0
- package/lib/PushNotification/index.js +9 -0
- package/lib/PushNotification/index.js.map +1 -0
- package/lib/PushNotification/types.d.ts +77 -0
- package/lib/PushNotification/types.js +12 -0
- package/lib/PushNotification/types.js.map +1 -0
- package/lib/PushNotification/utils.d.ts +3 -0
- package/lib/PushNotification/utils.js +81 -0
- package/lib/PushNotification/utils.js.map +1 -0
- package/lib/common/AWSPinpointProviderCommon/index.d.ts +34 -0
- package/lib/common/AWSPinpointProviderCommon/index.js +281 -0
- package/lib/common/AWSPinpointProviderCommon/index.js.map +1 -0
- package/lib/common/AWSPinpointProviderCommon/types.d.ts +9 -0
- package/lib/common/AWSPinpointProviderCommon/types.js +5 -0
- package/lib/common/AWSPinpointProviderCommon/types.js.map +1 -0
- package/lib/common/constants.d.ts +1 -0
- package/lib/common/constants.js +6 -0
- package/lib/common/constants.js.map +1 -0
- package/lib/common/eventListeners/index.d.ts +4 -0
- package/lib/common/eventListeners/index.js +55 -0
- package/lib/common/eventListeners/index.js.map +1 -0
- package/lib/common/eventListeners/types.d.ts +7 -0
- package/lib/common/eventListeners/types.js +5 -0
- package/lib/common/eventListeners/types.js.map +1 -0
- package/lib/common/index.d.ts +4 -0
- package/lib/common/index.js +13 -0
- package/lib/common/index.js.map +1 -0
- package/lib/index.d.ts +5 -2
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -1
- package/lib/types.d.ts +34 -2
- package/lib/types.js +2 -0
- package/lib/types.js.map +1 -1
- package/lib-esm/InAppMessaging/InAppMessaging.d.ts +10 -8
- package/lib-esm/InAppMessaging/InAppMessaging.js +9 -11
- package/lib-esm/InAppMessaging/InAppMessaging.js.map +1 -1
- package/lib-esm/InAppMessaging/Providers/AWSPinpointProvider/index.d.ts +5 -25
- package/lib-esm/InAppMessaging/Providers/AWSPinpointProvider/index.js +39 -254
- package/lib-esm/InAppMessaging/Providers/AWSPinpointProvider/index.js.map +1 -1
- package/lib-esm/InAppMessaging/Providers/AWSPinpointProvider/types.d.ts +0 -9
- package/lib-esm/InAppMessaging/Providers/AWSPinpointProvider/types.js.map +1 -1
- package/lib-esm/InAppMessaging/Providers/AWSPinpointProvider/utils.js +2 -8
- package/lib-esm/InAppMessaging/Providers/AWSPinpointProvider/utils.js.map +1 -1
- package/lib-esm/InAppMessaging/index.d.ts +1 -3
- package/lib-esm/InAppMessaging/index.js +0 -1
- package/lib-esm/InAppMessaging/index.js.map +1 -1
- package/lib-esm/InAppMessaging/types.d.ts +30 -42
- package/lib-esm/InAppMessaging/types.js +2 -0
- package/lib-esm/InAppMessaging/types.js.map +1 -1
- package/lib-esm/Notifications.d.ts +6 -2
- package/lib-esm/Notifications.js +48 -3
- package/lib-esm/Notifications.js.map +1 -1
- package/lib-esm/PushNotification/NotEnabledError.d.ts +3 -0
- package/lib-esm/PushNotification/NotEnabledError.js +14 -0
- package/lib-esm/PushNotification/NotEnabledError.js.map +1 -0
- package/lib-esm/PushNotification/Platform/index.d.ts +2 -0
- package/lib-esm/PushNotification/Platform/index.js +24 -0
- package/lib-esm/PushNotification/Platform/index.js.map +1 -0
- package/lib-esm/PushNotification/Platform/index.native.d.ts +2 -0
- package/lib-esm/PushNotification/Platform/index.native.js +6 -0
- package/lib-esm/PushNotification/Platform/index.native.js.map +1 -0
- package/lib-esm/PushNotification/Platform/types.d.ts +5 -0
- package/lib-esm/PushNotification/Platform/types.js +3 -0
- package/lib-esm/PushNotification/Platform/types.js.map +1 -0
- package/lib-esm/PushNotification/PlatformNotSupportedError.d.ts +3 -0
- package/lib-esm/PushNotification/PlatformNotSupportedError.js +14 -0
- package/lib-esm/PushNotification/PlatformNotSupportedError.js.map +1 -0
- package/lib-esm/PushNotification/Providers/AWSPinpointProvider/index.d.ts +15 -0
- package/lib-esm/PushNotification/Providers/AWSPinpointProvider/index.js +113 -0
- package/lib-esm/PushNotification/Providers/AWSPinpointProvider/index.js.map +1 -0
- package/lib-esm/PushNotification/Providers/AWSPinpointProvider/types.d.ts +9 -0
- package/lib-esm/PushNotification/Providers/AWSPinpointProvider/types.js +14 -0
- package/lib-esm/PushNotification/Providers/AWSPinpointProvider/types.js.map +1 -0
- package/lib-esm/PushNotification/Providers/AWSPinpointProvider/utils.d.ts +7 -0
- package/lib-esm/PushNotification/Providers/AWSPinpointProvider/utils.js +56 -0
- package/lib-esm/PushNotification/Providers/AWSPinpointProvider/utils.js.map +1 -0
- package/lib-esm/PushNotification/Providers/index.d.ts +1 -0
- package/lib-esm/PushNotification/Providers/index.js +4 -0
- package/lib-esm/PushNotification/Providers/index.js.map +1 -0
- package/lib-esm/PushNotification/PushNotification.d.ts +39 -0
- package/lib-esm/PushNotification/PushNotification.js +89 -0
- package/lib-esm/PushNotification/PushNotification.js.map +1 -0
- package/lib-esm/PushNotification/PushNotification.native.d.ts +63 -0
- package/lib-esm/PushNotification/PushNotification.native.js +325 -0
- package/lib-esm/PushNotification/PushNotification.native.js.map +1 -0
- package/lib-esm/PushNotification/index.d.ts +2 -0
- package/lib-esm/PushNotification/index.js +5 -0
- package/lib-esm/PushNotification/index.js.map +1 -0
- package/lib-esm/PushNotification/types.d.ts +77 -0
- package/lib-esm/PushNotification/types.js +10 -0
- package/lib-esm/PushNotification/types.js.map +1 -0
- package/lib-esm/PushNotification/utils.d.ts +3 -0
- package/lib-esm/PushNotification/utils.js +79 -0
- package/lib-esm/PushNotification/utils.js.map +1 -0
- package/lib-esm/common/AWSPinpointProviderCommon/index.d.ts +34 -0
- package/lib-esm/common/AWSPinpointProviderCommon/index.js +279 -0
- package/lib-esm/common/AWSPinpointProviderCommon/index.js.map +1 -0
- package/lib-esm/common/AWSPinpointProviderCommon/types.d.ts +9 -0
- package/lib-esm/common/AWSPinpointProviderCommon/types.js +3 -0
- package/lib-esm/common/AWSPinpointProviderCommon/types.js.map +1 -0
- package/lib-esm/common/constants.d.ts +1 -0
- package/lib-esm/common/constants.js +4 -0
- package/lib-esm/common/constants.js.map +1 -0
- package/lib-esm/common/eventListeners/index.d.ts +4 -0
- package/lib-esm/common/eventListeners/index.js +53 -0
- package/lib-esm/common/eventListeners/index.js.map +1 -0
- package/lib-esm/common/eventListeners/types.d.ts +7 -0
- package/lib-esm/common/eventListeners/types.js +3 -0
- package/lib-esm/common/eventListeners/types.js.map +1 -0
- package/lib-esm/common/index.d.ts +4 -0
- package/lib-esm/common/index.js +6 -0
- package/lib-esm/common/index.js.map +1 -0
- package/lib-esm/index.d.ts +5 -2
- package/lib-esm/index.js +2 -0
- package/lib-esm/index.js.map +1 -1
- package/lib-esm/types.d.ts +34 -2
- package/lib-esm/types.js +2 -0
- package/lib-esm/types.js.map +1 -1
- package/package.json +11 -50
- package/src/InAppMessaging/InAppMessaging.ts +27 -36
- package/src/InAppMessaging/Providers/AWSPinpointProvider/index.ts +45 -245
- package/src/InAppMessaging/Providers/AWSPinpointProvider/types.ts +0 -12
- package/src/InAppMessaging/Providers/AWSPinpointProvider/utils.ts +3 -12
- package/src/InAppMessaging/index.ts +0 -3
- package/src/InAppMessaging/types.ts +52 -56
- package/src/Notifications.ts +42 -4
- package/src/PushNotification/NotEnabledError.ts +11 -0
- package/src/PushNotification/Platform/index.native.ts +9 -0
- package/src/PushNotification/Platform/index.ts +22 -0
- package/src/PushNotification/Platform/types.ts +15 -0
- package/src/PushNotification/PlatformNotSupportedError.ts +9 -0
- package/src/PushNotification/Providers/AWSPinpointProvider/index.ts +137 -0
- package/src/PushNotification/Providers/AWSPinpointProvider/types.ts +13 -0
- package/src/PushNotification/Providers/AWSPinpointProvider/utils.ts +79 -0
- package/src/PushNotification/Providers/index.ts +4 -0
- package/src/PushNotification/PushNotification.native.ts +381 -0
- package/src/PushNotification/PushNotification.ts +107 -0
- package/src/PushNotification/index.ts +9 -0
- package/src/PushNotification/types.ts +114 -0
- package/src/PushNotification/utils.ts +112 -0
- package/src/common/AWSPinpointProviderCommon/index.ts +295 -0
- package/src/common/AWSPinpointProviderCommon/types.ts +14 -0
- package/src/common/constants.ts +5 -0
- package/src/common/eventListeners/index.ts +44 -0
- package/src/common/eventListeners/types.ts +12 -0
- package/src/common/index.ts +11 -0
- package/src/index.ts +9 -3
- package/src/types.ts +47 -2
- package/CHANGELOG.md +0 -215
- package/lib/InAppMessaging/eventListeners.d.ts +0 -3
- package/lib/InAppMessaging/eventListeners.js +0 -28
- package/lib/InAppMessaging/eventListeners.js.map +0 -1
- package/lib-esm/InAppMessaging/eventListeners.d.ts +0 -3
- package/lib-esm/InAppMessaging/eventListeners.js +0 -26
- package/lib-esm/InAppMessaging/eventListeners.js.map +0 -1
- package/src/InAppMessaging/eventListeners.ts +0 -42
|
@@ -1,46 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AWSPinpointProviderConfig } from '
|
|
3
|
-
|
|
4
|
-
export declare type
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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":"
|
|
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 {
|
|
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;
|
package/lib-esm/Notifications.js
CHANGED
|
@@ -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
|
|
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.
|
|
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;
|
|
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;AAErE,OAAO,mBAAmB,MAAM,kBAAkB,CAAC;AAKnD,IAAM,MAAM,GAAG,IAAI,MAAM,CAAC,eAAe,CAAC,CAAC;AAE3C;IAKC;QAAA,iBAEC;QANO,WAAM,GAAwB,EAAE,CAAC;QAgBzC;;;WAGG;QACH,cAAS,GAAG,UAAC,EAAmD;gBAAjD,gDAAqB;YACnC,KAAI,CAAC,MAAM,yBAAQ,KAAI,CAAC,MAAM,GAAK,MAAM,CAAE,CAAC;YAE5C,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE,MAAM,CAAC,CAAC;YAEhD,2BAA2B;YAC3B,KAAI,CAAC,cAAc,CAAC,SAAS,CAAC,KAAI,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;YAE1D,IAAI,KAAI,CAAC,MAAM,CAAC,IAAI,EAAE;gBACrB,IAAI;oBACH,IAAM,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC;oBAC/D,KAAI,CAAC,gBAAgB,GAAG,IAAI,gBAAgB,EAAE,CAAC;oBAC/C,KAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,KAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;iBAClD;gBAAC,OAAO,GAAG,EAAE;oBACb,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC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on.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,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,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 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/PushNotification/Platform/types.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC"}
|
|
@@ -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,G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BAAmB,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,CAAC;IAC1D,IAAI,CAAC,eAAe,EAAE;QACrB,OAAO,IAAI,CAAC;KACZ;IACO,IAAA,+BAAM,EAAE,uCAAU,CAAqB;IAC/C,OAAO;QACN,UAAU,EAAE,UAAU;QACtB,SAAS,EAAK,MAAM,SAAI,KAAO;QAC/B,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACnC,CAAC;AACH,CAAC,CAAC;AAEF,IAAM,2BAA2B,GAAG,UAAC,IAAqC;IACzE,IAAI,IAAI,CAAC,cAAc,CAAC,uBAAuB,CAAC,EAAE;QACjD,OAAO;YACN,MAAM,EAAE,6BAA6B,CAAC,QAAQ;YAC9C,UAAU,EAAE;gBACX,oBAAoB,EAAE,IAAI,CAAC,gCAAgC,CAAC;gBAC5D,WAAW,EAAE,IAAI,CAAC,uBAAuB,CAAC;gBAC1C,YAAY,EAAE,IAAI,CAAC,iCAAiC,CAAC;aACrD;SACD,CAAC;KACF;IACD,IAAM,QAAQ,GACb,OAAO,IAAI,CAAC,QAAQ,KAAK,QAAQ;QAChC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;QAC3B,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;IAClB,IAAI,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,QAAQ,EAAE;QACvB,OAAO;YACN,MAAM,EAAE,6BAA6B,CAAC,QAAQ;YAC9C,UAAU,EAAE,QAAQ,CAAC,QAAQ;SAC7B,CAAC;KACF;IACD,IAAI,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,EAAE;QACtB,OAAO;YACN,MAAM,EAAE,6BAA6B,CAAC,OAAO;YAC7C,UAAU,EAAE,QAAQ,CAAC,OAAO;SAC5B,CAAC;KACF;AACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as AWSPinpointProvider } from './AWSPinpointProvider';
|
|
@@ -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
|
+
}
|