@aws-amplify/notifications 2.0.1-api-v6-models.9351bcf.0 → 2.0.1-api-v6-models.891fe0d.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.
- package/in-app-messaging/package.json +4 -4
- package/lib/eventListeners/eventListeners.js +19 -37
- package/lib/eventListeners/index.js +4 -3
- package/lib/eventListeners/types.d.ts +2 -2
- package/lib/inAppMessaging/errors/InAppMessagingError.js +8 -11
- package/lib/inAppMessaging/errors/assertServiceError.js +3 -2
- package/lib/inAppMessaging/errors/assertValidationError.js +5 -4
- package/lib/inAppMessaging/errors/index.js +6 -5
- package/lib/inAppMessaging/errors/validation.js +7 -7
- package/lib/inAppMessaging/index.d.ts +2 -1
- package/lib/inAppMessaging/index.js +12 -10
- package/lib/inAppMessaging/providers/pinpoint/apis/clearMessages.d.ts +13 -0
- package/lib/inAppMessaging/providers/pinpoint/apis/clearMessages.js +26 -0
- package/lib/inAppMessaging/providers/pinpoint/apis/dispatchEvent.js +26 -38
- package/lib/inAppMessaging/providers/pinpoint/apis/identifyUser.d.ts +2 -1
- package/lib/inAppMessaging/providers/pinpoint/apis/identifyUser.js +24 -35
- package/lib/inAppMessaging/providers/pinpoint/apis/index.d.ts +1 -0
- package/lib/inAppMessaging/providers/pinpoint/apis/index.js +13 -10
- package/lib/inAppMessaging/providers/pinpoint/apis/initializeInAppMessaging.js +21 -21
- package/lib/inAppMessaging/providers/pinpoint/apis/notifyMessageInteraction.js +6 -6
- package/lib/inAppMessaging/providers/pinpoint/apis/onMessageActionTaken.js +5 -4
- package/lib/inAppMessaging/providers/pinpoint/apis/onMessageDismissed.js +5 -4
- package/lib/inAppMessaging/providers/pinpoint/apis/onMessageDisplayed.js +5 -4
- package/lib/inAppMessaging/providers/pinpoint/apis/onMessageReceived.js +5 -4
- package/lib/inAppMessaging/providers/pinpoint/apis/setConflictHandler.js +6 -6
- package/lib/inAppMessaging/providers/pinpoint/apis/syncMessages.js +46 -76
- package/lib/inAppMessaging/providers/pinpoint/index.d.ts +1 -1
- package/lib/inAppMessaging/providers/pinpoint/index.js +12 -10
- package/lib/inAppMessaging/providers/pinpoint/types/index.js +2 -1
- package/lib/inAppMessaging/providers/pinpoint/types/inputs.d.ts +8 -8
- package/lib/inAppMessaging/providers/pinpoint/types/options.d.ts +1 -1
- package/lib/inAppMessaging/providers/pinpoint/types/outputs.d.ts +4 -4
- package/lib/inAppMessaging/providers/pinpoint/types/types.d.ts +6 -6
- package/lib/inAppMessaging/providers/pinpoint/types/types.js +1 -0
- package/lib/inAppMessaging/providers/pinpoint/utils/constants.js +1 -0
- package/lib/inAppMessaging/providers/pinpoint/utils/helpers.d.ts +3 -3
- package/lib/inAppMessaging/providers/pinpoint/utils/helpers.js +114 -110
- package/lib/inAppMessaging/providers/pinpoint/utils/index.js +11 -10
- package/lib/inAppMessaging/providers/pinpoint/utils/messageProcessingHelpers.js +116 -191
- package/lib/inAppMessaging/providers/pinpoint/utils/resolveConfig.js +9 -8
- package/lib/inAppMessaging/providers/pinpoint/utils/resolveCredentials.d.ts +1 -1
- package/lib/inAppMessaging/providers/pinpoint/utils/resolveCredentials.js +9 -15
- package/lib/inAppMessaging/providers/pinpoint/utils/userAgent.js +6 -5
- package/lib/inAppMessaging/types/event.d.ts +2 -2
- package/lib/inAppMessaging/types/inputs.d.ts +1 -1
- package/lib/inAppMessaging/types/message.d.ts +3 -3
- package/lib/inAppMessaging/types/options.d.ts +1 -1
- package/lib/inAppMessaging/utils/index.js +4 -3
- package/lib/inAppMessaging/utils/statusHelpers.js +8 -5
- package/lib/index.js +1 -0
- package/lib/pushNotifications/errors/PushNotificationError.js +8 -11
- package/lib/pushNotifications/errors/errorHelpers.js +14 -13
- package/lib/pushNotifications/errors/index.js +4 -3
- package/lib/pushNotifications/index.d.ts +1 -1
- package/lib/pushNotifications/index.js +13 -12
- package/lib/pushNotifications/providers/pinpoint/apis/getBadgeCount.js +4 -2
- package/lib/pushNotifications/providers/pinpoint/apis/getBadgeCount.native.js +9 -10
- package/lib/pushNotifications/providers/pinpoint/apis/getLaunchNotification.js +4 -2
- package/lib/pushNotifications/providers/pinpoint/apis/getLaunchNotification.native.js +7 -5
- package/lib/pushNotifications/providers/pinpoint/apis/getPermissionStatus.js +4 -2
- package/lib/pushNotifications/providers/pinpoint/apis/getPermissionStatus.native.js +7 -5
- package/lib/pushNotifications/providers/pinpoint/apis/identifyUser.js +4 -2
- package/lib/pushNotifications/providers/pinpoint/apis/identifyUser.native.js +25 -36
- package/lib/pushNotifications/providers/pinpoint/apis/index.js +12 -11
- package/lib/pushNotifications/providers/pinpoint/apis/initializePushNotifications.js +4 -2
- package/lib/pushNotifications/providers/pinpoint/apis/initializePushNotifications.native.d.ts +1 -1
- package/lib/pushNotifications/providers/pinpoint/apis/initializePushNotifications.native.js +90 -115
- package/lib/pushNotifications/providers/pinpoint/apis/onNotificationOpened.js +4 -2
- package/lib/pushNotifications/providers/pinpoint/apis/onNotificationOpened.native.js +7 -5
- package/lib/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInBackground.js +4 -2
- package/lib/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInBackground.native.js +7 -5
- package/lib/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInForeground.js +4 -2
- package/lib/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInForeground.native.js +7 -5
- package/lib/pushNotifications/providers/pinpoint/apis/onTokenReceived.js +4 -2
- package/lib/pushNotifications/providers/pinpoint/apis/onTokenReceived.native.js +7 -5
- package/lib/pushNotifications/providers/pinpoint/apis/requestPermissions.js +4 -2
- package/lib/pushNotifications/providers/pinpoint/apis/requestPermissions.native.js +7 -5
- package/lib/pushNotifications/providers/pinpoint/apis/setBadgeCount.js +4 -2
- package/lib/pushNotifications/providers/pinpoint/apis/setBadgeCount.native.js +7 -5
- package/lib/pushNotifications/providers/pinpoint/index.d.ts +1 -1
- package/lib/pushNotifications/providers/pinpoint/index.js +12 -11
- package/lib/pushNotifications/providers/pinpoint/types/analytics.d.ts +3 -3
- package/lib/pushNotifications/providers/pinpoint/types/apis.d.ts +11 -11
- package/lib/pushNotifications/providers/pinpoint/types/inputs.d.ts +7 -7
- package/lib/pushNotifications/providers/pinpoint/types/options.d.ts +1 -1
- package/lib/pushNotifications/providers/pinpoint/types/outputs.d.ts +8 -8
- package/lib/pushNotifications/providers/pinpoint/types/pushNotifications.d.ts +1 -1
- package/lib/pushNotifications/providers/pinpoint/utils/createMessageEventRecorder.d.ts +3 -2
- package/lib/pushNotifications/providers/pinpoint/utils/createMessageEventRecorder.js +33 -49
- package/lib/pushNotifications/providers/pinpoint/utils/getAnalyticsEvent.d.ts +3 -2
- package/lib/pushNotifications/providers/pinpoint/utils/getAnalyticsEvent.js +17 -13
- package/lib/pushNotifications/providers/pinpoint/utils/getChannelType.d.ts +2 -1
- package/lib/pushNotifications/providers/pinpoint/utils/getChannelType.js +9 -7
- package/lib/pushNotifications/providers/pinpoint/utils/index.d.ts +2 -1
- package/lib/pushNotifications/providers/pinpoint/utils/index.js +7 -4
- package/lib/pushNotifications/providers/pinpoint/utils/resolveConfig.js +17 -0
- package/lib/pushNotifications/types/errors.js +1 -0
- package/lib/pushNotifications/types/index.d.ts +1 -0
- package/lib/pushNotifications/types/index.js +20 -2
- package/lib/pushNotifications/types/inputs.d.ts +9 -8
- package/lib/pushNotifications/types/module.d.ts +31 -0
- package/lib/pushNotifications/types/options.d.ts +1 -1
- package/lib/pushNotifications/types/outputs.d.ts +8 -8
- package/lib/pushNotifications/types/pushNotifications.d.ts +4 -5
- package/lib/pushNotifications/utils/getPushNotificationUserAgentString.js +11 -0
- package/lib/pushNotifications/utils/index.d.ts +1 -1
- package/lib/pushNotifications/utils/index.js +8 -7
- package/lib/pushNotifications/utils/initializationManager.js +8 -9
- package/lib/pushNotifications/utils/resolveCredentials.d.ts +1 -1
- package/lib/pushNotifications/utils/resolveCredentials.js +9 -15
- package/lib/pushNotifications/utils/tokenManager.js +6 -3
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib-esm/eventListeners/eventListeners.js +15 -37
- package/lib-esm/eventListeners/types.d.ts +2 -2
- package/lib-esm/eventListeners/types.js +1 -0
- package/lib-esm/inAppMessaging/errors/InAppMessagingError.js +6 -11
- package/lib-esm/inAppMessaging/errors/assertValidationError.js +2 -2
- package/lib-esm/inAppMessaging/errors/validation.js +6 -7
- package/lib-esm/inAppMessaging/index.d.ts +2 -1
- package/lib-esm/inAppMessaging/index.js +1 -1
- package/lib-esm/inAppMessaging/providers/pinpoint/apis/clearMessages.d.ts +13 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/apis/clearMessages.js +22 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/apis/dispatchEvent.js +15 -31
- package/lib-esm/inAppMessaging/providers/pinpoint/apis/identifyUser.d.ts +2 -1
- package/lib-esm/inAppMessaging/providers/pinpoint/apis/identifyUser.js +18 -31
- package/lib-esm/inAppMessaging/providers/pinpoint/apis/index.d.ts +1 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/apis/index.js +1 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/apis/initializeInAppMessaging.js +5 -6
- package/lib-esm/inAppMessaging/providers/pinpoint/apis/notifyMessageInteraction.js +1 -2
- package/lib-esm/inAppMessaging/providers/pinpoint/apis/setConflictHandler.js +4 -5
- package/lib-esm/inAppMessaging/providers/pinpoint/apis/syncMessages.js +38 -69
- package/lib-esm/inAppMessaging/providers/pinpoint/index.d.ts +1 -1
- package/lib-esm/inAppMessaging/providers/pinpoint/index.js +1 -1
- package/lib-esm/inAppMessaging/providers/pinpoint/types/inputs.d.ts +8 -8
- package/lib-esm/inAppMessaging/providers/pinpoint/types/inputs.js +1 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/types/options.d.ts +1 -1
- package/lib-esm/inAppMessaging/providers/pinpoint/types/options.js +1 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/types/outputs.d.ts +4 -4
- package/lib-esm/inAppMessaging/providers/pinpoint/types/outputs.js +1 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/types/types.d.ts +6 -6
- package/lib-esm/inAppMessaging/providers/pinpoint/utils/constants.js +4 -4
- package/lib-esm/inAppMessaging/providers/pinpoint/utils/helpers.d.ts +3 -3
- package/lib-esm/inAppMessaging/providers/pinpoint/utils/helpers.js +85 -97
- package/lib-esm/inAppMessaging/providers/pinpoint/utils/messageProcessingHelpers.js +111 -187
- package/lib-esm/inAppMessaging/providers/pinpoint/utils/resolveConfig.js +3 -4
- package/lib-esm/inAppMessaging/providers/pinpoint/utils/resolveCredentials.d.ts +1 -1
- package/lib-esm/inAppMessaging/providers/pinpoint/utils/resolveCredentials.js +5 -13
- package/lib-esm/inAppMessaging/providers/pinpoint/utils/userAgent.js +2 -2
- package/lib-esm/inAppMessaging/types/event.d.ts +2 -2
- package/lib-esm/inAppMessaging/types/event.js +1 -0
- package/lib-esm/inAppMessaging/types/index.js +1 -0
- package/lib-esm/inAppMessaging/types/inputs.d.ts +1 -1
- package/lib-esm/inAppMessaging/types/inputs.js +1 -0
- package/lib-esm/inAppMessaging/types/message.d.ts +3 -3
- package/lib-esm/inAppMessaging/types/message.js +1 -0
- package/lib-esm/inAppMessaging/types/options.d.ts +1 -1
- package/lib-esm/inAppMessaging/types/options.js +1 -0
- package/lib-esm/inAppMessaging/utils/statusHelpers.js +3 -3
- package/lib-esm/index.js +1 -0
- package/lib-esm/pushNotifications/errors/PushNotificationError.js +6 -11
- package/lib-esm/pushNotifications/errors/errorHelpers.js +8 -9
- package/lib-esm/pushNotifications/index.d.ts +1 -1
- package/lib-esm/pushNotifications/providers/pinpoint/apis/getBadgeCount.js +1 -1
- package/lib-esm/pushNotifications/providers/pinpoint/apis/getBadgeCount.native.js +5 -8
- package/lib-esm/pushNotifications/providers/pinpoint/apis/getLaunchNotification.js +1 -1
- package/lib-esm/pushNotifications/providers/pinpoint/apis/getLaunchNotification.native.js +2 -2
- package/lib-esm/pushNotifications/providers/pinpoint/apis/getPermissionStatus.js +1 -1
- package/lib-esm/pushNotifications/providers/pinpoint/apis/getPermissionStatus.native.js +2 -2
- package/lib-esm/pushNotifications/providers/pinpoint/apis/identifyUser.js +1 -1
- package/lib-esm/pushNotifications/providers/pinpoint/apis/identifyUser.native.js +20 -33
- package/lib-esm/pushNotifications/providers/pinpoint/apis/initializePushNotifications.js +1 -1
- package/lib-esm/pushNotifications/providers/pinpoint/apis/initializePushNotifications.native.d.ts +1 -1
- package/lib-esm/pushNotifications/providers/pinpoint/apis/initializePushNotifications.native.js +76 -103
- package/lib-esm/pushNotifications/providers/pinpoint/apis/onNotificationOpened.js +1 -1
- package/lib-esm/pushNotifications/providers/pinpoint/apis/onNotificationOpened.native.js +1 -1
- package/lib-esm/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInBackground.js +1 -1
- package/lib-esm/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInBackground.native.js +1 -1
- package/lib-esm/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInForeground.js +1 -1
- package/lib-esm/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInForeground.native.js +1 -1
- package/lib-esm/pushNotifications/providers/pinpoint/apis/onTokenReceived.js +1 -1
- package/lib-esm/pushNotifications/providers/pinpoint/apis/onTokenReceived.native.js +1 -1
- package/lib-esm/pushNotifications/providers/pinpoint/apis/requestPermissions.js +1 -1
- package/lib-esm/pushNotifications/providers/pinpoint/apis/requestPermissions.native.js +2 -2
- package/lib-esm/pushNotifications/providers/pinpoint/apis/setBadgeCount.js +1 -1
- package/lib-esm/pushNotifications/providers/pinpoint/apis/setBadgeCount.native.js +2 -2
- package/lib-esm/pushNotifications/providers/pinpoint/index.d.ts +1 -1
- package/lib-esm/pushNotifications/providers/pinpoint/types/analytics.d.ts +3 -3
- package/lib-esm/pushNotifications/providers/pinpoint/types/analytics.js +1 -0
- package/lib-esm/pushNotifications/providers/pinpoint/types/apis.d.ts +11 -11
- package/lib-esm/pushNotifications/providers/pinpoint/types/apis.js +1 -0
- package/lib-esm/pushNotifications/providers/pinpoint/types/index.js +1 -0
- package/lib-esm/pushNotifications/providers/pinpoint/types/inputs.d.ts +7 -7
- package/lib-esm/pushNotifications/providers/pinpoint/types/inputs.js +1 -0
- package/lib-esm/pushNotifications/providers/pinpoint/types/options.d.ts +1 -1
- package/lib-esm/pushNotifications/providers/pinpoint/types/options.js +1 -0
- package/lib-esm/pushNotifications/providers/pinpoint/types/outputs.d.ts +8 -8
- package/lib-esm/pushNotifications/providers/pinpoint/types/outputs.js +1 -0
- package/lib-esm/pushNotifications/providers/pinpoint/types/pushNotifications.d.ts +1 -1
- package/lib-esm/pushNotifications/providers/pinpoint/types/pushNotifications.js +1 -0
- package/lib-esm/pushNotifications/providers/pinpoint/utils/createMessageEventRecorder.d.ts +3 -2
- package/lib-esm/pushNotifications/providers/pinpoint/utils/createMessageEventRecorder.js +27 -45
- package/lib-esm/pushNotifications/providers/pinpoint/utils/getAnalyticsEvent.d.ts +3 -2
- package/lib-esm/pushNotifications/providers/pinpoint/utils/getAnalyticsEvent.js +15 -13
- package/lib-esm/pushNotifications/providers/pinpoint/utils/getChannelType.d.ts +2 -1
- package/lib-esm/pushNotifications/providers/pinpoint/utils/getChannelType.js +5 -5
- package/lib-esm/pushNotifications/providers/pinpoint/utils/index.d.ts +2 -1
- package/lib-esm/pushNotifications/providers/pinpoint/utils/index.js +2 -1
- package/lib-esm/pushNotifications/{utils → providers/pinpoint/utils}/resolveConfig.js +4 -5
- package/lib-esm/pushNotifications/types/index.d.ts +1 -0
- package/lib-esm/pushNotifications/types/index.js +5 -0
- package/lib-esm/pushNotifications/types/inputs.d.ts +9 -8
- package/lib-esm/pushNotifications/types/inputs.js +1 -0
- package/lib-esm/pushNotifications/types/module.d.ts +31 -0
- package/lib-esm/pushNotifications/{Platform/types.js → types/module.js} +1 -0
- package/lib-esm/pushNotifications/types/options.d.ts +1 -1
- package/lib-esm/pushNotifications/types/options.js +1 -0
- package/lib-esm/pushNotifications/types/outputs.d.ts +8 -8
- package/lib-esm/pushNotifications/types/outputs.js +1 -0
- package/lib-esm/pushNotifications/types/pushNotifications.d.ts +4 -5
- package/lib-esm/pushNotifications/types/pushNotifications.js +1 -0
- package/lib-esm/pushNotifications/{providers/pinpoint/utils → utils}/getPushNotificationUserAgentString.js +4 -6
- package/lib-esm/pushNotifications/utils/index.d.ts +1 -1
- package/lib-esm/pushNotifications/utils/index.js +1 -1
- package/lib-esm/pushNotifications/utils/initializationManager.js +5 -9
- package/lib-esm/pushNotifications/utils/resolveCredentials.d.ts +1 -1
- package/lib-esm/pushNotifications/utils/resolveCredentials.js +5 -13
- package/lib-esm/pushNotifications/utils/tokenManager.js +3 -3
- package/lib-esm/tsconfig.tsbuildinfo +1 -0
- package/package.json +63 -30
- package/src/inAppMessaging/index.ts +12 -0
- package/src/inAppMessaging/providers/pinpoint/apis/clearMessages.ts +26 -0
- package/src/inAppMessaging/providers/pinpoint/apis/index.ts +1 -0
- package/src/inAppMessaging/providers/pinpoint/index.ts +1 -0
- package/src/inAppMessaging/providers/pinpoint/utils/helpers.ts +38 -28
- package/src/inAppMessaging/providers/pinpoint/utils/messageProcessingHelpers.ts +25 -9
- package/src/inAppMessaging/providers/pinpoint/utils/resolveConfig.ts +1 -1
- package/src/pushNotifications/index.ts +1 -0
- package/src/pushNotifications/providers/pinpoint/apis/getBadgeCount.ts +1 -1
- package/src/pushNotifications/providers/pinpoint/apis/getLaunchNotification.native.ts +1 -1
- package/src/pushNotifications/providers/pinpoint/apis/getLaunchNotification.ts +1 -1
- package/src/pushNotifications/providers/pinpoint/apis/getPermissionStatus.native.ts +1 -1
- package/src/pushNotifications/providers/pinpoint/apis/getPermissionStatus.ts +1 -1
- package/src/pushNotifications/providers/pinpoint/apis/identifyUser.native.ts +5 -2
- package/src/pushNotifications/providers/pinpoint/apis/identifyUser.ts +1 -1
- package/src/pushNotifications/providers/pinpoint/apis/initializePushNotifications.native.ts +51 -41
- package/src/pushNotifications/providers/pinpoint/apis/requestPermissions.native.ts +1 -1
- package/src/pushNotifications/providers/pinpoint/apis/requestPermissions.ts +1 -1
- package/src/pushNotifications/providers/pinpoint/index.ts +1 -0
- package/src/pushNotifications/providers/pinpoint/utils/createMessageEventRecorder.ts +5 -4
- package/src/pushNotifications/providers/pinpoint/utils/getAnalyticsEvent.ts +7 -4
- package/src/pushNotifications/providers/pinpoint/utils/getChannelType.ts +1 -1
- package/src/pushNotifications/providers/pinpoint/utils/index.ts +2 -1
- package/src/pushNotifications/{utils → providers/pinpoint/utils}/resolveConfig.ts +2 -2
- package/src/pushNotifications/types/index.ts +1 -0
- package/src/pushNotifications/types/inputs.ts +1 -1
- package/src/pushNotifications/types/module.ts +42 -0
- package/src/pushNotifications/types/outputs.ts +1 -1
- package/src/pushNotifications/types/pushNotifications.ts +2 -7
- package/src/pushNotifications/utils/index.ts +1 -1
- package/lib/inAppMessaging/providers/index.d.ts +0 -2
- package/lib/inAppMessaging/providers/index.js +0 -15
- package/lib/pushNotifications/Platform/index.d.ts +0 -2
- package/lib/pushNotifications/Platform/index.js +0 -25
- package/lib/pushNotifications/Platform/index.native.d.ts +0 -2
- package/lib/pushNotifications/Platform/index.native.js +0 -7
- package/lib/pushNotifications/Platform/types.d.ts +0 -5
- package/lib/pushNotifications/providers/pinpoint/utils/getPushNotificationUserAgentString.js +0 -11
- package/lib/pushNotifications/utils/resolveConfig.js +0 -16
- package/lib/tsconfig.build.tsbuildinfo +0 -8667
- package/lib-esm/inAppMessaging/providers/index.d.ts +0 -2
- package/lib-esm/inAppMessaging/providers/index.js +0 -3
- package/lib-esm/pushNotifications/Platform/index.d.ts +0 -2
- package/lib-esm/pushNotifications/Platform/index.js +0 -23
- package/lib-esm/pushNotifications/Platform/index.native.d.ts +0 -2
- package/lib-esm/pushNotifications/Platform/index.native.js +0 -5
- package/lib-esm/pushNotifications/Platform/types.d.ts +0 -5
- package/lib-esm/tsconfig.build.tsbuildinfo +0 -7115
- package/src/inAppMessaging/providers/index.ts +0 -38
- package/src/pushNotifications/Platform/index.native.ts +0 -9
- package/src/pushNotifications/Platform/index.ts +0 -22
- package/src/pushNotifications/Platform/types.ts +0 -15
- /package/lib/pushNotifications/{utils → providers/pinpoint/utils}/resolveConfig.d.ts +0 -0
- /package/lib/pushNotifications/{Platform/types.js → types/module.js} +0 -0
- /package/lib/pushNotifications/{providers/pinpoint/utils → utils}/getPushNotificationUserAgentString.d.ts +0 -0
- /package/lib-esm/pushNotifications/{utils → providers/pinpoint/utils}/resolveConfig.d.ts +0 -0
- /package/lib-esm/pushNotifications/{providers/pinpoint/utils → utils}/getPushNotificationUserAgentString.d.ts +0 -0
- /package/src/pushNotifications/{providers/pinpoint/utils → utils}/getPushNotificationUserAgentString.ts +0 -0
|
@@ -22,9 +22,9 @@ import { getInAppMessagingUserAgentString } from './userAgent';
|
|
|
22
22
|
|
|
23
23
|
const DELIVERY_TYPE = 'IN_APP_MESSAGE';
|
|
24
24
|
|
|
25
|
-
let eventNameMemo = {};
|
|
26
|
-
let eventAttributesMemo = {};
|
|
27
|
-
let eventMetricsMemo = {};
|
|
25
|
+
let eventNameMemo: Record<string, boolean> = {};
|
|
26
|
+
let eventAttributesMemo: Record<string, boolean> = {};
|
|
27
|
+
let eventMetricsMemo: Record<string, boolean> = {};
|
|
28
28
|
|
|
29
29
|
export const logger = new ConsoleLogger('InAppMessaging.Pinpoint.Utils');
|
|
30
30
|
|
|
@@ -44,7 +44,8 @@ export const recordAnalyticsEvent = (
|
|
|
44
44
|
event: {
|
|
45
45
|
name: event,
|
|
46
46
|
attributes: {
|
|
47
|
-
campaign_id
|
|
47
|
+
// only include campaign_id field if we have one
|
|
48
|
+
...(id && { campaign_id: id }),
|
|
48
49
|
delivery_type: DELIVERY_TYPE,
|
|
49
50
|
treatment_id: metadata?.treatmentId,
|
|
50
51
|
},
|
|
@@ -52,7 +53,7 @@ export const recordAnalyticsEvent = (
|
|
|
52
53
|
identityId,
|
|
53
54
|
region,
|
|
54
55
|
userAgentValue: getInAppMessagingUserAgentString(
|
|
55
|
-
InAppMessagingAction.
|
|
56
|
+
InAppMessagingAction.NotifyMessageInteraction
|
|
56
57
|
),
|
|
57
58
|
});
|
|
58
59
|
})
|
|
@@ -72,19 +73,19 @@ export const matchesEventType = (
|
|
|
72
73
|
{ CampaignId, Schedule }: PinpointInAppMessage,
|
|
73
74
|
{ name: eventType }: InAppMessagingEvent
|
|
74
75
|
) => {
|
|
75
|
-
const { EventType } = Schedule?.EventFilter?.Dimensions;
|
|
76
|
+
const { EventType } = Schedule?.EventFilter?.Dimensions ?? {};
|
|
76
77
|
const memoKey = `${CampaignId}:${eventType}`;
|
|
77
78
|
if (!eventNameMemo.hasOwnProperty(memoKey)) {
|
|
78
|
-
eventNameMemo[memoKey] = !!EventType?.Values
|
|
79
|
+
eventNameMemo[memoKey] = !!EventType?.Values?.includes(eventType);
|
|
79
80
|
}
|
|
80
81
|
return eventNameMemo[memoKey];
|
|
81
82
|
};
|
|
82
83
|
|
|
83
84
|
export const matchesAttributes = (
|
|
84
85
|
{ CampaignId, Schedule }: PinpointInAppMessage,
|
|
85
|
-
{ attributes }: InAppMessagingEvent
|
|
86
|
+
{ attributes = {} }: InAppMessagingEvent
|
|
86
87
|
): boolean => {
|
|
87
|
-
const { Attributes } = Schedule?.EventFilter?.Dimensions;
|
|
88
|
+
const { Attributes } = Schedule?.EventFilter?.Dimensions ?? {};
|
|
88
89
|
if (isEmpty(Attributes)) {
|
|
89
90
|
// if message does not have attributes defined it does not matter what attributes are on the event
|
|
90
91
|
return true;
|
|
@@ -95,18 +96,20 @@ export const matchesAttributes = (
|
|
|
95
96
|
}
|
|
96
97
|
const memoKey = `${CampaignId}:${JSON.stringify(attributes)}`;
|
|
97
98
|
if (!eventAttributesMemo.hasOwnProperty(memoKey)) {
|
|
98
|
-
eventAttributesMemo[memoKey] =
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
eventAttributesMemo[memoKey] =
|
|
100
|
+
!Attributes ||
|
|
101
|
+
Object.entries(Attributes).every(([key, { Values }]) =>
|
|
102
|
+
Values?.includes(attributes[key])
|
|
103
|
+
);
|
|
101
104
|
}
|
|
102
105
|
return eventAttributesMemo[memoKey];
|
|
103
106
|
};
|
|
104
107
|
|
|
105
108
|
export const matchesMetrics = (
|
|
106
109
|
{ CampaignId, Schedule }: PinpointInAppMessage,
|
|
107
|
-
{ metrics }: InAppMessagingEvent
|
|
110
|
+
{ metrics = {} }: InAppMessagingEvent
|
|
108
111
|
): boolean => {
|
|
109
|
-
const { Metrics } = Schedule?.EventFilter?.Dimensions;
|
|
112
|
+
const { Metrics } = Schedule?.EventFilter?.Dimensions ?? {};
|
|
110
113
|
if (isEmpty(Metrics)) {
|
|
111
114
|
// if message does not have metrics defined it does not matter what metrics are on the event
|
|
112
115
|
return true;
|
|
@@ -117,18 +120,20 @@ export const matchesMetrics = (
|
|
|
117
120
|
}
|
|
118
121
|
const memoKey = `${CampaignId}:${JSON.stringify(metrics)}`;
|
|
119
122
|
if (!eventMetricsMemo.hasOwnProperty(memoKey)) {
|
|
120
|
-
eventMetricsMemo[memoKey] =
|
|
121
|
-
|
|
123
|
+
eventMetricsMemo[memoKey] =
|
|
124
|
+
!Metrics ||
|
|
125
|
+
Object.entries(Metrics).every(([key, { ComparisonOperator, Value }]) => {
|
|
122
126
|
const compare = getComparator(ComparisonOperator);
|
|
123
127
|
// if there is some unknown comparison operator, treat as a comparison failure
|
|
124
|
-
return compare ? compare(Value, metrics[key]) : false;
|
|
125
|
-
}
|
|
126
|
-
);
|
|
128
|
+
return compare && !!Value ? compare(Value, metrics[key]) : false;
|
|
129
|
+
});
|
|
127
130
|
}
|
|
128
131
|
return eventMetricsMemo[memoKey];
|
|
129
132
|
};
|
|
130
133
|
|
|
131
|
-
export const getComparator = (
|
|
134
|
+
export const getComparator = (
|
|
135
|
+
operator?: string
|
|
136
|
+
): MetricsComparator | undefined => {
|
|
132
137
|
switch (operator) {
|
|
133
138
|
case 'EQUAL':
|
|
134
139
|
return (metricsVal, eventVal) => metricsVal === eventVal;
|
|
@@ -141,7 +146,7 @@ export const getComparator = (operator: string): MetricsComparator => {
|
|
|
141
146
|
case 'LESS_THAN_OR_EQUAL':
|
|
142
147
|
return (metricsVal, eventVal) => metricsVal >= eventVal;
|
|
143
148
|
default:
|
|
144
|
-
return
|
|
149
|
+
return undefined;
|
|
145
150
|
}
|
|
146
151
|
};
|
|
147
152
|
|
|
@@ -218,8 +223,9 @@ export const clearMemo = () => {
|
|
|
218
223
|
// - 1. the usage of MOBILE_FEED and OVERLAYS as values for message layouts are not leaked
|
|
219
224
|
// outside the Pinpoint provider
|
|
220
225
|
// - 2. Amplify correctly handles the legacy layout values from Pinpoint after they are updated
|
|
226
|
+
|
|
221
227
|
export const interpretLayout = (
|
|
222
|
-
layout: PinpointInAppMessage['InAppMessage']['Layout']
|
|
228
|
+
layout: NonNullable<PinpointInAppMessage['InAppMessage']>['Layout']
|
|
223
229
|
): InAppMessageLayout => {
|
|
224
230
|
if (layout === 'MOBILE_FEED') {
|
|
225
231
|
return 'MODAL';
|
|
@@ -258,21 +264,23 @@ export const extractContent = ({
|
|
|
258
264
|
}
|
|
259
265
|
if (HeaderConfig) {
|
|
260
266
|
extractedContent.header = {
|
|
261
|
-
|
|
267
|
+
// Default to empty string in rare cases we don't have a Header value
|
|
268
|
+
content: HeaderConfig.Header ?? '',
|
|
262
269
|
style: {
|
|
263
270
|
color: HeaderConfig.TextColor,
|
|
264
271
|
textAlign:
|
|
265
|
-
HeaderConfig.Alignment
|
|
272
|
+
HeaderConfig.Alignment?.toLowerCase() as InAppMessageTextAlign,
|
|
266
273
|
},
|
|
267
274
|
};
|
|
268
275
|
}
|
|
269
276
|
if (BodyConfig) {
|
|
270
277
|
extractedContent.body = {
|
|
271
|
-
|
|
278
|
+
// Default to empty string in rare cases we don't have a Body value
|
|
279
|
+
content: BodyConfig.Body ?? '',
|
|
272
280
|
style: {
|
|
273
281
|
color: BodyConfig.TextColor,
|
|
274
282
|
textAlign:
|
|
275
|
-
BodyConfig.Alignment
|
|
283
|
+
BodyConfig.Alignment?.toLowerCase() as InAppMessageTextAlign,
|
|
276
284
|
},
|
|
277
285
|
};
|
|
278
286
|
}
|
|
@@ -283,7 +291,8 @@ export const extractContent = ({
|
|
|
283
291
|
}
|
|
284
292
|
if (defaultPrimaryButton) {
|
|
285
293
|
extractedContent.primaryButton = {
|
|
286
|
-
|
|
294
|
+
// Default to empty string in rare cases we don't have a Text value
|
|
295
|
+
title: defaultPrimaryButton.Text ?? '',
|
|
287
296
|
action: defaultPrimaryButton.ButtonAction as InAppMessageAction,
|
|
288
297
|
url: defaultPrimaryButton.Link,
|
|
289
298
|
style: {
|
|
@@ -295,7 +304,8 @@ export const extractContent = ({
|
|
|
295
304
|
}
|
|
296
305
|
if (defaultSecondaryButton) {
|
|
297
306
|
extractedContent.secondaryButton = {
|
|
298
|
-
|
|
307
|
+
// Default to empty string in rare cases we don't have a Text value
|
|
308
|
+
title: defaultSecondaryButton.Text ?? '',
|
|
299
309
|
action: defaultSecondaryButton.ButtonAction as InAppMessageAction,
|
|
300
310
|
url: defaultSecondaryButton.Link,
|
|
301
311
|
style: {
|
|
@@ -30,7 +30,7 @@ export async function processInAppMessages(
|
|
|
30
30
|
messages: PinpointInAppMessage[],
|
|
31
31
|
event: InAppMessagingEvent
|
|
32
32
|
): Promise<InAppMessage[]> {
|
|
33
|
-
let highestPrioritySeen: number;
|
|
33
|
+
let highestPrioritySeen: number | undefined;
|
|
34
34
|
let acc: PinpointInAppMessage[] = [];
|
|
35
35
|
for (let index = 0; index < messages.length; index++) {
|
|
36
36
|
const message = messages[index];
|
|
@@ -88,9 +88,13 @@ function normalizeMessages(messages: PinpointInAppMessage[]): InAppMessage[] {
|
|
|
88
88
|
return messages.map(message => {
|
|
89
89
|
const { CampaignId, InAppMessage } = message;
|
|
90
90
|
return {
|
|
91
|
-
|
|
91
|
+
// Default to empty string in rare cases we don't have a campaignId
|
|
92
|
+
id: CampaignId ?? '',
|
|
92
93
|
content: extractContent(message),
|
|
93
|
-
layout
|
|
94
|
+
// Default to TOP_BANNER layout in rare cases we don't have a Layout
|
|
95
|
+
layout: InAppMessage?.Layout
|
|
96
|
+
? interpretLayout(InAppMessage.Layout)
|
|
97
|
+
: 'TOP_BANNER',
|
|
94
98
|
metadata: extractMetadata(message),
|
|
95
99
|
};
|
|
96
100
|
});
|
|
@@ -114,16 +118,28 @@ async function isBelowCap({
|
|
|
114
118
|
}
|
|
115
119
|
|
|
116
120
|
async function getMessageCounts(
|
|
117
|
-
messageId
|
|
121
|
+
messageId?: string
|
|
118
122
|
): Promise<InAppMessageCounts> {
|
|
123
|
+
let messageCounts = {
|
|
124
|
+
sessionCount: 0,
|
|
125
|
+
dailyCount: 0,
|
|
126
|
+
totalCount: 0,
|
|
127
|
+
};
|
|
119
128
|
try {
|
|
120
|
-
return
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
129
|
+
// only return true counts if there is a messageId else default to 0
|
|
130
|
+
if (messageId)
|
|
131
|
+
messageCounts = {
|
|
132
|
+
sessionCount: getSessionCount(messageId),
|
|
133
|
+
dailyCount: await getDailyCount(),
|
|
134
|
+
totalCount: await getTotalCount(messageId),
|
|
135
|
+
};
|
|
136
|
+
return messageCounts;
|
|
125
137
|
} catch (err) {
|
|
126
138
|
logger.error('Failed to get message counts from storage', err);
|
|
139
|
+
|
|
140
|
+
// If there are no cached counts or there is an error,
|
|
141
|
+
// we default to 0 allowing all the messages to be eligible
|
|
142
|
+
return messageCounts;
|
|
127
143
|
}
|
|
128
144
|
}
|
|
129
145
|
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
*/
|
|
13
13
|
export const resolveConfig = () => {
|
|
14
14
|
const { appId, region } =
|
|
15
|
-
Amplify.getConfig().Notifications?.InAppMessaging
|
|
15
|
+
Amplify.getConfig().Notifications?.InAppMessaging?.Pinpoint ?? {};
|
|
16
16
|
assertValidationError(!!appId, InAppMessagingValidationErrorCode.NoAppId);
|
|
17
17
|
assertValidationError(!!region, InAppMessagingValidationErrorCode.NoRegion);
|
|
18
18
|
return { appId, region };
|
|
@@ -16,6 +16,6 @@ import { GetBadgeCount } from '../types';
|
|
|
16
16
|
* const badgeCount = await getBadgeCount();
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
export const getBadgeCount: GetBadgeCount = () => {
|
|
19
|
+
export const getBadgeCount: GetBadgeCount = async () => {
|
|
20
20
|
throw new PlatformNotSupportedError();
|
|
21
21
|
};
|
|
@@ -8,7 +8,7 @@ import { GetLaunchNotification } from '../types';
|
|
|
8
8
|
const { getLaunchNotification: getLaunchNotificationNative } =
|
|
9
9
|
loadAmplifyPushNotification();
|
|
10
10
|
|
|
11
|
-
export const getLaunchNotification: GetLaunchNotification = () => {
|
|
11
|
+
export const getLaunchNotification: GetLaunchNotification = async () => {
|
|
12
12
|
assertIsInitialized();
|
|
13
13
|
return getLaunchNotificationNative();
|
|
14
14
|
};
|
|
@@ -21,6 +21,6 @@ import { GetLaunchNotification, GetLaunchNotificationOutput } from '../types';
|
|
|
21
21
|
* const launchNotification = await getLaunchNotification();
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
|
-
export const getLaunchNotification: GetLaunchNotification = () => {
|
|
24
|
+
export const getLaunchNotification: GetLaunchNotification = async () => {
|
|
25
25
|
throw new PlatformNotSupportedError();
|
|
26
26
|
};
|
|
@@ -8,7 +8,7 @@ import { GetPermissionStatus } from '../types';
|
|
|
8
8
|
const { getPermissionStatus: getPermissionStatusNative } =
|
|
9
9
|
loadAmplifyPushNotification();
|
|
10
10
|
|
|
11
|
-
export const getPermissionStatus: GetPermissionStatus = () => {
|
|
11
|
+
export const getPermissionStatus: GetPermissionStatus = async () => {
|
|
12
12
|
assertIsInitialized();
|
|
13
13
|
return getPermissionStatusNative();
|
|
14
14
|
};
|
|
@@ -29,6 +29,6 @@ import { GetPermissionStatus, GetPermissionStatusOutput } from '../types';
|
|
|
29
29
|
* ```ts
|
|
30
30
|
* const permissionStatus = await getPermissionStatus();
|
|
31
31
|
*/
|
|
32
|
-
export const getPermissionStatus: GetPermissionStatus = () => {
|
|
32
|
+
export const getPermissionStatus: GetPermissionStatus = async () => {
|
|
33
33
|
throw new PlatformNotSupportedError();
|
|
34
34
|
};
|
|
@@ -4,8 +4,11 @@
|
|
|
4
4
|
import { PushNotificationAction } from '@aws-amplify/core/internals/utils';
|
|
5
5
|
import { updateEndpoint } from '@aws-amplify/core/internals/providers/pinpoint';
|
|
6
6
|
import { assertIsInitialized } from '../../../errors/errorHelpers';
|
|
7
|
-
import {
|
|
8
|
-
|
|
7
|
+
import {
|
|
8
|
+
getPushNotificationUserAgentString,
|
|
9
|
+
resolveCredentials,
|
|
10
|
+
} from '../../../utils';
|
|
11
|
+
import { getChannelType, resolveConfig } from '../utils';
|
|
9
12
|
import { IdentifyUser } from '../types';
|
|
10
13
|
|
|
11
14
|
export const identifyUser: IdentifyUser = async ({
|
|
@@ -12,17 +12,17 @@ import {
|
|
|
12
12
|
notifyEventListenersAndAwaitHandlers,
|
|
13
13
|
} from '../../../../eventListeners';
|
|
14
14
|
import {
|
|
15
|
+
getPushNotificationUserAgentString,
|
|
15
16
|
getToken,
|
|
16
17
|
initialize,
|
|
17
18
|
isInitialized,
|
|
18
|
-
resolveConfig,
|
|
19
19
|
resolveCredentials,
|
|
20
20
|
setToken,
|
|
21
21
|
} from '../../../utils';
|
|
22
22
|
import {
|
|
23
23
|
createMessageEventRecorder,
|
|
24
24
|
getChannelType,
|
|
25
|
-
|
|
25
|
+
resolveConfig,
|
|
26
26
|
} from '../utils';
|
|
27
27
|
|
|
28
28
|
const {
|
|
@@ -37,7 +37,7 @@ const logger = new ConsoleLogger('Notifications.PushNotification');
|
|
|
37
37
|
|
|
38
38
|
const BACKGROUND_TASK_TIMEOUT = 25; // seconds
|
|
39
39
|
|
|
40
|
-
export const initializePushNotifications = ():
|
|
40
|
+
export const initializePushNotifications = (): void => {
|
|
41
41
|
if (isInitialized()) {
|
|
42
42
|
logger.info('Push notifications have already been enabled');
|
|
43
43
|
return;
|
|
@@ -47,37 +47,10 @@ export const initializePushNotifications = (): Promise<void> => {
|
|
|
47
47
|
initialize();
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
const addAnalyticsListeners = (): void => {
|
|
51
|
-
let launchNotificationOpenedListenerRemover: EventListenerRemover;
|
|
52
|
-
|
|
53
|
-
// wire up default Pinpoint message event handling
|
|
54
|
-
addEventListener(
|
|
55
|
-
'backgroundMessageReceived',
|
|
56
|
-
createMessageEventRecorder('backgroundMessageReceived')
|
|
57
|
-
);
|
|
58
|
-
addEventListener(
|
|
59
|
-
'foregroundMessageReceived',
|
|
60
|
-
createMessageEventRecorder('foregroundMessageReceived')
|
|
61
|
-
);
|
|
62
|
-
launchNotificationOpenedListenerRemover = addEventListener(
|
|
63
|
-
'launchNotificationsOpened',
|
|
64
|
-
createMessageEventRecorder(
|
|
65
|
-
'notificationOpened',
|
|
66
|
-
// once we are done with it we can remove the listener
|
|
67
|
-
launchNotificationOpenedListenerRemover?.remove
|
|
68
|
-
)
|
|
69
|
-
);
|
|
70
|
-
addEventListener(
|
|
71
|
-
'notificationOpened',
|
|
72
|
-
createMessageEventRecorder(
|
|
73
|
-
'notificationOpened',
|
|
74
|
-
// if we are in this state, we no longer need the listener as the app was launched via some other means
|
|
75
|
-
launchNotificationOpenedListenerRemover?.remove
|
|
76
|
-
)
|
|
77
|
-
);
|
|
78
|
-
};
|
|
79
|
-
|
|
80
50
|
const addNativeListeners = (): void => {
|
|
51
|
+
let launchNotificationOpenedListener: ReturnType<
|
|
52
|
+
typeof addMessageEventListener
|
|
53
|
+
> | null;
|
|
81
54
|
const { NativeEvent, NativeHeadlessTaskKey } = getConstants();
|
|
82
55
|
const {
|
|
83
56
|
BACKGROUND_MESSAGE_RECEIVED,
|
|
@@ -126,7 +99,9 @@ const addNativeListeners = (): void => {
|
|
|
126
99
|
logger.error(err);
|
|
127
100
|
} finally {
|
|
128
101
|
// notify native module that handlers have completed their work (or timed out)
|
|
129
|
-
|
|
102
|
+
if (completionHandlerId) {
|
|
103
|
+
completeNotification(completionHandlerId);
|
|
104
|
+
}
|
|
130
105
|
}
|
|
131
106
|
}
|
|
132
107
|
);
|
|
@@ -140,14 +115,14 @@ const addNativeListeners = (): void => {
|
|
|
140
115
|
}
|
|
141
116
|
);
|
|
142
117
|
|
|
143
|
-
|
|
118
|
+
launchNotificationOpenedListener = LAUNCH_NOTIFICATION_OPENED
|
|
144
119
|
? addMessageEventListener(
|
|
145
120
|
// listen for native notification opened app (user tapped on notification, opening the app from quit -
|
|
146
121
|
// not background - state) event. This is broadcasted to an internal listener only as it is not intended
|
|
147
122
|
// for use otherwise as it produces inconsistent results when used within React Native app context
|
|
148
123
|
LAUNCH_NOTIFICATION_OPENED,
|
|
149
124
|
message => {
|
|
150
|
-
notifyEventListeners('
|
|
125
|
+
notifyEventListeners('launchNotificationOpened', message);
|
|
151
126
|
// once we are done with it we can remove the listener
|
|
152
127
|
launchNotificationOpenedListener?.remove();
|
|
153
128
|
}
|
|
@@ -169,23 +144,58 @@ const addNativeListeners = (): void => {
|
|
|
169
144
|
// listen for native new token event, automatically re-register device with provider using new token and
|
|
170
145
|
// broadcast to library listeners
|
|
171
146
|
TOKEN_RECEIVED,
|
|
172
|
-
token => {
|
|
147
|
+
async token => {
|
|
173
148
|
// avoid a race condition where two endpoints are created with the same token on a fresh install
|
|
174
149
|
if (getToken() === token) {
|
|
175
150
|
return;
|
|
176
151
|
}
|
|
177
152
|
setToken(token);
|
|
178
|
-
registerDevice();
|
|
179
153
|
notifyEventListeners('tokenReceived', token);
|
|
154
|
+
try {
|
|
155
|
+
await registerDevice(token);
|
|
156
|
+
} catch (err) {
|
|
157
|
+
logger.error('Failed to register device for push notifications', err);
|
|
158
|
+
throw err;
|
|
159
|
+
}
|
|
180
160
|
}
|
|
181
161
|
);
|
|
182
162
|
};
|
|
183
163
|
|
|
184
|
-
const
|
|
164
|
+
const addAnalyticsListeners = (): void => {
|
|
165
|
+
let launchNotificationOpenedListenerRemover: EventListenerRemover | undefined;
|
|
166
|
+
|
|
167
|
+
// wire up default Pinpoint message event handling
|
|
168
|
+
addEventListener(
|
|
169
|
+
'backgroundMessageReceived',
|
|
170
|
+
createMessageEventRecorder('received_background')
|
|
171
|
+
);
|
|
172
|
+
addEventListener(
|
|
173
|
+
'foregroundMessageReceived',
|
|
174
|
+
createMessageEventRecorder('received_foreground')
|
|
175
|
+
);
|
|
176
|
+
launchNotificationOpenedListenerRemover = addEventListener(
|
|
177
|
+
'launchNotificationOpened',
|
|
178
|
+
createMessageEventRecorder(
|
|
179
|
+
'opened_notification',
|
|
180
|
+
// once we are done with it we can remove the listener
|
|
181
|
+
launchNotificationOpenedListenerRemover?.remove
|
|
182
|
+
)
|
|
183
|
+
);
|
|
184
|
+
addEventListener(
|
|
185
|
+
'notificationOpened',
|
|
186
|
+
createMessageEventRecorder(
|
|
187
|
+
'opened_notification',
|
|
188
|
+
// if we are in this state, we no longer need the listener as the app was launched via some other means
|
|
189
|
+
launchNotificationOpenedListenerRemover?.remove
|
|
190
|
+
)
|
|
191
|
+
);
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const registerDevice = async (address: string): Promise<void> => {
|
|
185
195
|
const { credentials, identityId } = await resolveCredentials();
|
|
186
196
|
const { appId, region } = resolveConfig();
|
|
187
|
-
|
|
188
|
-
address
|
|
197
|
+
await updateEndpoint({
|
|
198
|
+
address,
|
|
189
199
|
appId,
|
|
190
200
|
category: 'PushNotification',
|
|
191
201
|
credentials,
|
|
@@ -8,7 +8,7 @@ import { RequestPermissions } from '../types';
|
|
|
8
8
|
const { requestPermissions: requestPermissionsNative } =
|
|
9
9
|
loadAmplifyPushNotification();
|
|
10
10
|
|
|
11
|
-
export const requestPermissions: RequestPermissions = input => {
|
|
11
|
+
export const requestPermissions: RequestPermissions = async input => {
|
|
12
12
|
assertIsInitialized();
|
|
13
13
|
return requestPermissionsNative(input);
|
|
14
14
|
};
|
|
@@ -4,14 +4,15 @@
|
|
|
4
4
|
import { record } from '@aws-amplify/core/internals/providers/pinpoint';
|
|
5
5
|
import { ConsoleLogger } from '@aws-amplify/core';
|
|
6
6
|
import { AWSCredentials } from '@aws-amplify/core/internals/utils';
|
|
7
|
+
import { PinpointMessageEvent } from '../types';
|
|
7
8
|
import {
|
|
8
9
|
OnPushNotificationMessageHandler,
|
|
9
|
-
PushNotificationEvent,
|
|
10
10
|
PushNotificationMessage,
|
|
11
11
|
} from '../../../types';
|
|
12
|
+
import { resolveCredentials } from '../../../utils';
|
|
12
13
|
import { getAnalyticsEvent } from './getAnalyticsEvent';
|
|
13
14
|
import { getChannelType } from './getChannelType';
|
|
14
|
-
import { resolveConfig
|
|
15
|
+
import { resolveConfig } from './resolveConfig';
|
|
15
16
|
|
|
16
17
|
const logger = new ConsoleLogger('PushNotification.recordMessageEvent');
|
|
17
18
|
|
|
@@ -20,7 +21,7 @@ const logger = new ConsoleLogger('PushNotification.recordMessageEvent');
|
|
|
20
21
|
*/
|
|
21
22
|
export const createMessageEventRecorder =
|
|
22
23
|
(
|
|
23
|
-
event:
|
|
24
|
+
event: PinpointMessageEvent,
|
|
24
25
|
callback?: Function
|
|
25
26
|
): OnPushNotificationMessageHandler =>
|
|
26
27
|
async message => {
|
|
@@ -45,7 +46,7 @@ const recordMessageEvent = async ({
|
|
|
45
46
|
}: {
|
|
46
47
|
appId: string;
|
|
47
48
|
credentials: AWSCredentials;
|
|
48
|
-
event:
|
|
49
|
+
event: PinpointMessageEvent;
|
|
49
50
|
message: PushNotificationMessage;
|
|
50
51
|
region: string;
|
|
51
52
|
}): Promise<void> => {
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { PinpointAnalyticsEvent } from '@aws-amplify/core/internals/providers/pinpoint';
|
|
5
|
-
import { AnalyticsEventAttributes } from '../types';
|
|
6
|
-
import {
|
|
5
|
+
import { AnalyticsEventAttributes, PinpointMessageEvent } from '../types';
|
|
6
|
+
import { PushNotificationMessage } from '../../../types';
|
|
7
7
|
|
|
8
8
|
const ANDROID_CAMPAIGN_ACTIVITY_ID_KEY =
|
|
9
9
|
'pinpoint.campaign.campaign_activity_id';
|
|
@@ -15,7 +15,7 @@ const ANDROID_CAMPAIGN_TREATMENT_ID_KEY = 'pinpoint.campaign.treatment_id';
|
|
|
15
15
|
*/
|
|
16
16
|
export const getAnalyticsEvent = (
|
|
17
17
|
{ data }: PushNotificationMessage,
|
|
18
|
-
event:
|
|
18
|
+
event: PinpointMessageEvent
|
|
19
19
|
): PinpointAnalyticsEvent | null => {
|
|
20
20
|
if (!data) {
|
|
21
21
|
return null;
|
|
@@ -33,7 +33,10 @@ export const getAnalyticsEvent = (
|
|
|
33
33
|
|
|
34
34
|
const getAnalyticsEventAttributes = (
|
|
35
35
|
data: PushNotificationMessage['data']
|
|
36
|
-
): AnalyticsEventAttributes => {
|
|
36
|
+
): AnalyticsEventAttributes | undefined => {
|
|
37
|
+
if (!data) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
37
40
|
if (data.hasOwnProperty(ANDROID_CAMPAIGN_ID_KEY)) {
|
|
38
41
|
return {
|
|
39
42
|
source: '_campaign',
|
|
@@ -19,7 +19,7 @@ export const getChannelType = (): ChannelType => {
|
|
|
19
19
|
}
|
|
20
20
|
if (isIos) {
|
|
21
21
|
// If building in debug mode, use the APNs sandbox
|
|
22
|
-
return
|
|
22
|
+
return __DEV__ ? 'APNS_SANDBOX' : 'APNS';
|
|
23
23
|
}
|
|
24
24
|
throw new PlatformNotSupportedError();
|
|
25
25
|
};
|
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
export { createMessageEventRecorder } from './createMessageEventRecorder';
|
|
5
|
+
export { getAnalyticsEvent } from './getAnalyticsEvent';
|
|
5
6
|
export { getChannelType } from './getChannelType';
|
|
6
|
-
export {
|
|
7
|
+
export { resolveConfig } from './resolveConfig';
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { Amplify } from '@aws-amplify/core';
|
|
5
|
-
import { assert, PushNotificationValidationErrorCode } from '
|
|
5
|
+
import { assert, PushNotificationValidationErrorCode } from '../../../errors';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @internal
|
|
9
9
|
*/
|
|
10
10
|
export const resolveConfig = () => {
|
|
11
11
|
const { appId, region } =
|
|
12
|
-
Amplify.getConfig().Notifications?.PushNotification
|
|
12
|
+
Amplify.getConfig().Notifications?.PushNotification?.Pinpoint ?? {};
|
|
13
13
|
assert(!!appId, PushNotificationValidationErrorCode.NoAppId);
|
|
14
14
|
assert(!!region, PushNotificationValidationErrorCode.NoRegion);
|
|
15
15
|
return { appId, region };
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
import { UserProfile } from '@aws-amplify/core';
|
|
5
5
|
import { PushNotificationServiceOptions } from './options';
|
|
6
|
+
import { PushNotificationPermissions } from './module';
|
|
6
7
|
import {
|
|
7
8
|
OnPushNotificationMessageHandler,
|
|
8
9
|
OnTokenReceivedHandler,
|
|
9
|
-
PushNotificationPermissions,
|
|
10
10
|
} from './pushNotifications';
|
|
11
11
|
|
|
12
12
|
export type PushNotificationIdentifyUserInput<
|