@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.
Files changed (43) hide show
  1. package/README.md +1076 -0
  2. package/RollershopCapacitorEmarsysSdk.podspec +18 -0
  3. package/android/build.gradle +58 -0
  4. package/android/src/main/AndroidManifest.xml +3 -0
  5. package/android/src/main/java/de/roller/emarsys/Emarsys.java +8 -0
  6. package/android/src/main/java/de/roller/emarsys/EmarsysPlugin.java +22 -0
  7. package/android/src/main/res/.gitkeep +0 -0
  8. package/dist/docs.json +1912 -0
  9. package/dist/esm/definitions.d.ts +266 -0
  10. package/dist/esm/definitions.js +3 -0
  11. package/dist/esm/definitions.js.map +1 -0
  12. package/dist/esm/index.d.ts +4 -0
  13. package/dist/esm/index.js +5 -0
  14. package/dist/esm/index.js.map +1 -0
  15. package/dist/esm/interfaces/base.d.ts +25 -0
  16. package/dist/esm/interfaces/base.js +2 -0
  17. package/dist/esm/interfaces/base.js.map +1 -0
  18. package/dist/esm/interfaces/config.d.ts +12 -0
  19. package/dist/esm/interfaces/config.js +2 -0
  20. package/dist/esm/interfaces/config.js.map +1 -0
  21. package/dist/esm/interfaces/inbox.d.ts +108 -0
  22. package/dist/esm/interfaces/inbox.js +2 -0
  23. package/dist/esm/interfaces/inbox.js.map +1 -0
  24. package/dist/esm/interfaces/predict.d.ts +297 -0
  25. package/dist/esm/interfaces/predict.js +2 -0
  26. package/dist/esm/interfaces/predict.js.map +1 -0
  27. package/dist/esm/interfaces/push.d.ts +25 -0
  28. package/dist/esm/interfaces/push.js +2 -0
  29. package/dist/esm/interfaces/push.js.map +1 -0
  30. package/dist/plugin.cjs.js +10 -0
  31. package/dist/plugin.cjs.js.map +1 -0
  32. package/dist/plugin.js +13 -0
  33. package/dist/plugin.js.map +1 -0
  34. package/ios/Plugin/EmarsysConfig.swift +51 -0
  35. package/ios/Plugin/EmarsysDelegate.swift +16 -0
  36. package/ios/Plugin/EmarsysInbox.swift +110 -0
  37. package/ios/Plugin/EmarsysPlugin.h +10 -0
  38. package/ios/Plugin/EmarsysPlugin.m +36 -0
  39. package/ios/Plugin/EmarsysPlugin.swift +335 -0
  40. package/ios/Plugin/EmarsysPredict.swift +195 -0
  41. package/ios/Plugin/EmarsysTypes.swift +18 -0
  42. package/ios/Plugin/Info.plist +24 -0
  43. package/package.json +102 -0
@@ -0,0 +1,266 @@
1
+ import type { PluginListenerHandle } from '@capacitor/core';
2
+ import type { ContactFieldId, PermissionStatus, SetAuthenticatedContactOptions, SetContactOptions } from './interfaces/base';
3
+ import type { ApplicationCode, MerchantId } from './interfaces/config';
4
+ import type { InboxTag } from './interfaces/inbox';
5
+ import type { CardItems, Product, Purchase, RecommendedProductOptions, RecommendedProducts } from './interfaces/predict';
6
+ import type { PushMessageEvent, SilentPushMessageInformation, TokenResult } from './interfaces/push';
7
+ declare type ConsoleLogLevels = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'basic';
8
+ declare module '@capacitor/cli' {
9
+ interface PluginsConfig {
10
+ /**
11
+ * The following options are available to initialize the SDK:
12
+ */
13
+ Emarsys?: {
14
+ /**
15
+ * Emarsys App code, which is generated when the app is added to the account.
16
+ *
17
+ * @since 1.0.0
18
+ * @example 'yourApplicationCode'
19
+ */
20
+ mobileEngageApplicationCode?: string;
21
+ /**
22
+ * Emarsys Predict Merchant ID (If the Predict feature is enabled on the Emarsys account).
23
+ *
24
+ * @since 1.0.0
25
+ * @example 'yourMerchantId'
26
+ */
27
+ merchantId?: string;
28
+ /**
29
+ * The default console logging is only showing logs when you call an unallowed method.
30
+ * You are able to modify the allowed loglevels for console logging, by setting it during the setup.
31
+ *
32
+ * @since 1.0.0
33
+ * @example ['info', 'debug', '...']
34
+ */
35
+ consoleLogLevels?: ConsoleLogLevels[];
36
+ };
37
+ }
38
+ }
39
+ export interface EmarsysPlugin {
40
+ /**
41
+ * Check permission to receive push notifications.
42
+ *
43
+ * @example Test
44
+ * @since 1.0.0
45
+ */
46
+ checkPermissions(): Promise<PermissionStatus>;
47
+ /**
48
+ * Request permission to receive push notifications.
49
+ *
50
+ * @since 1.0.0
51
+ */
52
+ requestPermissions(): Promise<PermissionStatus>;
53
+ /**
54
+ * Register the app to receive push notifications.
55
+ *
56
+ * This method will resolve with the push token or reject if there was a problem. It does not prompt the user for notification permissions, use `requestPermissions()` first.
57
+ *
58
+ * @since 1.0.0
59
+ */
60
+ register(): Promise<TokenResult>;
61
+ /**
62
+ * After application setup is finished, you can use this method to identify the user with `contactFieldValue`.
63
+ *
64
+ * Without contact identification all tracked events will be linked to an anonymous contact in Mobile Engage and will rely on visitor cookies in case of Predict.
65
+ *
66
+ * @since 1.0.0
67
+ */
68
+ setContact(options: SetContactOptions): Promise<void>;
69
+ /**
70
+ * After the application setup is finished, you can use this method to identify the user with an `openIdToken`.
71
+ *
72
+ * Without contact identification all tracked events will be linked to an anonymous contact in Mobile Engage and will rely on visitor cookies in case of Predict.
73
+ *
74
+ * @since 1.0.0
75
+ */
76
+ setAuthenticatedContact(options: SetAuthenticatedContactOptions): Promise<void>;
77
+ /**
78
+ * When the user signs out, this method should be used.
79
+ *
80
+ * You only need to call `clearContact` when you explicitly want to sign out the contact from Emarsys even if the user isn’t logged in into your application.
81
+ *
82
+ * @since 1.0.0
83
+ */
84
+ clearContact(): Promise<void>;
85
+ /**
86
+ * Use this method to get the current push token.
87
+ *
88
+ * @since 1.0.0
89
+ */
90
+ getPushToken(): Promise<TokenResult>;
91
+ /**
92
+ * Use this method to remove the push token of the contact.
93
+ *
94
+ * @since 1.0.0
95
+ */
96
+ clearPushToken(): Promise<void>;
97
+ /**
98
+ * When a critical activity starts and should not be interrupted by In-App, pause In-App messages.
99
+ *
100
+ * @since 1.0.0
101
+ */
102
+ pauseInApp(): Promise<void>;
103
+ /**
104
+ * Use this method to check if in app messages are paused.
105
+ *
106
+ * @since 1.0.0
107
+ */
108
+ isInAppPaused(): Promise<{
109
+ isPaused: boolean;
110
+ }>;
111
+ /**
112
+ * In order to show In-App messages after being paused, use the resume method.
113
+ *
114
+ * @since 1.0.0
115
+ */
116
+ resumeInApp(): Promise<void>;
117
+ /**
118
+ * If an item was viewed use the `trackItemView` method with an itemId.
119
+ *
120
+ * @since 1.0.0
121
+ */
122
+ trackItem(options: {
123
+ itemId: string;
124
+ }): Promise<void>;
125
+ /**
126
+ * When the user navigates between the categories you should call `trackCategoryView` in every navigation. Be aware to send `categoryPath` in the required format. Please visit [Predict's documentation](https://dev.emarsys.com/v2/web-extend-command-reference) for more information.
127
+ *
128
+ * @since 1.0.0
129
+ */
130
+ trackCategory(options: {
131
+ categoryPath: string;
132
+ }): Promise<void>;
133
+ /**
134
+ * To report search terms entered by the contact use `trackSearchTerm` method.
135
+ *
136
+ * @since 1.0.0
137
+ */
138
+ trackSearch(options: {
139
+ searchTerm: string;
140
+ }): Promise<void>;
141
+ /**
142
+ * To report search terms entered by the contact use `trackSearchTerm` method.
143
+ *
144
+ * @since 1.0.0
145
+ */
146
+ trackTag(options: {
147
+ tag: string;
148
+ }): Promise<void>;
149
+ /**
150
+ * When you want to track the cart items in the basket you can call this method with a list of CartItems.
151
+ *
152
+ * @since 1.0.0
153
+ */
154
+ trackCard(options: CardItems): Promise<void>;
155
+ /**
156
+ * To report a purchase event you should call this method with the items purchased and with an `orderId`.
157
+ *
158
+ * @since 1.0.0
159
+ */
160
+ trackPurchase(options: Purchase): Promise<void>;
161
+ /**
162
+ * With the Emarsys SDK you can ask for product recommendations based on different recommendation logics.
163
+ *
164
+ * This method is also going to track the value attached to the logic on the backend, so no additional tracking needed when using recommendations!
165
+ *
166
+ * @since 1.0.0
167
+ */
168
+ recommendProducts(options: RecommendedProductOptions): Promise<RecommendedProducts>;
169
+ /**
170
+ * The Emarsys SDK doesn't track automatically recommendationClicks, so you have to call manually `trackRecommendationClick` when an interaction happens with any of the recommended `products`.
171
+ *
172
+ * @since 1.0.0
173
+ */
174
+ trackRecommendationClick(product: Product): Promise<void>;
175
+ /**
176
+ * In order to receive the messageInbox content, you can use this method.
177
+ *
178
+ * @since 1.0.0
179
+ */
180
+ fetchMessages(): Promise<any>;
181
+ /**
182
+ * To label a message with a tag, you can use this method. (for example: "READ", "SEEN" etc)
183
+ *
184
+ * @since 1.0.0
185
+ */
186
+ addTag(options: InboxTag): Promise<void>;
187
+ /**
188
+ * To remove a label from a message, you can use this method.
189
+ *
190
+ * @since 1.0.0
191
+ */
192
+ removeTag(options: InboxTag): Promise<void>;
193
+ /**
194
+ * Provides what is the actual `applicationCode` set in the SDK.
195
+ *
196
+ * @since 1.0.0
197
+ */
198
+ getApplicationCode(): Promise<ApplicationCode>;
199
+ /**
200
+ * If any error occurs during the change process, the Mobile Engage feature will be turned off.
201
+ *
202
+ * @since 1.0.0
203
+ */
204
+ setApplicationCode(options: ApplicationCode): Promise<void>;
205
+ /**
206
+ * Provides what is the actual `merchantId` set in the SDK.
207
+ *
208
+ * @since 1.0.0
209
+ */
210
+ getMerchantId(): Promise<MerchantId>;
211
+ /**
212
+ * Change the actual `merchantId` that is set in the SDK.
213
+ *
214
+ * @since 1.0.0
215
+ */
216
+ setMerchantId(options: MerchantId): Promise<void>;
217
+ /**
218
+ * Provides what is the actual `contactFieldId` set in the SDK.
219
+ *
220
+ * @since 1.0.0
221
+ */
222
+ getContactFieldId(): Promise<ContactFieldId>;
223
+ /**
224
+ * Provides what is the actual `hardwareId` set in the SDK.
225
+ *
226
+ * @since 1.0.0
227
+ */
228
+ getHardwareId(): Promise<{
229
+ hardwareId: string;
230
+ }>;
231
+ /**
232
+ * Provides what is the actual language of the application.
233
+ *
234
+ * @since 1.0.0
235
+ */
236
+ getLanguageCode(): Promise<{
237
+ languageCode: string;
238
+ }>;
239
+ /**
240
+ * Provides the actual `sdkVersion`
241
+ *
242
+ * @since 1.0.0
243
+ */
244
+ getSdkVersion(): Promise<{
245
+ sdkVersion: string;
246
+ }>;
247
+ /**
248
+ * Called when a event is received
249
+ *
250
+ * @since 1.0.0
251
+ */
252
+ addListener(eventName: 'pushMessageEvent', listenerFunc: (event: PushMessageEvent) => void): Promise<PluginListenerHandle> & PluginListenerHandle;
253
+ /**
254
+ * Called when a silent push message is received
255
+ *
256
+ * @since 1.0.0
257
+ */
258
+ addListener(eventName: 'silentPushMessageInformation', listenerFunc: (information: SilentPushMessageInformation) => void): Promise<PluginListenerHandle> & PluginListenerHandle;
259
+ /**
260
+ * Remove all native listeners for this plugin.
261
+ *
262
+ * @since 1.0.0
263
+ */
264
+ removeAllListeners(): Promise<void>;
265
+ }
266
+ export {};
@@ -0,0 +1,3 @@
1
+ /// <reference types="@capacitor/cli" />
2
+ export {};
3
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,wCAAwC"}
@@ -0,0 +1,4 @@
1
+ import type { EmarsysPlugin } from './definitions';
2
+ declare const Emarsys: EmarsysPlugin;
3
+ export * from './definitions';
4
+ export { Emarsys };
@@ -0,0 +1,5 @@
1
+ import { registerPlugin } from '@capacitor/core';
2
+ const Emarsys = registerPlugin('Emarsys');
3
+ export * from './definitions';
4
+ export { Emarsys };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,OAAO,GAAG,cAAc,CAAgB,SAAS,CAAC,CAAC;AAEzD,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,25 @@
1
+ import type { PermissionState } from '@capacitor/core';
2
+ export interface PermissionStatus {
3
+ /**
4
+ * @since 1.0.0
5
+ */
6
+ receive: PermissionState;
7
+ }
8
+ export interface ContactFieldId {
9
+ /**
10
+ * @since 1.0.0
11
+ */
12
+ contactFieldId: number;
13
+ }
14
+ export interface SetContactOptions extends ContactFieldId {
15
+ /**
16
+ * @since 1.0.0
17
+ */
18
+ contactFieldValue: string;
19
+ }
20
+ export interface SetAuthenticatedContactOptions extends ContactFieldId {
21
+ /**
22
+ * @since 1.0.0
23
+ */
24
+ openIdToken: string;
25
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/interfaces/base.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ export interface ApplicationCode {
2
+ /**
3
+ * @since 1.0.0
4
+ */
5
+ applicationCode: string;
6
+ }
7
+ export interface MerchantId {
8
+ /**
9
+ * @since 1.0.0
10
+ */
11
+ merchantId: string;
12
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/interfaces/config.ts"],"names":[],"mappings":""}
@@ -0,0 +1,108 @@
1
+ interface InboxMessageBaseAction {
2
+ /**
3
+ * @since 1.0.0
4
+ */
5
+ id: string;
6
+ /**
7
+ * @since 1.0.0
8
+ */
9
+ title: string;
10
+ /**
11
+ * @since 1.0.0
12
+ */
13
+ type: string;
14
+ }
15
+ export interface InboxMessageAppAction extends InboxMessageBaseAction {
16
+ /**
17
+ * @since 1.0.0
18
+ */
19
+ name: string;
20
+ /**
21
+ * @since 1.0.0
22
+ */
23
+ payload: {
24
+ [key: string]: any;
25
+ };
26
+ }
27
+ export interface InboxMessageCustomAction extends InboxMessageBaseAction {
28
+ /**
29
+ * @since 1.0.0
30
+ */
31
+ name: string;
32
+ /**
33
+ * @since 1.0.0
34
+ */
35
+ payload: {
36
+ [key: string]: any;
37
+ };
38
+ }
39
+ export interface InboxMessageExternalUrlAction extends InboxMessageBaseAction {
40
+ /**
41
+ * @since 1.0.0
42
+ */
43
+ url: string;
44
+ }
45
+ export declare type InboxMessageAction = InboxMessageAppAction | InboxMessageCustomAction | InboxMessageExternalUrlAction;
46
+ export interface InboxMessage {
47
+ /**
48
+ * @since 1.0.0
49
+ */
50
+ id: string;
51
+ /**
52
+ * @since 1.0.0
53
+ */
54
+ campaignId: string;
55
+ /**
56
+ * @since 1.0.0
57
+ */
58
+ collapseId?: string;
59
+ /**
60
+ * @since 1.0.0
61
+ */
62
+ title: string;
63
+ /**
64
+ * @since 1.0.0
65
+ */
66
+ body: string;
67
+ /**
68
+ * @since 1.0.0
69
+ */
70
+ imageUrl?: string;
71
+ /**
72
+ * @since 1.0.0
73
+ */
74
+ receivedAt: number;
75
+ /**
76
+ * @since 1.0.0
77
+ */
78
+ updatedAt?: number;
79
+ /**
80
+ * @since 1.0.0
81
+ */
82
+ expiresAt?: number;
83
+ /**
84
+ * @since 1.0.0
85
+ */
86
+ tags: string[];
87
+ /**
88
+ * @since 1.0.0
89
+ */
90
+ properties: {
91
+ [key: string]: string;
92
+ };
93
+ /**
94
+ * @since 1.0.0
95
+ */
96
+ actions: InboxMessageAction[];
97
+ }
98
+ export interface InboxTag {
99
+ /**
100
+ * @since 1.0.0
101
+ */
102
+ tag: string;
103
+ /**
104
+ * @since 1.0.0
105
+ */
106
+ messageId: string;
107
+ }
108
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=inbox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inbox.js","sourceRoot":"","sources":["../../../src/interfaces/inbox.ts"],"names":[],"mappings":""}