1
1
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
// SPDX-License-Identifier: Apache-2.0
3
+
3
4
import {
4
5
Alignment ,
5
6
ButtonAction ,
6
7
DimensionType ,
8
+ Event ,
7
9
FilterType ,
8
10
InAppMessageCampaign as PinpointInAppMessage ,
9
11
} from '@aws-sdk/client-pinpoint' ;
10
- import {
11
- InAppMessage ,
12
- InAppMessagingEvent ,
13
- UserInfo ,
14
- } from '../src/InAppMessaging' ;
12
+ import { InAppMessage , InAppMessagingEvent } from '../src/InAppMessaging' ;
13
+ import { PushNotificationMessage } from '../src/PushNotification' ;
14
+ import { UserInfo } from '../src' ;
15
15
import { NotificationsConfig } from '../src' ;
16
16
17
17
export const credentials = {
@@ -27,12 +27,13 @@ export const awsPinpointConfig = {
27
27
region : 'us-west-2' ,
28
28
} ;
29
29
30
- export const inAppMessagingConfig = {
30
+ export const subcategoryConfig = {
31
31
AWSPinpoint : awsPinpointConfig ,
32
32
} ;
33
33
34
34
export const notificationsConfig = {
35
- InAppMessaging : inAppMessagingConfig ,
35
+ InAppMessaging : subcategoryConfig ,
36
+ Push : subcategoryConfig ,
36
37
} ;
37
38
38
39
export const adhocConfig : NotificationsConfig = {
@@ -52,9 +53,34 @@ export const awsConfig = {
52
53
Notifications : notificationsConfig ,
53
54
} ;
54
55
55
- export const simpleEvent : InAppMessagingEvent = { name : 'foo' } ;
56
+ export const imageUrl = 'http://image.fakeurl/avocado.png' ;
57
+
58
+ export const userId = 'user-id' ;
59
+
60
+ export const userInfo : UserInfo = {
61
+ attributes : {
62
+ hobbies : [ 'shuffleboard' , 'jousting' ] ,
63
+ } ,
64
+ } ;
56
65
57
- export const simpleMessages = [ { id : 'foo' } , { id : 'bar' } ] ;
66
+ export const analyticsEvent : Event = {
67
+ EventType : 'analytics-event' ,
68
+ Timestamp : '2023-03-08T18:13:03.627Z' ,
69
+ } ;
70
+
71
+ /**
72
+ * In-App Messaging data
73
+ */
74
+ export const inAppMessagingConfig = {
75
+ endpointInfo : { channelType : 'IN_APP' } ,
76
+ } ;
77
+
78
+ export const simpleInAppMessagingEvent : InAppMessagingEvent = { name : 'foo' } ;
79
+
80
+ export const simpleInAppMessages : Partial < InAppMessage > [ ] = [
81
+ { id : 'foo' } ,
82
+ { id : 'bar' } ,
83
+ ] ;
58
84
59
85
export const closestExpiryMessage : InAppMessage = {
60
86
id : 'closest-expiry' ,
@@ -122,13 +148,13 @@ export const pinpointInAppMessage: PinpointInAppMessage = {
122
148
Header : 'Header content' ,
123
149
TextColor : '#88FF88' ,
124
150
} ,
125
- ImageUrl : 'http://image.url' ,
151
+ ImageUrl : imageUrl ,
126
152
PrimaryBtn : {
127
153
DefaultConfig : {
128
154
BackgroundColor : '#8888FF' ,
129
155
BorderRadius : 4 ,
130
156
ButtonAction : ButtonAction . CLOSE ,
131
- Link : null ,
157
+ Link : undefined ,
132
158
Text : 'Close button' ,
133
159
TextColor : '#FF88FF' ,
134
160
} ,
@@ -138,7 +164,7 @@ export const pinpointInAppMessage: PinpointInAppMessage = {
138
164
BackgroundColor : '#88FFFF' ,
139
165
BorderRadius : 4 ,
140
166
ButtonAction : ButtonAction . LINK ,
141
- Link : 'http://link.url ' ,
167
+ Link : 'http://link.fakeurl ' ,
142
168
Text : 'Link button' ,
143
169
TextColor : '#FFFFFF' ,
144
170
} ,
@@ -163,8 +189,8 @@ export const pinpointInAppMessage: PinpointInAppMessage = {
163
189
} ,
164
190
} ,
165
191
QuietTime : {
166
- End : null ,
167
- Start : null ,
192
+ End : undefined ,
193
+ Start : undefined ,
168
194
} ,
169
195
} ,
170
196
SessionCap : 0 ,
@@ -184,18 +210,18 @@ export const extractedContent = [
184
210
content : 'Header content' ,
185
211
style : { color : '#88FF88' , textAlign : 'center' } ,
186
212
} ,
187
- image : { src : 'http://image.url' } ,
213
+ image : { src : imageUrl } ,
188
214
primaryButton : {
189
215
action : 'CLOSE' ,
190
216
style : { backgroundColor : '#8888FF' , borderRadius : 4 , color : '#FF88FF' } ,
191
217
title : 'Close button' ,
192
- url : null ,
218
+ url : undefined ,
193
219
} ,
194
220
secondaryButton : {
195
221
action : 'LINK' ,
196
222
style : { backgroundColor : '#88FFFF' , borderRadius : 4 , color : '#FFFFFF' } ,
197
223
title : 'Link button' ,
198
- url : 'http://link.url ' ,
224
+ url : 'http://link.fakeurl ' ,
199
225
} ,
200
226
} ,
201
227
] ;
@@ -207,22 +233,114 @@ export const extractedMetadata = {
207
233
treatmentId : 'T1' ,
208
234
} ;
209
235
210
- export const userId = 'user-id' ;
236
+ /**
237
+ * Push Notification data
238
+ */
239
+ export const pushNotificationApnsConfig = {
240
+ endpointInfo : { channelType : 'APNS' } ,
241
+ } ;
211
242
212
- export const userInfo : UserInfo = {
213
- attributes : {
214
- hobbies : [ 'shuffleboard' , 'jousting' ] ,
243
+ export const pushNotificationFcmConfig = {
244
+ endpointInfo : { channelType : 'GCM' } ,
245
+ } ;
246
+
247
+ export const pushModuleConstants = {
248
+ NativeEvent : {
249
+ BACKGROUND_MESSAGE_RECEIVED : 'BackgroundMessageReceived' ,
250
+ FOREGROUND_MESSAGE_RECEIVED : 'ForegroundMessageReceived' ,
251
+ LAUNCH_NOTIFICATION_OPENED : 'LaunchNotificationOpened' ,
252
+ NOTIFICATION_OPENED : 'NotificationOpened' ,
253
+ TOKEN_RECEIVED : 'TokenReceived' ,
215
254
} ,
255
+ NativeHeadlessTaskKey : 'PushNotificationHeadlessTaskKey' ,
216
256
} ;
217
257
218
- export const pinpointEndpointPayload = {
219
- ApplicationId : awsPinpointConfig . appId ,
220
- EndpointRequest : expect . objectContaining ( {
221
- Attributes : userInfo . attributes ,
222
- ChannelType : 'IN_APP' ,
223
- User : {
224
- UserAttributes : userInfo . attributes ,
225
- UserId : userId ,
226
- } ,
227
- } ) ,
258
+ export const simplePushMessage : PushNotificationMessage = {
259
+ title : 'foo' ,
260
+ body : 'bar' ,
261
+ } ;
262
+
263
+ export const pushToken = 'foo-bar' ;
264
+ export const pushNotificationUrl = 'http://goto.fakeurl' ;
265
+ export const pushNotificationDeeplinkUrl = 'deeplink://url' ;
266
+ export const pushNotificationAdhocData = { foo : 'bar' } ;
267
+ export const pinpointCampaign = {
268
+ campaign_id : 'campaign-id' ,
269
+ campaign_activity_id : 'campaign-activity-id' ,
270
+ treatment_id : 'treatment-id' ,
271
+ } ;
272
+ export const pinpointJourney = {
273
+ journey_activity_id : 'journey-activity-id' ,
274
+ journey_run_id : 'journey-run-id' ,
275
+ journey_id : 'journey-id' ,
276
+ } ;
277
+
278
+ export const apnsMessagePayload = {
279
+ alert : {
280
+ title : 'apns-title' ,
281
+ subtitle : 'apns-subtitle' ,
282
+ body : 'apns-body' ,
283
+ } ,
284
+ } ;
285
+
286
+ export const apnsMessage = {
287
+ aps : apnsMessagePayload ,
288
+ data : {
289
+ 'media-url' : imageUrl ,
290
+ ...pushNotificationAdhocData ,
291
+ } ,
292
+ } ;
293
+
294
+ export const fcmMessageOptions = {
295
+ channelId : 'channel-id' ,
296
+ messageId : 'message-id' ,
297
+ senderId : 'sender-id' ,
298
+ sendTime : 1678840781599 ,
299
+ } ;
300
+
301
+ export const fcmMessagePayload = {
302
+ title : 'fcm-title' ,
303
+ body : 'fcm-body' ,
304
+ imageUrl : imageUrl ,
305
+ action : { } ,
306
+ rawData : pushNotificationAdhocData ,
307
+ } ;
308
+
309
+ export const fcmMessage = {
310
+ ...fcmMessagePayload ,
311
+ ...fcmMessageOptions ,
312
+ } ;
313
+
314
+ export const ANDROID_CAMPAIGN_ACTIVITY_ID_KEY =
315
+ 'pinpoint.campaign.campaign_activity_id' ;
316
+ export const ANDROID_CAMPAIGN_ID_KEY = 'pinpoint.campaign.campaign_id' ;
317
+ export const ANDROID_CAMPAIGN_TREATMENT_ID_KEY =
318
+ 'pinpoint.campaign.treatment_id' ;
319
+
320
+ export const androidCampaignData = {
321
+ title : simplePushMessage . title ,
322
+ body : simplePushMessage . body ,
323
+ [ ANDROID_CAMPAIGN_ACTIVITY_ID_KEY ] : pinpointCampaign . campaign_activity_id ,
324
+ [ ANDROID_CAMPAIGN_ID_KEY ] : pinpointCampaign . campaign_id ,
325
+ [ ANDROID_CAMPAIGN_TREATMENT_ID_KEY ] : pinpointCampaign . treatment_id ,
326
+ } ;
327
+
328
+ export const androidJourneyData = {
329
+ title : simplePushMessage . title ,
330
+ body : simplePushMessage . body ,
331
+ pinpoint : {
332
+ journey : pinpointJourney ,
333
+ } ,
334
+ } ;
335
+
336
+ export const iosCampaignData = {
337
+ pinpoint : {
338
+ campaign : pinpointCampaign ,
339
+ } ,
340
+ } ;
341
+
342
+ export const iosJourneyData = {
343
+ pinpoint : {
344
+ journey : pinpointJourney ,
345
+ } ,
228
346
} ;
0 commit comments