@rollershop/capacitor-emarsys-sdk 1.0.0-beta.1
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/README.md +1076 -0
- package/RollershopCapacitorEmarsysSdk.podspec +18 -0
- package/android/build.gradle +58 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/de/roller/emarsys/Emarsys.java +8 -0
- package/android/src/main/java/de/roller/emarsys/EmarsysPlugin.java +22 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +1912 -0
- package/dist/esm/definitions.d.ts +266 -0
- package/dist/esm/definitions.js +3 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/interfaces/base.d.ts +25 -0
- package/dist/esm/interfaces/base.js +2 -0
- package/dist/esm/interfaces/base.js.map +1 -0
- package/dist/esm/interfaces/config.d.ts +12 -0
- package/dist/esm/interfaces/config.js +2 -0
- package/dist/esm/interfaces/config.js.map +1 -0
- package/dist/esm/interfaces/inbox.d.ts +108 -0
- package/dist/esm/interfaces/inbox.js +2 -0
- package/dist/esm/interfaces/inbox.js.map +1 -0
- package/dist/esm/interfaces/predict.d.ts +297 -0
- package/dist/esm/interfaces/predict.js +2 -0
- package/dist/esm/interfaces/predict.js.map +1 -0
- package/dist/esm/interfaces/push.d.ts +25 -0
- package/dist/esm/interfaces/push.js +2 -0
- package/dist/esm/interfaces/push.js.map +1 -0
- package/dist/plugin.cjs.js +10 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +13 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Plugin/EmarsysConfig.swift +51 -0
- package/ios/Plugin/EmarsysDelegate.swift +16 -0
- package/ios/Plugin/EmarsysInbox.swift +110 -0
- package/ios/Plugin/EmarsysPlugin.h +10 -0
- package/ios/Plugin/EmarsysPlugin.m +36 -0
- package/ios/Plugin/EmarsysPlugin.swift +335 -0
- package/ios/Plugin/EmarsysPredict.swift +195 -0
- package/ios/Plugin/EmarsysTypes.swift +18 -0
- package/ios/Plugin/Info.plist +24 -0
- package/package.json +102 -0
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
export interface CardItem {
|
|
2
|
+
/**
|
|
3
|
+
* @since 1.0.0
|
|
4
|
+
*/
|
|
5
|
+
itemId: string;
|
|
6
|
+
/**
|
|
7
|
+
* @since 1.0.0
|
|
8
|
+
*/
|
|
9
|
+
price: number;
|
|
10
|
+
/**
|
|
11
|
+
* @since 1.0.0
|
|
12
|
+
*/
|
|
13
|
+
quantity: number;
|
|
14
|
+
}
|
|
15
|
+
export interface CardItems {
|
|
16
|
+
items: CardItem[];
|
|
17
|
+
}
|
|
18
|
+
export interface Purchase extends CardItems {
|
|
19
|
+
/**
|
|
20
|
+
* @since 1.0.0
|
|
21
|
+
*/
|
|
22
|
+
orderId: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Based on `searchTerm`
|
|
26
|
+
*/
|
|
27
|
+
interface RecommendedProductSearchLogic {
|
|
28
|
+
/**
|
|
29
|
+
* @since 1.0.0
|
|
30
|
+
*/
|
|
31
|
+
type: 'search';
|
|
32
|
+
/**
|
|
33
|
+
* @since 1.0.0
|
|
34
|
+
*/
|
|
35
|
+
value: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Based on `cartItems`
|
|
39
|
+
*/
|
|
40
|
+
interface RecommendedProductCartLogic {
|
|
41
|
+
/**
|
|
42
|
+
* @since 1.0.0
|
|
43
|
+
*/
|
|
44
|
+
type: 'cart';
|
|
45
|
+
/**
|
|
46
|
+
* @since 1.0.0
|
|
47
|
+
*/
|
|
48
|
+
value: CardItem[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Based on `itemViewId`
|
|
52
|
+
*/
|
|
53
|
+
interface RecommendedProductRelatedLogic {
|
|
54
|
+
/**
|
|
55
|
+
* @since 1.0.0
|
|
56
|
+
*/
|
|
57
|
+
type: 'related';
|
|
58
|
+
/**
|
|
59
|
+
* @since 1.0.0
|
|
60
|
+
*/
|
|
61
|
+
value: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Based on `categoryPath`
|
|
65
|
+
*/
|
|
66
|
+
interface RecommendedProductCategoryLogic {
|
|
67
|
+
/**
|
|
68
|
+
* @since 1.0.0
|
|
69
|
+
*/
|
|
70
|
+
type: 'category';
|
|
71
|
+
/**
|
|
72
|
+
* @since 1.0.0
|
|
73
|
+
*/
|
|
74
|
+
value: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Based on `itemViewId`
|
|
78
|
+
*/
|
|
79
|
+
interface RecommendedProductAlsoBoughtLogic {
|
|
80
|
+
/**
|
|
81
|
+
* @since 1.0.0
|
|
82
|
+
*/
|
|
83
|
+
type: 'also_bought';
|
|
84
|
+
/**
|
|
85
|
+
* @since 1.0.0
|
|
86
|
+
*/
|
|
87
|
+
value: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Based on `categoryPath`
|
|
91
|
+
*/
|
|
92
|
+
interface RecommendedProductPopularLogic {
|
|
93
|
+
/**
|
|
94
|
+
* @since 1.0.0
|
|
95
|
+
*/
|
|
96
|
+
type: 'popular';
|
|
97
|
+
/**
|
|
98
|
+
* @since 1.0.0
|
|
99
|
+
*/
|
|
100
|
+
value: string;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Based on based on current browsing and activity
|
|
104
|
+
*
|
|
105
|
+
* Optionally based on the variants
|
|
106
|
+
*/
|
|
107
|
+
interface RecommendedProductPersonalLogic {
|
|
108
|
+
/**
|
|
109
|
+
* @since 1.0.0
|
|
110
|
+
*/
|
|
111
|
+
type: 'personal';
|
|
112
|
+
/**
|
|
113
|
+
* @since 1.0.0
|
|
114
|
+
*/
|
|
115
|
+
value?: string[];
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Based on most recent browsing behaviour
|
|
119
|
+
*
|
|
120
|
+
* Optionally based on the variants
|
|
121
|
+
*/
|
|
122
|
+
interface RecommendedProductHomeLogic {
|
|
123
|
+
/**
|
|
124
|
+
* @since 1.0.0
|
|
125
|
+
*/
|
|
126
|
+
type: 'home';
|
|
127
|
+
/**
|
|
128
|
+
* @since 1.0.0
|
|
129
|
+
*/
|
|
130
|
+
value?: string[];
|
|
131
|
+
}
|
|
132
|
+
export declare type RecommendedProductLogic = RecommendedProductSearchLogic | RecommendedProductCartLogic | RecommendedProductRelatedLogic | RecommendedProductCategoryLogic | RecommendedProductAlsoBoughtLogic | RecommendedProductPopularLogic | RecommendedProductPersonalLogic | RecommendedProductHomeLogic;
|
|
133
|
+
declare type RecommendedProductFilterType = 'include' | 'exclude';
|
|
134
|
+
declare type RecommendedProductValueFilterComparatorType = 'isValue' | 'hasValue';
|
|
135
|
+
interface RecommendedProductValueFilter {
|
|
136
|
+
/**
|
|
137
|
+
* @since 1.0.0
|
|
138
|
+
*/
|
|
139
|
+
filterType: RecommendedProductFilterType;
|
|
140
|
+
/**
|
|
141
|
+
* `isValue`: checking if the `field` is matching the `value`,
|
|
142
|
+
*
|
|
143
|
+
* `hasValue`: One of the `field` values is equal to `expectation value` (applicable only to fields containing multiple values)
|
|
144
|
+
*
|
|
145
|
+
* @since 1.0.0
|
|
146
|
+
*/
|
|
147
|
+
comparatorType: RecommendedProductValueFilterComparatorType;
|
|
148
|
+
/**
|
|
149
|
+
* @since 1.0.0
|
|
150
|
+
*/
|
|
151
|
+
field: string;
|
|
152
|
+
/**
|
|
153
|
+
* @since 1.0.0
|
|
154
|
+
*/
|
|
155
|
+
value: string;
|
|
156
|
+
}
|
|
157
|
+
declare type RecommendedProductArrayFilterComparatorType = 'inValues' | 'overlapsValues';
|
|
158
|
+
interface RecommendedProductArrayFilter {
|
|
159
|
+
/**
|
|
160
|
+
* @since 1.0.0
|
|
161
|
+
*/
|
|
162
|
+
filterType: RecommendedProductFilterType;
|
|
163
|
+
/**
|
|
164
|
+
* `inValues`: any of the `values` has a match with the `field`,
|
|
165
|
+
*
|
|
166
|
+
* `overlapsValues`: One or more of the `field` values are found in `expectation values` (applicable only to fields containing multiple values)
|
|
167
|
+
*
|
|
168
|
+
* @since 1.0.0
|
|
169
|
+
*/
|
|
170
|
+
comparatorType: RecommendedProductArrayFilterComparatorType;
|
|
171
|
+
/**
|
|
172
|
+
* @since 1.0.0
|
|
173
|
+
*/
|
|
174
|
+
field: string;
|
|
175
|
+
/**
|
|
176
|
+
* @since 1.0.0
|
|
177
|
+
*/
|
|
178
|
+
value: string[];
|
|
179
|
+
}
|
|
180
|
+
export declare type RecommendedProductFilter = RecommendedProductValueFilter | RecommendedProductArrayFilter;
|
|
181
|
+
export interface RecommendedProductOptions {
|
|
182
|
+
/**
|
|
183
|
+
* The logic that should be used.
|
|
184
|
+
*
|
|
185
|
+
* @since 1.0.0
|
|
186
|
+
*/
|
|
187
|
+
logic: RecommendedProductLogic;
|
|
188
|
+
/**
|
|
189
|
+
* You can filter product recommendations with the SDK. There are two types of filters: `Exclude` or `Include`. In every case there are four types of comparators you can use to compare your chosen field to the `value`.
|
|
190
|
+
*
|
|
191
|
+
* This is an optional parameter.
|
|
192
|
+
*
|
|
193
|
+
* @since 1.0.0
|
|
194
|
+
*/
|
|
195
|
+
filter?: RecommendedProductFilter[];
|
|
196
|
+
/**
|
|
197
|
+
* You can limit the number of recommended products received by defining a `limit`.
|
|
198
|
+
*
|
|
199
|
+
* @default 5
|
|
200
|
+
*
|
|
201
|
+
* @since 1.0.0
|
|
202
|
+
*/
|
|
203
|
+
limit?: number;
|
|
204
|
+
/**
|
|
205
|
+
* You can personalize the recommendation further by setting the `availabilityZones` parameter of the recommendation, to only recommend the locally available products. This is an optional parameter.
|
|
206
|
+
*
|
|
207
|
+
* @since 1.0.0
|
|
208
|
+
*/
|
|
209
|
+
availabilityZone?: string;
|
|
210
|
+
}
|
|
211
|
+
export interface Product {
|
|
212
|
+
/**
|
|
213
|
+
* @since 1.0.0
|
|
214
|
+
*/
|
|
215
|
+
productId: string;
|
|
216
|
+
/**
|
|
217
|
+
* @since 1.0.0
|
|
218
|
+
*/
|
|
219
|
+
title: string;
|
|
220
|
+
/**
|
|
221
|
+
* @since 1.0.0
|
|
222
|
+
*/
|
|
223
|
+
linkUrl: string;
|
|
224
|
+
/**
|
|
225
|
+
* @since 1.0.0
|
|
226
|
+
*/
|
|
227
|
+
customFields: {
|
|
228
|
+
[key: string]: any;
|
|
229
|
+
};
|
|
230
|
+
/**
|
|
231
|
+
* @since 1.0.0
|
|
232
|
+
*/
|
|
233
|
+
feature: string;
|
|
234
|
+
/**
|
|
235
|
+
* @since 1.0.0
|
|
236
|
+
*/
|
|
237
|
+
cohort: string;
|
|
238
|
+
/**
|
|
239
|
+
* @since 1.0.0
|
|
240
|
+
*/
|
|
241
|
+
imageUrl?: string;
|
|
242
|
+
/**
|
|
243
|
+
* @since 1.0.0
|
|
244
|
+
*/
|
|
245
|
+
zoomImageUrl?: string;
|
|
246
|
+
/**
|
|
247
|
+
* @since 1.0.0
|
|
248
|
+
*/
|
|
249
|
+
categoryPath?: string;
|
|
250
|
+
/**
|
|
251
|
+
* @since 1.0.0
|
|
252
|
+
*/
|
|
253
|
+
available?: number;
|
|
254
|
+
/**
|
|
255
|
+
* @since 1.0.0
|
|
256
|
+
*/
|
|
257
|
+
productDescription?: string;
|
|
258
|
+
/**
|
|
259
|
+
* @since 1.0.0
|
|
260
|
+
*/
|
|
261
|
+
price?: number;
|
|
262
|
+
/**
|
|
263
|
+
* @since 1.0.0
|
|
264
|
+
*/
|
|
265
|
+
msrp?: number;
|
|
266
|
+
/**
|
|
267
|
+
* @since 1.0.0
|
|
268
|
+
*/
|
|
269
|
+
album?: string;
|
|
270
|
+
/**
|
|
271
|
+
* @since 1.0.0
|
|
272
|
+
*/
|
|
273
|
+
actor?: string;
|
|
274
|
+
/**
|
|
275
|
+
* @since 1.0.0
|
|
276
|
+
*/
|
|
277
|
+
artist?: string;
|
|
278
|
+
/**
|
|
279
|
+
* @since 1.0.0
|
|
280
|
+
*/
|
|
281
|
+
author?: string;
|
|
282
|
+
/**
|
|
283
|
+
* @since 1.0.0
|
|
284
|
+
*/
|
|
285
|
+
brand?: string;
|
|
286
|
+
/**
|
|
287
|
+
* @since 1.0.0
|
|
288
|
+
*/
|
|
289
|
+
year?: number;
|
|
290
|
+
}
|
|
291
|
+
export interface RecommendedProducts {
|
|
292
|
+
/**
|
|
293
|
+
* @since 1.0.0
|
|
294
|
+
*/
|
|
295
|
+
products: Product[];
|
|
296
|
+
}
|
|
297
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"predict.js","sourceRoot":"","sources":["../../../src/interfaces/predict.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface TokenResult {
|
|
2
|
+
/**
|
|
3
|
+
* @since 1.0.0
|
|
4
|
+
*/
|
|
5
|
+
token: string;
|
|
6
|
+
}
|
|
7
|
+
export interface SilentPushMessageInformation {
|
|
8
|
+
/**
|
|
9
|
+
* @since 1.0.0
|
|
10
|
+
*/
|
|
11
|
+
campaignId: string;
|
|
12
|
+
}
|
|
13
|
+
export interface PushMessageEvent {
|
|
14
|
+
/**
|
|
15
|
+
* @since 1.0.0
|
|
16
|
+
*/
|
|
17
|
+
eventName: string;
|
|
18
|
+
/**
|
|
19
|
+
* @since 1.0.0
|
|
20
|
+
*/
|
|
21
|
+
data: {
|
|
22
|
+
key: string;
|
|
23
|
+
value: string;
|
|
24
|
+
}[];
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"push.js","sourceRoot":"","sources":["../../../src/interfaces/push.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Emarsys = registerPlugin('Emarsys');\nexport * from './definitions';\nexport { Emarsys };\n//# sourceMappingURL=index.js.map"],"names":["registerPlugin"],"mappings":";;;;;;AACK,MAAC,OAAO,GAAGA,mBAAc,CAAC,SAAS;;;;"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
var capacitorEmarsys = (function (exports, core) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const Emarsys = core.registerPlugin('Emarsys');
|
|
5
|
+
|
|
6
|
+
exports.Emarsys = Emarsys;
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
9
|
+
|
|
10
|
+
return exports;
|
|
11
|
+
|
|
12
|
+
})({}, capacitorExports);
|
|
13
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Emarsys = registerPlugin('Emarsys');\nexport * from './definitions';\nexport { Emarsys };\n//# sourceMappingURL=index.js.map"],"names":["registerPlugin"],"mappings":";;;AACK,OAAC,OAAO,GAAGA,mBAAc,CAAC,SAAS;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
import EmarsysSDK
|
|
4
|
+
|
|
5
|
+
public class EmarsysConfig {
|
|
6
|
+
public func getApplicationCode(_ call: CAPPluginCall) {
|
|
7
|
+
call.resolve(["applicationCode": Emarsys.config.applicationCode()]);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public func setApplicationCode(_ call: CAPPluginCall) {
|
|
11
|
+
Emarsys.config.changeApplicationCode(applicationCode: call.getString("applicationCode")!) { error in
|
|
12
|
+
guard error == nil else {
|
|
13
|
+
call.reject(error!.localizedDescription)
|
|
14
|
+
return
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
call.resolve();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public func getMerchantId(_ call: CAPPluginCall) {
|
|
22
|
+
call.resolve(["merchantId": Emarsys.config.merchantId()]);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public func setMerchantId(_ call: CAPPluginCall) {
|
|
26
|
+
Emarsys.config.changeMerchantId(merchantId: call.getString("merchantId")!) { error in
|
|
27
|
+
guard error == nil else {
|
|
28
|
+
call.reject(error!.localizedDescription)
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
call.resolve();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public func getContactFieldId(_ call: CAPPluginCall) {
|
|
37
|
+
call.resolve(["contactFieldId": Emarsys.config.contactFieldId().intValue]);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public func getHardwareId(_ call: CAPPluginCall) {
|
|
41
|
+
call.resolve(["hardwareId": Emarsys.config.hardwareId()]);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public func getLanguageCode(_ call: CAPPluginCall) {
|
|
45
|
+
call.resolve(["languageCode": Emarsys.config.languageCode()]);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public func getSdkVersion(_ call: CAPPluginCall) {
|
|
49
|
+
call.resolve(["sdkVersion": Emarsys.config.sdkVersion()]);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Foundation;
|
|
2
|
+
import UIKit;
|
|
3
|
+
|
|
4
|
+
open class EmarsysDelegate: UIResponder, UIApplicationDelegate {
|
|
5
|
+
public func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
|
|
6
|
+
NotificationCenter.default.post(name: .emarsysRegisterWithToken, object: deviceToken);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
public func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
|
|
10
|
+
NotificationCenter.default.post(name: .emarsysRegisterFailed, object: error)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
|
|
14
|
+
NotificationCenter.default.post(name: .emarsysReceivedRemoteNotification, object: completionHandler, userInfo: userInfo)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
import EmarsysSDK
|
|
4
|
+
|
|
5
|
+
public class EmarsysInbox {
|
|
6
|
+
public func fetchMessages(_ call: CAPPluginCall) {
|
|
7
|
+
Emarsys.messageInbox.fetchMessages { inboxResult, error in
|
|
8
|
+
guard error == nil else {
|
|
9
|
+
call.reject(error!.localizedDescription)
|
|
10
|
+
return
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
call.resolve(self.formatMessages(messages: inboxResult!.messages));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public func addTag(_ call: CAPPluginCall) {
|
|
18
|
+
Emarsys.messageInbox.addTag(tag: call.getString("tag")!, messageId: call.getString("messageId")!) { error in
|
|
19
|
+
guard error == nil else {
|
|
20
|
+
call.reject(error!.localizedDescription)
|
|
21
|
+
return
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
call.resolve();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public func removeTag(_ call: CAPPluginCall) {
|
|
29
|
+
Emarsys.messageInbox.removeTag(tag: call.getString("tag")!, messageId: call.getString("messageId")!) { error in
|
|
30
|
+
guard error == nil else {
|
|
31
|
+
call.reject(error!.localizedDescription)
|
|
32
|
+
return
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
call.resolve();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Helper
|
|
40
|
+
|
|
41
|
+
private func formatMessages(messages: [EMSMessage]?) -> PluginCallResultData {
|
|
42
|
+
var jsMessages = [JSObject]();
|
|
43
|
+
|
|
44
|
+
messages?.forEach { message in
|
|
45
|
+
var jsMessage = JSObject.init(dictionaryLiteral:
|
|
46
|
+
("id", message.id),
|
|
47
|
+
("campaignId", message.campaignId),
|
|
48
|
+
("title", message.title),
|
|
49
|
+
("body", message.body),
|
|
50
|
+
("receivedAt", message.receivedAt.intValue)
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
if(message.collapseId != nil) {
|
|
54
|
+
jsMessage["collapseId"] = message.collapseId;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if(message.imageUrl != nil) {
|
|
58
|
+
jsMessage["imageUrl"] = message.imageUrl;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if(message.updatedAt != nil) {
|
|
62
|
+
jsMessage["updatedAt"] = message.updatedAt!.intValue;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if(message.expiresAt != nil) {
|
|
66
|
+
jsMessage["expiresAt"] = message.expiresAt!.intValue;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
var jsMessageTags = JSArray();
|
|
70
|
+
message.tags?.forEach { tag in
|
|
71
|
+
jsMessageTags.append(tag);
|
|
72
|
+
}
|
|
73
|
+
jsMessage["tags"] = jsMessageTags;
|
|
74
|
+
|
|
75
|
+
jsMessage["properties"] = JSTypes.coerceDictionaryToJSObject(message.properties ?? [:] )!
|
|
76
|
+
|
|
77
|
+
jsMessage["actions"] = self.formatMessageActions(actions: message.actions)
|
|
78
|
+
|
|
79
|
+
jsMessages.append(jsMessage);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return ["messages": jsMessages];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
private func formatMessageActions(actions: [EMSActionModelProtocol]?) -> JSValue {
|
|
86
|
+
var jsActions = [JSObject]();
|
|
87
|
+
|
|
88
|
+
actions?.forEach { action in
|
|
89
|
+
var jsAction = JSObject.init(dictionaryLiteral:
|
|
90
|
+
("id", action.id()),
|
|
91
|
+
("title", action.title()),
|
|
92
|
+
("type", action.type())
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
if let applicationAction = action as? EMSAppEventActionModel {
|
|
96
|
+
jsAction["name"] = applicationAction.name;
|
|
97
|
+
jsAction["payload"] = JSTypes.coerceDictionaryToJSObject(applicationAction.payload ?? [:] )!;
|
|
98
|
+
} else if let customAction = action as? EMSCustomEventActionModel {
|
|
99
|
+
jsAction["name"] = customAction.name;
|
|
100
|
+
jsAction["payload"] = JSTypes.coerceDictionaryToJSObject(customAction.payload ?? [:] )!;
|
|
101
|
+
} else if let externalUrlAction = action as? EMSOpenExternalUrlActionModel {
|
|
102
|
+
jsAction["url"] = externalUrlAction.url.absoluteString;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
jsActions.append(jsAction);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return jsActions;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#import <UIKit/UIKit.h>
|
|
2
|
+
|
|
3
|
+
//! Project version number for Plugin.
|
|
4
|
+
FOUNDATION_EXPORT double PluginVersionNumber;
|
|
5
|
+
|
|
6
|
+
//! Project version string for Plugin.
|
|
7
|
+
FOUNDATION_EXPORT const unsigned char PluginVersionString[];
|
|
8
|
+
|
|
9
|
+
// In this header, you should import all the public headers of your framework using statements like #import <Plugin/PublicHeader.h>
|
|
10
|
+
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
#import <Capacitor/Capacitor.h>
|
|
3
|
+
|
|
4
|
+
// Define the plugin using the CAP_PLUGIN Macro, and
|
|
5
|
+
// each method the plugin supports using the CAP_PLUGIN_METHOD macro.
|
|
6
|
+
CAP_PLUGIN(EmarsysPlugin, "Emarsys",
|
|
7
|
+
CAP_PLUGIN_METHOD(requestPermissions, CAPPluginReturnPromise);
|
|
8
|
+
CAP_PLUGIN_METHOD(checkPermissions, CAPPluginReturnPromise);
|
|
9
|
+
CAP_PLUGIN_METHOD(register, CAPPluginReturnPromise);
|
|
10
|
+
CAP_PLUGIN_METHOD(setContact, CAPPluginReturnPromise);
|
|
11
|
+
CAP_PLUGIN_METHOD(setAuthenticatedContact, CAPPluginReturnPromise);
|
|
12
|
+
CAP_PLUGIN_METHOD(clearContact, CAPPluginReturnPromise);
|
|
13
|
+
CAP_PLUGIN_METHOD(getPushToken, CAPPluginReturnPromise);
|
|
14
|
+
CAP_PLUGIN_METHOD(clearPushToken, CAPPluginReturnPromise);
|
|
15
|
+
CAP_PLUGIN_METHOD(pauseInApp, CAPPluginReturnPromise);
|
|
16
|
+
CAP_PLUGIN_METHOD(isInAppPaused, CAPPluginReturnPromise);
|
|
17
|
+
CAP_PLUGIN_METHOD(resumeInApp, CAPPluginReturnPromise);
|
|
18
|
+
CAP_PLUGIN_METHOD(trackItem, CAPPluginReturnPromise);
|
|
19
|
+
CAP_PLUGIN_METHOD(trackCategory, CAPPluginReturnPromise);
|
|
20
|
+
CAP_PLUGIN_METHOD(trackSearch, CAPPluginReturnPromise);
|
|
21
|
+
CAP_PLUGIN_METHOD(trackTag, CAPPluginReturnPromise);
|
|
22
|
+
CAP_PLUGIN_METHOD(trackCard, CAPPluginReturnPromise);
|
|
23
|
+
CAP_PLUGIN_METHOD(trackPurchase, CAPPluginReturnPromise);
|
|
24
|
+
CAP_PLUGIN_METHOD(recommendProducts, CAPPluginReturnPromise);
|
|
25
|
+
CAP_PLUGIN_METHOD(trackRecommendationClick, CAPPluginReturnPromise);
|
|
26
|
+
CAP_PLUGIN_METHOD(fetchMessages, CAPPluginReturnPromise);
|
|
27
|
+
CAP_PLUGIN_METHOD(addTag, CAPPluginReturnPromise);
|
|
28
|
+
CAP_PLUGIN_METHOD(removeTag, CAPPluginReturnPromise);
|
|
29
|
+
CAP_PLUGIN_METHOD(getApplicationCode, CAPPluginReturnPromise);
|
|
30
|
+
CAP_PLUGIN_METHOD(setApplicationCode, CAPPluginReturnPromise);
|
|
31
|
+
CAP_PLUGIN_METHOD(getMerchantId, CAPPluginReturnPromise);
|
|
32
|
+
CAP_PLUGIN_METHOD(getContactFieldId, CAPPluginReturnPromise);
|
|
33
|
+
CAP_PLUGIN_METHOD(getHardwareId, CAPPluginReturnPromise);
|
|
34
|
+
CAP_PLUGIN_METHOD(getLanguageCode, CAPPluginReturnPromise);
|
|
35
|
+
CAP_PLUGIN_METHOD(getSdkVersion, CAPPluginReturnPromise);
|
|
36
|
+
)
|