react-native-moengage-inbox 5.1.1 → 6.0.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/ReactNativeMoEngageInbox.podspec +2 -2
- package/android/build.gradle +6 -6
- package/package.json +7 -3
- package/src/model/MoEInboxMessage.ts +7 -2
- package/src/model/MoEMedia.ts +5 -1
- package/src/model/MoETextContent.ts +2 -0
- package/src/utils/MoEInboxConstants.ts +3 -0
- package/src/utils/MoEInboxParser.ts +46 -22
|
@@ -10,14 +10,14 @@ Pod::Spec.new do |s|
|
|
|
10
10
|
s.license = package['license']
|
|
11
11
|
s.authors = package["author"]
|
|
12
12
|
|
|
13
|
-
s.platforms = { :ios => "
|
|
13
|
+
s.platforms = { :ios => "13.0" }
|
|
14
14
|
s.source = { :git => "https://github.com/moengage/React-Native.git", :tag => "#{s.version}" }
|
|
15
15
|
|
|
16
16
|
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
17
17
|
s.public_header_files = 'ios/**/*.h'
|
|
18
18
|
|
|
19
19
|
s.dependency "React-Core"
|
|
20
|
-
s.dependency "MoEngagePluginInbox",'
|
|
20
|
+
s.dependency "MoEngagePluginInbox",'4.2.1'
|
|
21
21
|
s.dependency 'ReactNativeMoEngage'
|
|
22
22
|
s.module_map = false
|
|
23
23
|
|
package/android/build.gradle
CHANGED
|
@@ -15,9 +15,9 @@ buildscript {
|
|
|
15
15
|
|
|
16
16
|
ext {
|
|
17
17
|
//dependency version
|
|
18
|
-
moengageCoreVersion = "
|
|
19
|
-
moengageInboxCoreVersion = "
|
|
20
|
-
pluginBaseInboxVersion = "
|
|
18
|
+
moengageCoreVersion = "14.03.00"
|
|
19
|
+
moengageInboxCoreVersion = "4.1.0"
|
|
20
|
+
pluginBaseInboxVersion = "5.0.0"
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
apply plugin: 'com.android.library'
|
|
@@ -25,10 +25,10 @@ apply plugin: 'kotlin-android'
|
|
|
25
25
|
apply plugin: 'com.facebook.react'
|
|
26
26
|
|
|
27
27
|
android {
|
|
28
|
-
compileSdk
|
|
28
|
+
compileSdk 35
|
|
29
29
|
namespace "com.moengage.react.inbox"
|
|
30
30
|
defaultConfig {
|
|
31
|
-
minSdk
|
|
31
|
+
minSdk 23
|
|
32
32
|
versionCode 1
|
|
33
33
|
versionName "1.0"
|
|
34
34
|
|
|
@@ -83,4 +83,4 @@ dependencies {
|
|
|
83
83
|
|
|
84
84
|
def isNewArchitectureEnabled() {
|
|
85
85
|
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
|
|
86
|
-
}
|
|
86
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-moengage-inbox",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Inbox Module for the MoEngage Platform",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"files": [
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"!**/__mocks__"
|
|
19
19
|
],
|
|
20
20
|
"scripts": {
|
|
21
|
-
"test": "
|
|
21
|
+
"test": "jest"
|
|
22
22
|
},
|
|
23
23
|
"keywords": [
|
|
24
24
|
"react-native",
|
|
@@ -39,7 +39,11 @@
|
|
|
39
39
|
},
|
|
40
40
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"
|
|
42
|
+
"@types/jest": "^29.5.0",
|
|
43
|
+
"babel-jest": "^29.7.0",
|
|
44
|
+
"react-native": "0.73.0",
|
|
45
|
+
"ts-jest": "^29.1.0",
|
|
46
|
+
"typescript": "^4.3.0"
|
|
43
47
|
},
|
|
44
48
|
"codegenConfig": {
|
|
45
49
|
"name": "NativeMoEngageInboxSpec",
|
|
@@ -13,8 +13,11 @@ export default class MoEInboxMessage {
|
|
|
13
13
|
receivedTime: string;
|
|
14
14
|
expiry: string;
|
|
15
15
|
payload: Map<String, Object>;
|
|
16
|
+
groupKey: string | null;
|
|
17
|
+
notificationId: string | null;
|
|
18
|
+
sentTime: string | null;
|
|
16
19
|
|
|
17
|
-
constructor(id: number | undefined, campaignId: string, textContent: MoETextContent, isClicked: boolean, media: MoEMedia | undefined, action: Array<MoEAction> | undefined, tag: string | undefined, receivedTime: string, expiry: string, payload: Map<String, Object
|
|
20
|
+
constructor(id: number | undefined, campaignId: string, textContent: MoETextContent, isClicked: boolean, media: MoEMedia | undefined, action: Array<MoEAction> | undefined, tag: string | undefined, receivedTime: string, expiry: string, payload: Map<String, Object>, groupKey: string | null, notificationId: string | null, sentTime: string | null) {
|
|
18
21
|
this.id = id;
|
|
19
22
|
this.campaignId = campaignId;
|
|
20
23
|
this.text = textContent;
|
|
@@ -25,6 +28,8 @@ export default class MoEInboxMessage {
|
|
|
25
28
|
this.receivedTime = receivedTime;
|
|
26
29
|
this.expiry = expiry;
|
|
27
30
|
this.payload = payload
|
|
28
|
-
|
|
31
|
+
this.groupKey = groupKey;
|
|
32
|
+
this.notificationId = notificationId;
|
|
33
|
+
this.sentTime = sentTime;
|
|
29
34
|
}
|
|
30
35
|
}
|
package/src/model/MoEMedia.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { MoEMediaType } from "./MoEMediaType";
|
|
2
|
+
import { MoEAccessibilityData } from "react-native-moengage";
|
|
2
3
|
|
|
3
4
|
export default class MoEMedia {
|
|
4
5
|
mediaType: MoEMediaType;
|
|
5
6
|
url: string;
|
|
6
|
-
|
|
7
|
+
accessibilityData: MoEAccessibilityData | null;
|
|
8
|
+
|
|
9
|
+
constructor(mediaType: MoEMediaType, url: string, accessibilityData: MoEAccessibilityData | null) {
|
|
7
10
|
this.mediaType = mediaType;
|
|
8
11
|
this.url = url;
|
|
12
|
+
this.accessibilityData = accessibilityData;
|
|
9
13
|
}
|
|
10
14
|
}
|
|
@@ -2,6 +2,8 @@ export default class MoETextContent {
|
|
|
2
2
|
title: string;
|
|
3
3
|
message: string;
|
|
4
4
|
summary?: string | undefined;
|
|
5
|
+
// Only for iOS
|
|
6
|
+
// subtitle is only for iOS
|
|
5
7
|
subtitle?: string | undefined;
|
|
6
8
|
constructor(title: string, message: string, summary: string | undefined, subtitle: string | undefined) {
|
|
7
9
|
this.title = title;
|
|
@@ -7,7 +7,9 @@ import MoEAction from "../model/MoEAction";
|
|
|
7
7
|
import * as InboxConstants from "../utils/MoEInboxConstants"
|
|
8
8
|
import { isValidObject, isValidString, isValidNumber } from "../utils/MoEInboxHelper";
|
|
9
9
|
import { MoEPlatform } from "../model/MoEPlatform";
|
|
10
|
-
import { MOE_DATA } from "../utils/MoEInboxConstants"
|
|
10
|
+
import { MOE_DATA } from "../utils/MoEInboxConstants";
|
|
11
|
+
import { KEY_ACCESSIBILITY, MoEAccessibilityData } from "react-native-moengage";
|
|
12
|
+
|
|
11
13
|
const PLATFORM = 'platform'
|
|
12
14
|
const UNCLICKED_COUNT = 'unClickedCount'
|
|
13
15
|
|
|
@@ -15,8 +17,8 @@ export function inboxDataFromJson(payload: string) {
|
|
|
15
17
|
const inboxJSON = JSON.parse(payload);
|
|
16
18
|
const inboxData = inboxJSON[InboxConstants.MOE_DATA]
|
|
17
19
|
var platform;
|
|
18
|
-
var messageList:MoEInboxMessage[] = [];
|
|
19
|
-
|
|
20
|
+
var messageList: MoEInboxMessage[] = [];
|
|
21
|
+
|
|
20
22
|
if (isValidObject(inboxData)) {
|
|
21
23
|
|
|
22
24
|
platform = inboxData[PLATFORM];
|
|
@@ -25,7 +27,7 @@ export function inboxDataFromJson(payload: string) {
|
|
|
25
27
|
for (var message of messages) {
|
|
26
28
|
var inboxMessage = inboxMessageFromJson(message);
|
|
27
29
|
if (inboxMessage != null)
|
|
28
|
-
|
|
30
|
+
messageList.push(inboxMessage);
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
if (platform != undefined)
|
|
@@ -33,7 +35,7 @@ export function inboxDataFromJson(payload: string) {
|
|
|
33
35
|
return undefined;
|
|
34
36
|
}
|
|
35
37
|
|
|
36
|
-
function inboxMessageFromJson(message: { [k: string]: any }) {
|
|
38
|
+
export function inboxMessageFromJson(message: { [k: string]: any }) {
|
|
37
39
|
if (message != undefined) {
|
|
38
40
|
var id;
|
|
39
41
|
var campaignId;
|
|
@@ -42,9 +44,12 @@ function inboxMessageFromJson(message: { [k: string]: any }) {
|
|
|
42
44
|
var expiry;
|
|
43
45
|
var tag;
|
|
44
46
|
var textContent;
|
|
45
|
-
var actionList:Array<MoEAction
|
|
47
|
+
var actionList: Array<MoEAction> = [];
|
|
46
48
|
var media;
|
|
47
49
|
var payload;
|
|
50
|
+
var groupKey: string | null = null;
|
|
51
|
+
var notificationId: string | null = null;
|
|
52
|
+
var sentTime: string | null = null;
|
|
48
53
|
|
|
49
54
|
campaignId = message[InboxConstants.CAMPAIGN_ID];
|
|
50
55
|
isClicked = message[InboxConstants.IS_CLICKED];
|
|
@@ -61,9 +66,9 @@ function inboxMessageFromJson(message: { [k: string]: any }) {
|
|
|
61
66
|
|
|
62
67
|
textContent = textContentFromJson(message[InboxConstants.TEXT]);
|
|
63
68
|
for (var action of actions) {
|
|
64
|
-
var moEAction=actionModelFromJson(action)
|
|
65
|
-
moEAction?
|
|
66
|
-
|
|
69
|
+
var moEAction = actionModelFromJson(action)
|
|
70
|
+
moEAction ?
|
|
71
|
+
actionList.push(moEAction) : null;
|
|
67
72
|
}
|
|
68
73
|
if (isValidObject(message[InboxConstants.MEDIA])) {
|
|
69
74
|
media = mediaModelFromJson(message[InboxConstants.MEDIA]);
|
|
@@ -72,19 +77,30 @@ function inboxMessageFromJson(message: { [k: string]: any }) {
|
|
|
72
77
|
if (isValidObject(message[InboxConstants.PAYLOAD])) {
|
|
73
78
|
payload = message[InboxConstants.PAYLOAD];
|
|
74
79
|
}
|
|
80
|
+
if (isValidString(message[InboxConstants.GROUP_KEY])) {
|
|
81
|
+
groupKey = message[InboxConstants.GROUP_KEY];
|
|
82
|
+
}
|
|
83
|
+
if (isValidString(message[InboxConstants.NOTIFICATION_ID])) {
|
|
84
|
+
notificationId = message[InboxConstants.NOTIFICATION_ID];
|
|
85
|
+
}
|
|
86
|
+
if (isValidString(message[InboxConstants.SENT_TIME])) {
|
|
87
|
+
sentTime = message[InboxConstants.SENT_TIME];
|
|
88
|
+
}
|
|
75
89
|
if (campaignId != undefined && textContent != undefined && isClicked != undefined && receivedTime != undefined && expiry != undefined && payload != undefined)
|
|
76
|
-
return new MoEInboxMessage(id, campaignId, textContent, isClicked, media, actionList, tag, receivedTime, expiry, payload)
|
|
90
|
+
return new MoEInboxMessage(id, campaignId, textContent, isClicked, media, actionList, tag, receivedTime, expiry, payload, groupKey, notificationId, sentTime);
|
|
77
91
|
else
|
|
78
92
|
return undefined;
|
|
79
93
|
|
|
80
94
|
}
|
|
81
95
|
else return undefined;
|
|
82
|
-
|
|
96
|
+
|
|
83
97
|
}
|
|
84
98
|
|
|
85
99
|
function mediaModelFromJson(mediaObject: { [k: string]: any }) {
|
|
86
100
|
var mediaType;
|
|
87
|
-
var url
|
|
101
|
+
var url;
|
|
102
|
+
var accessibilityData;
|
|
103
|
+
|
|
88
104
|
if (isValidString(mediaObject[InboxConstants.TYPE])) {
|
|
89
105
|
mediaType = mediaObject[InboxConstants.TYPE];
|
|
90
106
|
}
|
|
@@ -92,12 +108,16 @@ function mediaModelFromJson(mediaObject: { [k: string]: any }) {
|
|
|
92
108
|
if (isValidString(mediaObject[InboxConstants.URL])) {
|
|
93
109
|
url = mediaObject[InboxConstants.URL];
|
|
94
110
|
}
|
|
111
|
+
|
|
112
|
+
if (isValidObject(mediaObject[KEY_ACCESSIBILITY])) {
|
|
113
|
+
accessibilityData = MoEAccessibilityData.fromJson(mediaObject[KEY_ACCESSIBILITY]);
|
|
114
|
+
}
|
|
95
115
|
if (mediaType != undefined && url != undefined)
|
|
96
|
-
return new MoEMedia(mediaType, url)
|
|
116
|
+
return new MoEMedia(mediaType, url, accessibilityData ?? null)
|
|
97
117
|
else return undefined;
|
|
98
118
|
}
|
|
99
119
|
|
|
100
|
-
function actionModelFromJson(actionObject: { [k: string]: any}) {
|
|
120
|
+
function actionModelFromJson(actionObject: { [k: string]: any }) {
|
|
101
121
|
var actionType = actionObject[InboxConstants.ACTION_TYPE];
|
|
102
122
|
var navigationType;
|
|
103
123
|
var value;
|
|
@@ -112,7 +132,7 @@ function actionModelFromJson(actionObject: { [k: string]: any}) {
|
|
|
112
132
|
kvPair = actionObject[InboxConstants.KV_PAIR];
|
|
113
133
|
}
|
|
114
134
|
if (actionType != undefined)
|
|
115
|
-
return new MoEAction(actionType, navigationType,value,kvPair)
|
|
135
|
+
return new MoEAction(actionType, navigationType, value, kvPair)
|
|
116
136
|
else return undefined;
|
|
117
137
|
}
|
|
118
138
|
|
|
@@ -158,7 +178,10 @@ export function inboxMessageToJson(message: MoEInboxMessage) {
|
|
|
158
178
|
isClicked: message.isClicked,
|
|
159
179
|
tag: message.tag,
|
|
160
180
|
receivedTime: message.receivedTime,
|
|
161
|
-
expiry: message.expiry
|
|
181
|
+
expiry: message.expiry,
|
|
182
|
+
sentTime: message.sentTime,
|
|
183
|
+
groupKey: message.groupKey,
|
|
184
|
+
notificationId: message.notificationId
|
|
162
185
|
};
|
|
163
186
|
if (isValidObject(message.text)) {
|
|
164
187
|
json[InboxConstants.TEXT] = textContentToJson(message.text);
|
|
@@ -197,7 +220,8 @@ function textContentToJson(textContent: MoETextContent) {
|
|
|
197
220
|
function mediaToJson(media: MoEMedia) {
|
|
198
221
|
var json = {
|
|
199
222
|
type: media.mediaType,
|
|
200
|
-
url: media.url
|
|
223
|
+
url: media.url,
|
|
224
|
+
accessibility: media.accessibilityData ? media.accessibilityData.toJson() : null
|
|
201
225
|
}
|
|
202
226
|
return json
|
|
203
227
|
}
|
|
@@ -206,8 +230,8 @@ function actionToJson(action: MoEAction) {
|
|
|
206
230
|
var json = {
|
|
207
231
|
actionType: action.actionType,
|
|
208
232
|
navigationType: action.navigationType,
|
|
209
|
-
value:action.value,
|
|
210
|
-
kvPair:action.kvPair
|
|
233
|
+
value: action.value,
|
|
234
|
+
kvPair: action.kvPair
|
|
211
235
|
}
|
|
212
236
|
return json;
|
|
213
237
|
}
|
|
@@ -215,10 +239,10 @@ function actionToJson(action: MoEAction) {
|
|
|
215
239
|
export function fetchEmptyInboxModel() {
|
|
216
240
|
var platform;
|
|
217
241
|
|
|
218
|
-
if(Platform.OS=="ios")
|
|
219
|
-
|
|
242
|
+
if (Platform.OS == "ios")
|
|
243
|
+
platform = MoEPlatform.IOS
|
|
220
244
|
else
|
|
221
|
-
|
|
245
|
+
platform = MoEPlatform.Android
|
|
222
246
|
|
|
223
247
|
return new MoEInboxData(platform, [])
|
|
224
248
|
}
|