@aws-amplify/notifications 2.0.1-api-v6-models.c1977f8.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
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.PushNotificationError = exports.setBadgeCount = exports.requestPermissions = exports.onTokenReceived = exports.onNotificationReceivedInForeground = exports.onNotificationReceivedInBackground = exports.onNotificationOpened = exports.initializePushNotifications = exports.identifyUser = exports.getPermissionStatus = exports.getLaunchNotification = exports.getBadgeCount = void 0;
|
|
5
6
|
var pinpoint_1 = require("./providers/pinpoint");
|
|
6
|
-
exports
|
|
7
|
-
exports
|
|
8
|
-
exports
|
|
9
|
-
exports
|
|
10
|
-
exports
|
|
11
|
-
exports
|
|
12
|
-
exports
|
|
13
|
-
exports
|
|
14
|
-
exports
|
|
15
|
-
exports
|
|
16
|
-
exports
|
|
7
|
+
Object.defineProperty(exports, "getBadgeCount", { enumerable: true, get: function () { return pinpoint_1.getBadgeCount; } });
|
|
8
|
+
Object.defineProperty(exports, "getLaunchNotification", { enumerable: true, get: function () { return pinpoint_1.getLaunchNotification; } });
|
|
9
|
+
Object.defineProperty(exports, "getPermissionStatus", { enumerable: true, get: function () { return pinpoint_1.getPermissionStatus; } });
|
|
10
|
+
Object.defineProperty(exports, "identifyUser", { enumerable: true, get: function () { return pinpoint_1.identifyUser; } });
|
|
11
|
+
Object.defineProperty(exports, "initializePushNotifications", { enumerable: true, get: function () { return pinpoint_1.initializePushNotifications; } });
|
|
12
|
+
Object.defineProperty(exports, "onNotificationOpened", { enumerable: true, get: function () { return pinpoint_1.onNotificationOpened; } });
|
|
13
|
+
Object.defineProperty(exports, "onNotificationReceivedInBackground", { enumerable: true, get: function () { return pinpoint_1.onNotificationReceivedInBackground; } });
|
|
14
|
+
Object.defineProperty(exports, "onNotificationReceivedInForeground", { enumerable: true, get: function () { return pinpoint_1.onNotificationReceivedInForeground; } });
|
|
15
|
+
Object.defineProperty(exports, "onTokenReceived", { enumerable: true, get: function () { return pinpoint_1.onTokenReceived; } });
|
|
16
|
+
Object.defineProperty(exports, "requestPermissions", { enumerable: true, get: function () { return pinpoint_1.requestPermissions; } });
|
|
17
|
+
Object.defineProperty(exports, "setBadgeCount", { enumerable: true, get: function () { return pinpoint_1.setBadgeCount; } });
|
|
17
18
|
var errors_1 = require("./errors");
|
|
18
|
-
exports
|
|
19
|
+
Object.defineProperty(exports, "PushNotificationError", { enumerable: true, get: function () { return errors_1.PushNotificationError; } });
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
|
|
5
|
+
exports.getBadgeCount = void 0;
|
|
6
|
+
const utils_1 = require("@aws-amplify/core/internals/utils");
|
|
6
7
|
/**
|
|
7
8
|
* Returns the current badge count (the number next to your app's icon). This function is safe to call (but will be
|
|
8
9
|
* ignored) even when your React Native app is running on platforms where badges are not supported.
|
|
@@ -15,6 +16,7 @@ var utils_1 = require("@aws-amplify/core/internals/utils");
|
|
|
15
16
|
* const badgeCount = await getBadgeCount();
|
|
16
17
|
* ```
|
|
17
18
|
*/
|
|
18
|
-
|
|
19
|
+
const getBadgeCount = async () => {
|
|
19
20
|
throw new utils_1.PlatformNotSupportedError();
|
|
20
21
|
};
|
|
22
|
+
exports.getBadgeCount = getBadgeCount;
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}); };
|
|
5
|
+
exports.getBadgeCount = void 0;
|
|
6
|
+
const react_native_1 = require("@aws-amplify/react-native");
|
|
7
|
+
const errorHelpers_1 = require("../../../errors/errorHelpers");
|
|
8
|
+
const { getBadgeCount: getBadgeCountNative } = (0, react_native_1.loadAmplifyPushNotification)();
|
|
9
|
+
const getBadgeCount = async () => {
|
|
10
|
+
(0, errorHelpers_1.assertIsInitialized)();
|
|
11
|
+
return getBadgeCountNative();
|
|
12
|
+
};
|
|
13
|
+
exports.getBadgeCount = getBadgeCount;
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
|
|
5
|
+
exports.getLaunchNotification = void 0;
|
|
6
|
+
const utils_1 = require("@aws-amplify/core/internals/utils");
|
|
6
7
|
/**
|
|
7
8
|
* Returns the notification which launched your app from a terminated state. The launch notification is consumed by
|
|
8
9
|
* calls to this function and will yield a null result if:
|
|
@@ -19,6 +20,7 @@ var utils_1 = require("@aws-amplify/core/internals/utils");
|
|
|
19
20
|
* const launchNotification = await getLaunchNotification();
|
|
20
21
|
* ```
|
|
21
22
|
*/
|
|
22
|
-
|
|
23
|
+
const getLaunchNotification = async () => {
|
|
23
24
|
throw new utils_1.PlatformNotSupportedError();
|
|
24
25
|
};
|
|
26
|
+
exports.getLaunchNotification = getLaunchNotification;
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
exports.getLaunchNotification = void 0;
|
|
6
|
+
const react_native_1 = require("@aws-amplify/react-native");
|
|
7
|
+
const errorHelpers_1 = require("../../../errors/errorHelpers");
|
|
8
|
+
const { getLaunchNotification: getLaunchNotificationNative } = (0, react_native_1.loadAmplifyPushNotification)();
|
|
9
|
+
const getLaunchNotification = async () => {
|
|
10
|
+
(0, errorHelpers_1.assertIsInitialized)();
|
|
10
11
|
return getLaunchNotificationNative();
|
|
11
12
|
};
|
|
13
|
+
exports.getLaunchNotification = getLaunchNotification;
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
|
|
5
|
+
exports.getPermissionStatus = void 0;
|
|
6
|
+
const utils_1 = require("@aws-amplify/core/internals/utils");
|
|
6
7
|
/**
|
|
7
8
|
* Returns a string representing the current status of user permissions to display push notifications. The possible
|
|
8
9
|
* statuses are as follows:
|
|
@@ -28,6 +29,7 @@ var utils_1 = require("@aws-amplify/core/internals/utils");
|
|
|
28
29
|
* ```ts
|
|
29
30
|
* const permissionStatus = await getPermissionStatus();
|
|
30
31
|
*/
|
|
31
|
-
|
|
32
|
+
const getPermissionStatus = async () => {
|
|
32
33
|
throw new utils_1.PlatformNotSupportedError();
|
|
33
34
|
};
|
|
35
|
+
exports.getPermissionStatus = getPermissionStatus;
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
exports.getPermissionStatus = void 0;
|
|
6
|
+
const react_native_1 = require("@aws-amplify/react-native");
|
|
7
|
+
const errorHelpers_1 = require("../../../errors/errorHelpers");
|
|
8
|
+
const { getPermissionStatus: getPermissionStatusNative } = (0, react_native_1.loadAmplifyPushNotification)();
|
|
9
|
+
const getPermissionStatus = async () => {
|
|
10
|
+
(0, errorHelpers_1.assertIsInitialized)();
|
|
10
11
|
return getPermissionStatusNative();
|
|
11
12
|
};
|
|
13
|
+
exports.getPermissionStatus = getPermissionStatus;
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
|
|
5
|
+
exports.identifyUser = void 0;
|
|
6
|
+
const utils_1 = require("@aws-amplify/core/internals/utils");
|
|
6
7
|
/**
|
|
7
8
|
* Sends information about a user to Pinpoint. Sending user information allows you to associate a user to their user
|
|
8
9
|
* profile and activities or actions in your application. Activity can be tracked across devices & platforms by using
|
|
@@ -54,6 +55,7 @@ var utils_1 = require("@aws-amplify/core/internals/utils");
|
|
|
54
55
|
* },
|
|
55
56
|
* });
|
|
56
57
|
*/
|
|
57
|
-
|
|
58
|
+
const identifyUser = async () => {
|
|
58
59
|
throw new utils_1.PlatformNotSupportedError();
|
|
59
60
|
};
|
|
61
|
+
exports.identifyUser = identifyUser;
|
|
@@ -2,41 +2,30 @@
|
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
category: 'PushNotification',
|
|
30
|
-
credentials: credentials,
|
|
31
|
-
identityId: identityId,
|
|
32
|
-
region: region,
|
|
33
|
-
userAttributes: userAttributes,
|
|
34
|
-
userId: userId,
|
|
35
|
-
userProfile: userProfile,
|
|
36
|
-
userAgentValue: utils_3.getPushNotificationUserAgentString(utils_1.PushNotificationAction.IdentifyUser),
|
|
37
|
-
});
|
|
38
|
-
return [2 /*return*/];
|
|
39
|
-
}
|
|
40
|
-
});
|
|
5
|
+
exports.identifyUser = void 0;
|
|
6
|
+
const utils_1 = require("@aws-amplify/core/internals/utils");
|
|
7
|
+
const pinpoint_1 = require("@aws-amplify/core/internals/providers/pinpoint");
|
|
8
|
+
const errorHelpers_1 = require("../../../errors/errorHelpers");
|
|
9
|
+
const utils_2 = require("../../../utils");
|
|
10
|
+
const utils_3 = require("../utils");
|
|
11
|
+
const identifyUser = async ({ userId, userProfile, options, }) => {
|
|
12
|
+
(0, errorHelpers_1.assertIsInitialized)();
|
|
13
|
+
const { credentials, identityId } = await (0, utils_2.resolveCredentials)();
|
|
14
|
+
const { appId, region } = (0, utils_3.resolveConfig)();
|
|
15
|
+
const { address, optOut, userAttributes } = options ?? {};
|
|
16
|
+
(0, pinpoint_1.updateEndpoint)({
|
|
17
|
+
address,
|
|
18
|
+
channelType: (0, utils_3.getChannelType)(),
|
|
19
|
+
optOut,
|
|
20
|
+
appId,
|
|
21
|
+
category: 'PushNotification',
|
|
22
|
+
credentials,
|
|
23
|
+
identityId,
|
|
24
|
+
region,
|
|
25
|
+
userAttributes,
|
|
26
|
+
userId,
|
|
27
|
+
userProfile,
|
|
28
|
+
userAgentValue: (0, utils_2.getPushNotificationUserAgentString)(utils_1.PushNotificationAction.IdentifyUser),
|
|
41
29
|
});
|
|
42
30
|
};
|
|
31
|
+
exports.identifyUser = identifyUser;
|
|
@@ -2,25 +2,26 @@
|
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.setBadgeCount = exports.requestPermissions = exports.onTokenReceived = exports.onNotificationReceivedInForeground = exports.onNotificationReceivedInBackground = exports.onNotificationOpened = exports.initializePushNotifications = exports.identifyUser = exports.getPermissionStatus = exports.getLaunchNotification = exports.getBadgeCount = void 0;
|
|
5
6
|
var getBadgeCount_1 = require("./getBadgeCount");
|
|
6
|
-
exports
|
|
7
|
+
Object.defineProperty(exports, "getBadgeCount", { enumerable: true, get: function () { return getBadgeCount_1.getBadgeCount; } });
|
|
7
8
|
var getLaunchNotification_1 = require("./getLaunchNotification");
|
|
8
|
-
exports
|
|
9
|
+
Object.defineProperty(exports, "getLaunchNotification", { enumerable: true, get: function () { return getLaunchNotification_1.getLaunchNotification; } });
|
|
9
10
|
var getPermissionStatus_1 = require("./getPermissionStatus");
|
|
10
|
-
exports
|
|
11
|
+
Object.defineProperty(exports, "getPermissionStatus", { enumerable: true, get: function () { return getPermissionStatus_1.getPermissionStatus; } });
|
|
11
12
|
var identifyUser_1 = require("./identifyUser");
|
|
12
|
-
exports
|
|
13
|
+
Object.defineProperty(exports, "identifyUser", { enumerable: true, get: function () { return identifyUser_1.identifyUser; } });
|
|
13
14
|
var initializePushNotifications_1 = require("./initializePushNotifications");
|
|
14
|
-
exports
|
|
15
|
+
Object.defineProperty(exports, "initializePushNotifications", { enumerable: true, get: function () { return initializePushNotifications_1.initializePushNotifications; } });
|
|
15
16
|
var onNotificationOpened_1 = require("./onNotificationOpened");
|
|
16
|
-
exports
|
|
17
|
+
Object.defineProperty(exports, "onNotificationOpened", { enumerable: true, get: function () { return onNotificationOpened_1.onNotificationOpened; } });
|
|
17
18
|
var onNotificationReceivedInBackground_1 = require("./onNotificationReceivedInBackground");
|
|
18
|
-
exports
|
|
19
|
+
Object.defineProperty(exports, "onNotificationReceivedInBackground", { enumerable: true, get: function () { return onNotificationReceivedInBackground_1.onNotificationReceivedInBackground; } });
|
|
19
20
|
var onNotificationReceivedInForeground_1 = require("./onNotificationReceivedInForeground");
|
|
20
|
-
exports
|
|
21
|
+
Object.defineProperty(exports, "onNotificationReceivedInForeground", { enumerable: true, get: function () { return onNotificationReceivedInForeground_1.onNotificationReceivedInForeground; } });
|
|
21
22
|
var onTokenReceived_1 = require("./onTokenReceived");
|
|
22
|
-
exports
|
|
23
|
+
Object.defineProperty(exports, "onTokenReceived", { enumerable: true, get: function () { return onTokenReceived_1.onTokenReceived; } });
|
|
23
24
|
var requestPermissions_1 = require("./requestPermissions");
|
|
24
|
-
exports
|
|
25
|
+
Object.defineProperty(exports, "requestPermissions", { enumerable: true, get: function () { return requestPermissions_1.requestPermissions; } });
|
|
25
26
|
var setBadgeCount_1 = require("./setBadgeCount");
|
|
26
|
-
exports
|
|
27
|
+
Object.defineProperty(exports, "setBadgeCount", { enumerable: true, get: function () { return setBadgeCount_1.setBadgeCount; } });
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
|
|
5
|
+
exports.initializePushNotifications = void 0;
|
|
6
|
+
const utils_1 = require("@aws-amplify/core/internals/utils");
|
|
6
7
|
/**
|
|
7
8
|
* Initialize and set up the push notification category. The category must be first initialized before all other
|
|
8
9
|
* functionalities become available.
|
|
@@ -18,6 +19,7 @@ var utils_1 = require("@aws-amplify/core/internals/utils");
|
|
|
18
19
|
* initializePushNotifications();
|
|
19
20
|
* ```
|
|
20
21
|
*/
|
|
21
|
-
|
|
22
|
+
const initializePushNotifications = () => {
|
|
22
23
|
throw new utils_1.PlatformNotSupportedError();
|
|
23
24
|
};
|
|
25
|
+
exports.initializePushNotifications = initializePushNotifications;
|
package/lib/pushNotifications/providers/pinpoint/apis/initializePushNotifications.native.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const initializePushNotifications: () =>
|
|
1
|
+
export declare const initializePushNotifications: () => void;
|
|
@@ -2,157 +2,132 @@
|
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (utils_2.isInitialized()) {
|
|
5
|
+
exports.initializePushNotifications = void 0;
|
|
6
|
+
const core_1 = require("@aws-amplify/core");
|
|
7
|
+
const utils_1 = require("@aws-amplify/core/internals/utils");
|
|
8
|
+
const pinpoint_1 = require("@aws-amplify/core/internals/providers/pinpoint");
|
|
9
|
+
const react_native_1 = require("@aws-amplify/react-native");
|
|
10
|
+
const eventListeners_1 = require("../../../../eventListeners");
|
|
11
|
+
const utils_2 = require("../../../utils");
|
|
12
|
+
const utils_3 = require("../utils");
|
|
13
|
+
const { addMessageEventListener, addTokenEventListener, completeNotification, getConstants, registerHeadlessTask, } = (0, react_native_1.loadAmplifyPushNotification)();
|
|
14
|
+
const logger = new core_1.ConsoleLogger('Notifications.PushNotification');
|
|
15
|
+
const BACKGROUND_TASK_TIMEOUT = 25; // seconds
|
|
16
|
+
const initializePushNotifications = () => {
|
|
17
|
+
if ((0, utils_2.isInitialized)()) {
|
|
18
18
|
logger.info('Push notifications have already been enabled');
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
21
|
addNativeListeners();
|
|
22
22
|
addAnalyticsListeners();
|
|
23
|
-
utils_2.initialize();
|
|
23
|
+
(0, utils_2.initialize)();
|
|
24
24
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
launchNotificationOpenedListenerRemover = eventListeners_1.addEventListener('launchNotificationsOpened', utils_3.createMessageEventRecorder('notificationOpened',
|
|
31
|
-
// once we are done with it we can remove the listener
|
|
32
|
-
launchNotificationOpenedListenerRemover === null ||
|
|
33
|
-
// once we are done with it we can remove the listener
|
|
34
|
-
launchNotificationOpenedListenerRemover === void 0 ? void 0 :
|
|
35
|
-
// once we are done with it we can remove the listener
|
|
36
|
-
launchNotificationOpenedListenerRemover.remove));
|
|
37
|
-
eventListeners_1.addEventListener('notificationOpened', utils_3.createMessageEventRecorder('notificationOpened',
|
|
38
|
-
// if we are in this state, we no longer need the listener as the app was launched via some other means
|
|
39
|
-
launchNotificationOpenedListenerRemover === null ||
|
|
40
|
-
// if we are in this state, we no longer need the listener as the app was launched via some other means
|
|
41
|
-
launchNotificationOpenedListenerRemover === void 0 ? void 0 :
|
|
42
|
-
// if we are in this state, we no longer need the listener as the app was launched via some other means
|
|
43
|
-
launchNotificationOpenedListenerRemover.remove));
|
|
44
|
-
};
|
|
45
|
-
var addNativeListeners = function () {
|
|
46
|
-
var _a = getConstants(), NativeEvent = _a.NativeEvent, NativeHeadlessTaskKey = _a.NativeHeadlessTaskKey;
|
|
47
|
-
var BACKGROUND_MESSAGE_RECEIVED = NativeEvent.BACKGROUND_MESSAGE_RECEIVED, FOREGROUND_MESSAGE_RECEIVED = NativeEvent.FOREGROUND_MESSAGE_RECEIVED, LAUNCH_NOTIFICATION_OPENED = NativeEvent.LAUNCH_NOTIFICATION_OPENED, NOTIFICATION_OPENED = NativeEvent.NOTIFICATION_OPENED, TOKEN_RECEIVED = NativeEvent.TOKEN_RECEIVED;
|
|
25
|
+
exports.initializePushNotifications = initializePushNotifications;
|
|
26
|
+
const addNativeListeners = () => {
|
|
27
|
+
let launchNotificationOpenedListener;
|
|
28
|
+
const { NativeEvent, NativeHeadlessTaskKey } = getConstants();
|
|
29
|
+
const { BACKGROUND_MESSAGE_RECEIVED, FOREGROUND_MESSAGE_RECEIVED, LAUNCH_NOTIFICATION_OPENED, NOTIFICATION_OPENED, TOKEN_RECEIVED, } = NativeEvent;
|
|
48
30
|
// on platforms that can handle headless tasks, register one to broadcast background message received to
|
|
49
31
|
// library listeners
|
|
50
32
|
if (NativeHeadlessTaskKey) {
|
|
51
|
-
registerHeadlessTask(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
// keep headless task running until handlers have completed their work
|
|
56
|
-
return [4 /*yield*/, eventListeners_1.notifyEventListenersAndAwaitHandlers('backgroundMessageReceived', message)];
|
|
57
|
-
case 1:
|
|
58
|
-
// keep headless task running until handlers have completed their work
|
|
59
|
-
_a.sent();
|
|
60
|
-
return [2 /*return*/];
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}); });
|
|
33
|
+
registerHeadlessTask(async (message) => {
|
|
34
|
+
// keep headless task running until handlers have completed their work
|
|
35
|
+
await (0, eventListeners_1.notifyEventListenersAndAwaitHandlers)('backgroundMessageReceived', message);
|
|
36
|
+
});
|
|
64
37
|
}
|
|
65
38
|
else if (BACKGROUND_MESSAGE_RECEIVED) {
|
|
66
39
|
// on platforms that can't handle headless tasks, listen for native background message received event and
|
|
67
40
|
// broadcast to library listeners
|
|
68
|
-
addMessageEventListener(BACKGROUND_MESSAGE_RECEIVED,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
case 2:
|
|
89
|
-
err_1 = _a.sent();
|
|
90
|
-
logger.error(err_1);
|
|
91
|
-
return [3 /*break*/, 4];
|
|
92
|
-
case 3:
|
|
93
|
-
// notify native module that handlers have completed their work (or timed out)
|
|
94
|
-
completeNotification(completionHandlerId);
|
|
95
|
-
return [7 /*endfinally*/];
|
|
96
|
-
case 4: return [2 /*return*/];
|
|
41
|
+
addMessageEventListener(BACKGROUND_MESSAGE_RECEIVED, async (message, completionHandlerId) => {
|
|
42
|
+
// keep background task running until handlers have completed their work
|
|
43
|
+
try {
|
|
44
|
+
await Promise.race([
|
|
45
|
+
(0, eventListeners_1.notifyEventListenersAndAwaitHandlers)('backgroundMessageReceived', message),
|
|
46
|
+
// background tasks will get suspended and all future tasks be deprioritized by the OS if they run for
|
|
47
|
+
// more than 30 seconds so we reject with a error in a shorter amount of time to prevent this from
|
|
48
|
+
// happening
|
|
49
|
+
new Promise((_, reject) => {
|
|
50
|
+
setTimeout(() => reject(`onNotificationReceivedInBackground handlers should complete their work within ${BACKGROUND_TASK_TIMEOUT} seconds, but they did not.`), BACKGROUND_TASK_TIMEOUT * 1000);
|
|
51
|
+
}),
|
|
52
|
+
]);
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
logger.error(err);
|
|
56
|
+
}
|
|
57
|
+
finally {
|
|
58
|
+
// notify native module that handlers have completed their work (or timed out)
|
|
59
|
+
if (completionHandlerId) {
|
|
60
|
+
completeNotification(completionHandlerId);
|
|
97
61
|
}
|
|
98
|
-
}
|
|
99
|
-
});
|
|
62
|
+
}
|
|
63
|
+
});
|
|
100
64
|
}
|
|
101
65
|
addMessageEventListener(
|
|
102
66
|
// listen for native foreground message received event and broadcast to library listeners
|
|
103
|
-
FOREGROUND_MESSAGE_RECEIVED,
|
|
104
|
-
eventListeners_1.notifyEventListeners('foregroundMessageReceived', message);
|
|
67
|
+
FOREGROUND_MESSAGE_RECEIVED, message => {
|
|
68
|
+
(0, eventListeners_1.notifyEventListeners)('foregroundMessageReceived', message);
|
|
105
69
|
});
|
|
106
|
-
|
|
70
|
+
launchNotificationOpenedListener = LAUNCH_NOTIFICATION_OPENED
|
|
107
71
|
? addMessageEventListener(
|
|
108
72
|
// listen for native notification opened app (user tapped on notification, opening the app from quit -
|
|
109
73
|
// not background - state) event. This is broadcasted to an internal listener only as it is not intended
|
|
110
74
|
// for use otherwise as it produces inconsistent results when used within React Native app context
|
|
111
|
-
LAUNCH_NOTIFICATION_OPENED,
|
|
112
|
-
eventListeners_1.notifyEventListeners('
|
|
75
|
+
LAUNCH_NOTIFICATION_OPENED, message => {
|
|
76
|
+
(0, eventListeners_1.notifyEventListeners)('launchNotificationOpened', message);
|
|
113
77
|
// once we are done with it we can remove the listener
|
|
114
|
-
launchNotificationOpenedListener
|
|
78
|
+
launchNotificationOpenedListener?.remove();
|
|
115
79
|
})
|
|
116
80
|
: null;
|
|
117
81
|
addMessageEventListener(
|
|
118
82
|
// listen for native notification opened (user tapped on notification, opening the app from background -
|
|
119
83
|
// not quit - state) event and broadcast to library listeners
|
|
120
|
-
NOTIFICATION_OPENED,
|
|
121
|
-
eventListeners_1.notifyEventListeners('notificationOpened', message);
|
|
84
|
+
NOTIFICATION_OPENED, message => {
|
|
85
|
+
(0, eventListeners_1.notifyEventListeners)('notificationOpened', message);
|
|
122
86
|
// if we are in this state, we no longer need the listener as the app was launched via some other means
|
|
123
|
-
launchNotificationOpenedListener
|
|
87
|
+
launchNotificationOpenedListener?.remove();
|
|
124
88
|
});
|
|
125
89
|
addTokenEventListener(
|
|
126
90
|
// listen for native new token event, automatically re-register device with provider using new token and
|
|
127
91
|
// broadcast to library listeners
|
|
128
|
-
TOKEN_RECEIVED,
|
|
92
|
+
TOKEN_RECEIVED, async (token) => {
|
|
129
93
|
// avoid a race condition where two endpoints are created with the same token on a fresh install
|
|
130
|
-
if (utils_2.getToken() === token) {
|
|
94
|
+
if ((0, utils_2.getToken)() === token) {
|
|
131
95
|
return;
|
|
132
96
|
}
|
|
133
|
-
utils_2.setToken(token);
|
|
134
|
-
|
|
135
|
-
|
|
97
|
+
(0, utils_2.setToken)(token);
|
|
98
|
+
(0, eventListeners_1.notifyEventListeners)('tokenReceived', token);
|
|
99
|
+
try {
|
|
100
|
+
await registerDevice(token);
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
logger.error('Failed to register device for push notifications', err);
|
|
104
|
+
throw err;
|
|
105
|
+
}
|
|
136
106
|
});
|
|
137
107
|
};
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
108
|
+
const addAnalyticsListeners = () => {
|
|
109
|
+
let launchNotificationOpenedListenerRemover;
|
|
110
|
+
// wire up default Pinpoint message event handling
|
|
111
|
+
(0, eventListeners_1.addEventListener)('backgroundMessageReceived', (0, utils_3.createMessageEventRecorder)('received_background'));
|
|
112
|
+
(0, eventListeners_1.addEventListener)('foregroundMessageReceived', (0, utils_3.createMessageEventRecorder)('received_foreground'));
|
|
113
|
+
launchNotificationOpenedListenerRemover = (0, eventListeners_1.addEventListener)('launchNotificationOpened', (0, utils_3.createMessageEventRecorder)('opened_notification',
|
|
114
|
+
// once we are done with it we can remove the listener
|
|
115
|
+
launchNotificationOpenedListenerRemover?.remove));
|
|
116
|
+
(0, eventListeners_1.addEventListener)('notificationOpened', (0, utils_3.createMessageEventRecorder)('opened_notification',
|
|
117
|
+
// if we are in this state, we no longer need the listener as the app was launched via some other means
|
|
118
|
+
launchNotificationOpenedListenerRemover?.remove));
|
|
119
|
+
};
|
|
120
|
+
const registerDevice = async (address) => {
|
|
121
|
+
const { credentials, identityId } = await (0, utils_2.resolveCredentials)();
|
|
122
|
+
const { appId, region } = (0, utils_3.resolveConfig)();
|
|
123
|
+
await (0, pinpoint_1.updateEndpoint)({
|
|
124
|
+
address,
|
|
125
|
+
appId,
|
|
126
|
+
category: 'PushNotification',
|
|
127
|
+
credentials,
|
|
128
|
+
region,
|
|
129
|
+
channelType: (0, utils_3.getChannelType)(),
|
|
130
|
+
identityId,
|
|
131
|
+
userAgentValue: (0, utils_2.getPushNotificationUserAgentString)(utils_1.PushNotificationAction.InitializePushNotifications),
|
|
157
132
|
});
|
|
158
|
-
}
|
|
133
|
+
};
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
|
|
5
|
+
exports.onNotificationOpened = void 0;
|
|
6
|
+
const utils_1 = require("@aws-amplify/core/internals/utils");
|
|
6
7
|
/**
|
|
7
8
|
* Registers a listener that will be triggered when a notification is opened by user.
|
|
8
9
|
*
|
|
@@ -28,6 +29,7 @@ var utils_1 = require("@aws-amplify/core/internals/utils");
|
|
|
28
29
|
* });
|
|
29
30
|
* ```
|
|
30
31
|
*/
|
|
31
|
-
|
|
32
|
+
const onNotificationOpened = () => {
|
|
32
33
|
throw new utils_1.PlatformNotSupportedError();
|
|
33
34
|
};
|
|
35
|
+
exports.onNotificationOpened = onNotificationOpened;
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
exports.onNotificationOpened = void 0;
|
|
6
|
+
const eventListeners_1 = require("../../../../eventListeners");
|
|
7
|
+
const errorHelpers_1 = require("../../../errors/errorHelpers");
|
|
8
|
+
const onNotificationOpened = input => {
|
|
9
|
+
(0, errorHelpers_1.assertIsInitialized)();
|
|
10
|
+
return (0, eventListeners_1.addEventListener)('notificationOpened', input);
|
|
10
11
|
};
|
|
12
|
+
exports.onNotificationOpened = onNotificationOpened;
|