@selligent-marketing-cloud/selligent-react-native 3.5.1 → 3.7.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/README.md CHANGED
@@ -10,7 +10,7 @@ This module supports the following SDK and tools:
10
10
 
11
11
  | SDK | Version |
12
12
  | ------------------------------------------------------------------------------ | ------- |
13
- | [Android SDK](https://github.com/SelligentMarketingCloud/MobileSDK-Android) | 4.4.0 |
13
+ | [Android SDK](https://github.com/SelligentMarketingCloud/MobileSDK-Android) | 4.4.1 |
14
14
  | [iOS SDK](https://github.com/SelligentMarketingCloud/MobileSDK-iOS) | 3.8.1 |
15
15
  | ReactNative | 0.72.4 |
16
16
  | Expo SDK | 49 |
@@ -186,6 +186,8 @@ This module supports the following SDK and tools:
186
186
 
187
187
  ```objective-c
188
188
  @import RNSelligentMobileSDK;
189
+ // OR
190
+ // #import <RNSelligentMobileSDK/RNSelligentMobileSDK-Swift.h>
189
191
 
190
192
  // You can alternatively specify a different file name (without the extension) from where to load the Marigold Engage configs (defaults to 'selligent')
191
193
  // if (!launchOptions) {
@@ -193,6 +195,7 @@ This module supports the following SDK and tools:
193
195
  // }
194
196
  // [launchOptions setValue:@"alternativeFileName" forKey:@"RN_SELLIGENT_JSON"];
195
197
 
198
+ // At the end of application:didFinishLaunchingWithOptions:
196
199
  [RNSelligent configureWithLaunchOptions:launchOptions];
197
200
  ```
198
201
 
@@ -214,6 +217,12 @@ This module supports the following SDK and tools:
214
217
  // OR
215
218
  // #import <RNSelligentMobileSDK/RNSelligentMobileSDK-Swift.h>
216
219
 
220
+ // You can alternatively specify a different file name (without the extension) from where to load the Marigold Engage configs (defaults to 'selligent')
221
+ // if (!launchOptions) {
222
+ // launchOptions = [NSMutableDictionary new];
223
+ // }
224
+ // [launchOptions setValue:@"alternativeFileName" forKey:@"RN_SELLIGENT_JSON"];
225
+
217
226
  // At the end of application:didFinishLaunchingWithOptions:
218
227
  [RNSelligent configureWithLaunchOptions:launchOptions];
219
228
  ```
@@ -55,7 +55,6 @@ repositories {
55
55
  url "$projectDir/../node_modules/react-native/android"
56
56
  }
57
57
  google()
58
- maven { url 'https://developer.huawei.com/repo/' }
59
58
  }
60
59
 
61
60
  dependencies {
@@ -63,7 +62,7 @@ dependencies {
63
62
  exclude group:'com.facebook.fbjni'
64
63
  exclude group:'com.facebook.yoga'
65
64
  }
66
- implementation 'com.selligent.sdk:selligent_mobile_sdk:4.4.0'
65
+ implementation 'com.selligent.sdk:selligent_mobile_sdk:4.4.1'
67
66
  implementation 'com.google.code.gson:gson:2.9.0'
68
67
  implementation 'com.google.firebase:firebase-messaging:23.2.1'
69
68
  implementation 'androidx.work:work-runtime:2.8.1'
@@ -3,16 +3,12 @@ package com.selligent;
3
3
  import android.content.BroadcastReceiver;
4
4
  import android.content.Context;
5
5
  import android.content.Intent;
6
- import android.text.TextUtils;
7
6
 
8
- import com.facebook.react.bridge.WritableMap;
9
7
  import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter;
10
8
  import com.selligent.rnmobilesdk.BroadcastDataFactory;
11
9
 
12
-
13
10
  class EventReceiver extends BroadcastReceiver {
14
-
15
- private RCTDeviceEventEmitter rctDeviceEventEmitter;
11
+ private final RCTDeviceEventEmitter rctDeviceEventEmitter;
16
12
 
17
13
  public EventReceiver(RCTDeviceEventEmitter rctDeviceEventEmitter) {
18
14
  this.rctDeviceEventEmitter = rctDeviceEventEmitter;
@@ -20,13 +16,13 @@ class EventReceiver extends BroadcastReceiver {
20
16
 
21
17
  @Override
22
18
  public void onReceive(Context context, Intent intent) {
23
- final String smBroadcastEventType = intent.getAction();
24
- if (TextUtils.isEmpty(smBroadcastEventType)) return;
19
+ String smBroadcastEventType = intent.getAction();
25
20
 
26
- final WritableMap broadcastData = BroadcastDataFactory.getBroadcastData(smBroadcastEventType, intent);
27
- final String eventName = broadcastData.getString("broadcastEventType");
21
+ if (smBroadcastEventType == null || smBroadcastEventType.isEmpty()) return;
28
22
 
29
- rctDeviceEventEmitter.emit(eventName, broadcastData);
23
+ this.rctDeviceEventEmitter.emit(
24
+ smBroadcastEventType,
25
+ BroadcastDataFactory.getBroadcastData(smBroadcastEventType, intent)
26
+ );
30
27
  }
31
-
32
28
  }
@@ -0,0 +1,59 @@
1
+ package com.selligent;
2
+
3
+ import com.facebook.react.bridge.Arguments;
4
+ import com.facebook.react.bridge.WritableArray;
5
+ import com.facebook.react.bridge.WritableMap;
6
+
7
+ import java.util.List;
8
+ import java.util.Map;
9
+
10
+ final class RNHelpers {
11
+ private RNHelpers() { }
12
+
13
+ static WritableArray convertListToWritableArray(List<Map<String, Object>> list) {
14
+ WritableArray array = Arguments.createArray();
15
+
16
+ if (list.isEmpty()) { return array; }
17
+
18
+ for (Map<String, Object> map : list) {
19
+ array.pushMap(RNHelpers.convertMapToWritableMap(map));
20
+ }
21
+
22
+ return array;
23
+ }
24
+
25
+ static WritableMap convertMapToWritableMap(Map<String, Object> map) {
26
+ WritableMap writableMap = Arguments.createMap();
27
+
28
+ if (map.entrySet().isEmpty()) { return writableMap; }
29
+
30
+ for (Map.Entry<String, Object> entry : map.entrySet()) {
31
+ Object value = entry.getValue();
32
+ String key = entry.getKey();
33
+
34
+ if (value instanceof Map) {
35
+ writableMap.putMap(key, RNHelpers.convertMapToWritableMap((Map<String, Object>) value));
36
+ }
37
+ else if (value instanceof List) {
38
+ writableMap.putArray(key, RNHelpers.convertListToWritableArray((List<Map<String, Object>>) value));
39
+ }
40
+ else if (value instanceof Boolean) {
41
+ writableMap.putBoolean(key, (Boolean) value);
42
+ }
43
+ else if (value instanceof Integer) {
44
+ writableMap.putInt(key, (Integer) value);
45
+ }
46
+ else if (value instanceof Double) {
47
+ writableMap.putDouble(key, (Double) value);
48
+ }
49
+ else if (value instanceof String) {
50
+ writableMap.putString(key, (String) value);
51
+ }
52
+ else {
53
+ writableMap.putNull(key);
54
+ }
55
+ }
56
+
57
+ return writableMap;
58
+ }
59
+ }
@@ -1,19 +1,15 @@
1
-
2
1
  package com.selligent;
3
2
 
3
+ import android.annotation.SuppressLint;
4
4
  import android.app.Activity;
5
5
  import android.app.Application;
6
+ import android.content.Context;
6
7
  import android.content.Intent;
7
- import android.content.IntentFilter;
8
- import android.content.res.Resources;
9
8
 
9
+ import androidx.annotation.NonNull;
10
10
  import androidx.appcompat.app.AppCompatActivity;
11
- import androidx.lifecycle.Observer;
12
11
  import androidx.localbroadcastmanager.content.LocalBroadcastManager;
13
12
 
14
- import android.graphics.Color;
15
- import android.util.Log;
16
-
17
13
  import com.facebook.react.bridge.ActivityEventListener;
18
14
  import com.facebook.react.bridge.Callback;
19
15
  import com.facebook.react.bridge.LifecycleEventListener;
@@ -23,601 +19,259 @@ import com.facebook.react.bridge.ReactMethod;
23
19
  import com.facebook.react.bridge.ReadableArray;
24
20
  import com.facebook.react.bridge.ReadableMap;
25
21
  import com.facebook.react.bridge.ReadableType;
26
- import com.facebook.react.bridge.WritableArray;
27
- import com.facebook.react.bridge.WritableMap;
28
- import com.facebook.react.bridge.WritableNativeArray;
29
- import com.facebook.react.bridge.WritableNativeMap;
30
22
  import com.facebook.react.modules.core.DeviceEventManagerModule;
31
- import com.google.gson.Gson;
32
- import com.google.gson.reflect.TypeToken;
33
- import com.selligent.rnmobilesdk.BroadcastEventType;
34
- import com.selligent.rnmobilesdk.ButtonBroadcastEventDataParser;
35
- import com.selligent.rnmobilesdk.DeviceIdBroadcastEventDataParser;
36
- import com.selligent.rnmobilesdk.Event;
37
- import com.selligent.rnmobilesdk.GCMTokenBroadcastEventDataParser;
38
- import com.selligent.rnmobilesdk.InAppMessageBroadcastEventDataParser;
39
- import com.selligent.rnmobilesdk.InAppMessageRefreshType;
40
- import com.selligent.rnmobilesdk.NotificationMessageBroadcastEventDataParser;
41
- import com.selligent.rnmobilesdk.RemoteMessageDisplayType;
42
- import com.selligent.rnmobilesdk.SMEventFactory;
43
- import com.selligent.rnmobilesdk.SMSettingsFactory;
44
- import com.selligent.rnmobilesdk.Settings;
45
- import com.selligent.sdk.SMCallback;
46
- import com.selligent.sdk.SMEvent;
23
+ import com.selligent.rnmobilesdk.Manager;
47
24
  import com.selligent.sdk.SMForegroundGcmBroadcastReceiver;
48
- import com.selligent.sdk.SMInAppMessage;
49
- import com.selligent.sdk.SMInAppRefreshType;
50
- import com.selligent.sdk.SMManager;
51
- import com.selligent.sdk.SMNotificationButton;
52
- import com.selligent.sdk.SMNotificationMessage;
53
- import com.selligent.sdk.SMObserverManager;
54
- import com.selligent.sdk.SMRemoteMessageDisplayType;
55
- import com.selligent.sdk.SMSettings;
56
25
 
57
- import java.util.HashMap;
26
+ import java.util.Map;
58
27
 
59
28
  public class RNSelligent extends ReactContextBaseJavaModule implements LifecycleEventListener, ActivityEventListener {
60
-
61
- private static final String RN_SELLIGENT_NAME = "RNSelligent";
62
29
  private final ReactApplicationContext reactContext;
63
- private final SMManager smManager;
30
+ private final Manager manager;
64
31
  EventReceiver eventReceiver;
65
32
  SMForegroundGcmBroadcastReceiver receiver;
66
- private static SMInAppRefreshType inAppMessageRefreshType;
67
-
68
- public static final String REACT_CLASS = "SelligentReactNative"; // for logging purposes
69
-
70
- boolean areObserverStarted = false;
71
33
 
72
- //region getter
73
- static SMManager getSMManager()
74
- {
75
- return SMManager.getInstance();
34
+ static Manager getManager() {
35
+ return Manager.getInstance();
76
36
  }
77
37
 
78
- static String getSelligentSettings()
79
- {
38
+ static String getSelligentSettings() {
80
39
  return BuildConfig.SELLIGENT_SETTINGS;
81
40
  }
82
41
 
83
- static Class<? extends Activity> getActivityClass(String notificationActivityName) throws Exception
84
- {
85
- return (Class<? extends Activity>) Class.forName(notificationActivityName);
86
- }
87
- //endregion
88
-
89
-
90
42
  public RNSelligent(ReactApplicationContext reactContext) {
91
43
  super(reactContext);
44
+
92
45
  this.reactContext = reactContext;
93
46
  reactContext.addLifecycleEventListener(this);
94
47
  reactContext.addActivityEventListener(this);
95
- this.smManager = getSMManager();
48
+ this.manager = RNSelligent.getManager();
96
49
  }
97
50
 
51
+ @NonNull
98
52
  @Override
99
53
  public String getName() {
100
- return RN_SELLIGENT_NAME;
54
+ return Manager.RN_SELLIGENT_NAME;
101
55
  }
102
56
 
103
57
  public static void configure(Application application) {
104
- try {
105
- final HashMap<String, Object> settingsHashMap = new Gson().fromJson(
106
- getSelligentSettings(), new TypeToken<HashMap<String, Object>>() {}.getType()
107
- );
108
- final Settings settings = Settings.fromHashMap(settingsHashMap);
109
- final SMSettings smSettings = SMSettingsFactory.getSMSettings(settings);
110
- final String notificationActivityName = settings.getActivityName();
111
-
112
- SMManager.NOTIFICATION_ACTIVITY = getActivityClass(notificationActivityName);
113
- inAppMessageRefreshType = settings.getInAppMessageRefreshType().getSmInAppRefreshType();
114
-
115
- final SMManager smManager = getSMManager();
116
- SMManager.DEBUG = BuildConfig.BUILD_TYPE.equals("debug") || settings.getEnableAndroidLogging();
117
- smManager.start(smSettings, application);
118
-
119
- final Resources resources = application.getResources();
120
-
121
- if (settings.getNotificationSmallIcon() != null && !settings.getNotificationSmallIcon().isEmpty()) {
122
- final int smallIconResourceId = resources.getIdentifier(settings.getNotificationSmallIcon(), "drawable", application.getPackageName());
123
- if(smallIconResourceId != 0) {
124
- smManager.setNotificationSmallIcon(smallIconResourceId);
125
- }
126
- }
127
-
128
- if (settings.getNotificationLargeIcon() != null && !settings.getNotificationLargeIcon().isEmpty()) {
129
- final int largeIconResourceId = resources.getIdentifier(settings.getNotificationLargeIcon(), "drawable", application.getPackageName());
130
- if (largeIconResourceId != 0) {
131
- smManager.setNotificationLargeIcon(largeIconResourceId);
132
- }
133
- }
134
-
135
- if (settings.getNotificationIconColor() != null && !settings.getNotificationIconColor().isEmpty()) {
136
- try {
137
- final int color = Color.parseColor(settings.getNotificationIconColor());
138
- smManager.setNotificationIconColor(color);
139
- } catch (IllegalArgumentException e) {
140
- Log.e(RN_SELLIGENT_NAME, "notificationIconColor must be a color hex string.");
141
- }
142
- }
143
-
144
- } catch (Exception e) {
145
- Log.e(RN_SELLIGENT_NAME, "SMManager start failed: an error occurred while setting the NotificationActivity", e);
146
- }
58
+ RNSelligent.getManager().configure(application, RNSelligent.getSelligentSettings(), BuildConfig.BUILD_TYPE.equals("debug"));
147
59
  }
148
60
 
149
- /* Our methods: */
150
-
151
61
  @ReactMethod
152
62
  public void getVersionLib(Callback successCallback) {
153
- final String versionLib = SMManager.VERSION_LIB;
154
- successCallback.invoke(versionLib);
63
+ successCallback.invoke(manager.getVersionLib());
155
64
  }
156
65
 
157
66
  @ReactMethod
158
67
  public void enableInAppMessages(ReadableMap enabled) {
159
- final String enabledProperty = "enabled";
160
- final ReadableType enabledType = enabled.getType(enabledProperty);
68
+ String enabledProperty = "enabled";
69
+ ReadableType enabledType = enabled.getType(enabledProperty);
161
70
 
162
71
  if (enabledType == ReadableType.Boolean) {
163
- enableInAppMessages(enabled.getBoolean(enabledProperty));
164
- }
165
- else if (enabledType == ReadableType.Number) {
166
- enableInAppMessages(enabled.getInt(enabledProperty));
72
+ this.manager.enableInAppMessages(enabled.getBoolean(enabledProperty));
167
73
  }
168
- }
169
-
170
- private void enableInAppMessages(boolean enable) {
171
- if (enable) {
172
- smManager.enableInAppMessages(inAppMessageRefreshType);
173
- } else {
174
- smManager.disableInAppMessages();
74
+ else if (enabledType == ReadableType.Number) {
75
+ this.manager.enableInAppMessages(enabled.getInt(enabledProperty));
175
76
  }
176
77
  }
177
78
 
178
- private void enableInAppMessages(Integer inAppMessageRefreshTypeIndex) {
179
- final InAppMessageRefreshType refreshType = InAppMessageRefreshType.valueOf(inAppMessageRefreshTypeIndex);
180
- final SMInAppRefreshType smInAppRefreshType = refreshType.getSmInAppRefreshType();
181
-
182
- smManager.enableInAppMessages(smInAppRefreshType);
183
- }
184
-
185
79
  @ReactMethod
186
80
  public void areInAppMessagesEnabled(Callback successCallback) {
187
- final Boolean areInAppMessagesEnabled = smManager.areInAppMessagesEnabled();
188
- successCallback.invoke(areInAppMessagesEnabled);
81
+ successCallback.invoke(this.manager.areInAppMessagesEnabled());
189
82
  }
190
83
 
191
84
  @ReactMethod
192
85
  public void displayMessage(String messageId) {
193
- final Activity currentActivity = getCurrentActivity();
194
-
195
- if (currentActivity != null) {
196
- smManager.displayInAppMessage(messageId, currentActivity);
197
- }
86
+ this.manager.displayMessage(messageId, this.getCurrentActivity());
198
87
  }
199
88
 
200
89
  @ReactMethod
201
- public void getInAppMessages(final Callback successCallback) {
202
- smManager.getInAppMessages(inAppMessages -> {
203
- WritableArray resultingMessagesArray = new WritableNativeArray();
204
-
205
- for (SMInAppMessage message : inAppMessages) {
206
- WritableMap messageMap = new WritableNativeMap();
207
-
208
- messageMap.putString("id", message.id);
209
- messageMap.putString("title", message.title);
210
- messageMap.putString("body", message.getBody());
211
- messageMap.putDouble("creationDate", message.getCreationDate());
212
- messageMap.putDouble("expirationDate", message.getExpirationDate());
213
- messageMap.putDouble("receptionDate", message.getReceptionDate());
214
- messageMap.putBoolean("hasBeenSeen", message.hasBeenSeen());
215
- messageMap.putDouble("type", message.getType().getValue());
216
-
217
- WritableArray buttonsArray = new WritableNativeArray();
218
-
219
- SMNotificationButton[] buttons = message.getButtons();
220
-
221
- if(buttons != null) {
222
- for(SMNotificationButton button : buttons) {
223
- WritableMap buttonMap = new WritableNativeMap();
224
-
225
- buttonMap.putString("id", button.id);
226
- buttonMap.putString("value", button.value);
227
- buttonMap.putString("label", button.label);
228
- buttonMap.putInt("type", button.type);
229
-
230
- buttonsArray.pushMap(buttonMap);
231
- }
232
- }
233
-
234
- messageMap.putArray("buttons", buttonsArray);
235
-
236
- resultingMessagesArray.pushMap(messageMap);
237
- }
238
-
239
- successCallback.invoke(resultingMessagesArray);
240
- });
90
+ public void getInAppMessages(Callback successCallback) {
91
+ this.manager.getInAppMessages(list ->
92
+ successCallback.invoke(RNHelpers.convertListToWritableArray(list))
93
+ );
241
94
  }
242
95
 
243
96
  @ReactMethod
244
- public void setInAppMessageAsSeen(final String messageId, final Callback successCallback, final Callback errorCallback) {
245
- smManager.getInAppMessages(inAppMessages ->
246
- {
247
- for(SMInAppMessage message : inAppMessages)
248
- {
249
- if(message.id.equals(messageId))
250
- {
251
- smManager.setInAppMessageAsSeen(message);
252
- successCallback.invoke();
253
- return;
254
- }
255
- }
256
- errorCallback.invoke(String.format("No message with id %s found", messageId));
257
- });
97
+ public void setInAppMessageAsSeen(String messageId, Callback successCallback, Callback errorCallback) {
98
+ this.manager.setInAppMessageAsSeen(messageId, error ->
99
+ processErrorStringToCallback(error, successCallback, errorCallback)
100
+ );
258
101
  }
259
102
 
260
103
  @ReactMethod
261
- public void setInAppMessageAsUnseen(final String messageId, final Callback successCallback, final Callback errorCallback)
262
- {
263
- smManager.getInAppMessages(inAppMessages ->
264
- {
265
- for(SMInAppMessage message : inAppMessages)
266
- {
267
- if(message.id.equals(messageId))
268
- {
269
- smManager.setInAppMessageAsUnseen(message);
270
- successCallback.invoke();
271
- return;
272
- }
273
- }
274
- errorCallback.invoke(String.format("No message with id %s found", messageId));
275
- });
104
+ public void setInAppMessageAsUnseen(String messageId, Callback successCallback, Callback errorCallback) {
105
+ this.manager.setInAppMessageAsUnseen(messageId, error ->
106
+ processErrorStringToCallback(error, successCallback, errorCallback)
107
+ );
276
108
  }
277
109
 
278
110
  @ReactMethod
279
- public void setInAppMessageAsDeleted(final String messageId, final Callback successCallback, final Callback errorCallback)
280
- {
281
- smManager.getInAppMessages(inAppMessages ->
282
- {
283
- for(SMInAppMessage message : inAppMessages)
284
- {
285
- if(message.id.equals(messageId))
286
- {
287
- smManager.deleteInAppMessage(messageId);
288
- successCallback.invoke();
289
- return;
290
- }
291
- }
292
- errorCallback.invoke(String.format("No message with id %s found", messageId));
293
- });
111
+ public void setInAppMessageAsDeleted(String messageId, Callback successCallback, Callback errorCallback) {
112
+ this.manager.setInAppMessageAsDeleted(messageId, error ->
113
+ processErrorStringToCallback(error, successCallback, errorCallback)
114
+ );
294
115
  }
295
116
 
296
117
  @ReactMethod
297
- public void executeButtonAction(final String buttonId, final String messageId, final Callback successCallback, final Callback errorCallback) {
298
- smManager.getInAppMessages(inAppMessages -> {
299
- for(SMInAppMessage message : inAppMessages) {
300
- if(message.id.equals(messageId))
301
- {
302
- SMNotificationButton[] buttons = message.getButtons();
303
- if (buttons != null)
304
- {
305
- for (SMNotificationButton button : message.getButtons())
306
- {
307
- if (button.id.equals(buttonId))
308
- {
309
- smManager.executeButtonAction(reactContext, button, message);
310
- successCallback.invoke();
311
- return;
312
- }
313
- }
314
- }
315
- errorCallback.invoke("buttonId does not exist in message.");
316
- return;
317
- }
318
- }
319
- errorCallback.invoke(String.format("No message with id %s found", messageId));
320
- });
118
+ public void executeButtonAction(String buttonId, String messageId, Callback successCallback, Callback errorCallback) {
119
+ this.manager.executeButtonAction(this.reactContext, buttonId, messageId, error ->
120
+ processErrorStringToCallback(error, successCallback, errorCallback)
121
+ );
321
122
  }
322
123
 
323
124
  @ReactMethod
324
125
  public void setDebug(Boolean enable) {
325
- SMManager.DEBUG = enable;
126
+ Manager.setDebug(enable);
326
127
  }
327
128
 
328
129
  @ReactMethod
329
- public void sendEvent(ReadableMap eventMap, final Callback successCallback, final Callback errorCallback) {
330
- final Event event = Event.fromHashMap(eventMap.toHashMap());
331
- final SMEvent smEvent = SMEventFactory.getSMEvent(event, new SMCallback() {
332
- @Override
333
- public void onSuccess(String message) {
334
- successCallback.invoke(message);
335
- }
336
-
337
- @Override
338
- public void onError(int responseCode, Exception e) {
339
- errorCallback.invoke(responseCode);
340
- }
341
- });
342
-
343
- smManager.sendSMEvent(smEvent);
130
+ public void sendEvent(ReadableMap eventMap, Callback successCallback, Callback errorCallback) {
131
+ this.manager.sendEvent(eventMap.toHashMap(), successCallback::invoke, errorCallback::invoke);
344
132
  }
345
133
 
346
134
  @ReactMethod
347
135
  public void getDeviceId(Callback successCallback) {
348
- final String deviceId = smManager.getDeviceId();
349
- successCallback.invoke(deviceId);
136
+ successCallback.invoke(this.manager.getDeviceId());
350
137
  }
351
138
 
352
139
  @ReactMethod
353
140
  public void enableNotifications(Boolean enable) {
354
- if (Boolean.TRUE.equals(enable)) {
355
- smManager.enableNotifications();
356
- } else {
357
- smManager.disableNotifications();
358
- }
141
+ this.manager.enableNotifications(enable);
359
142
  }
360
143
 
361
144
  public static void enableNotifications() {
362
- SMManager.getInstance().enableNotifications();
145
+ RNSelligent.getManager().enableNotifications(true);
363
146
  }
364
147
 
365
148
  @ReactMethod
149
+ @SuppressWarnings("unused")
366
150
  public void displayLastReceivedRemotePushNotification(String templateId) {
367
- final Activity currentActivity = getCurrentActivity();
368
-
369
- if (currentActivity != null) {
370
- smManager.displayLastReceivedNotificationContent(currentActivity);
371
- }
151
+ this.manager.displayLastReceivedRemotePushNotification(this.getCurrentActivity());
372
152
  }
373
153
 
374
154
  @ReactMethod
375
- public void displayLastReceivedNotification()
376
- {
377
- smManager.displayLastReceivedNotification();
155
+ public void displayLastReceivedNotification() {
156
+ this.manager.displayLastReceivedNotification();
378
157
  }
379
158
 
380
159
  @ReactMethod
381
160
  public void getLastRemotePushNotification(Callback successCallback) {
382
- final SMNotificationMessage notification = smManager.retrieveLastReceivedNotificationContent();
383
-
384
- WritableMap resultingNotificationMap = new WritableNativeMap();
385
-
386
- if (notification != null) {
387
- resultingNotificationMap.putString("id", notification.getId());
388
- resultingNotificationMap.putString("title", notification.getNotificationTitle());
389
- }
390
-
391
- successCallback.invoke(resultingNotificationMap);
161
+ successCallback.invoke(
162
+ RNHelpers.convertMapToWritableMap(this.manager.getLastRemotePushNotification())
163
+ );
392
164
  }
393
165
 
394
166
  @ReactMethod
395
167
  public void setNotificationSmallIcon(String iconName) {
396
- final int resourceId = processNotificationIcon(iconName);
397
- smManager.setNotificationSmallIcon(resourceId);
168
+ this.manager.setNotificationSmallIcon(this.reactContext, iconName);
398
169
  }
399
170
 
400
171
  @ReactMethod
401
172
  public void setNotificationLargeIcon(String iconName) {
402
- final int resourceId = processNotificationIcon(iconName);
403
-
404
- smManager.setNotificationLargeIcon(resourceId);
405
- }
406
-
407
- private int processNotificationIcon(String iconName) {
408
- final Resources resources = reactContext.getResources();
409
- final int resourceId = resources.getIdentifier(iconName, "drawable", reactContext.getPackageName());
410
-
411
- if (resourceId == 0) {
412
- throw new IllegalArgumentException("Could not find a drawable with the name " + iconName);
413
- }
414
-
415
- return resourceId;
173
+ this.manager.setNotificationLargeIcon(this.reactContext, iconName);
416
174
  }
417
175
 
418
176
  @ReactMethod
419
- public void setNotificationIconColor(final String colorString, final Callback successCallback, final Callback errorCallback) {
420
- try {
421
- final int color = Color.parseColor(colorString);
422
- smManager.setNotificationIconColor(color);
423
- successCallback.invoke();
424
- } catch (IllegalArgumentException e) {
425
- errorCallback.invoke("color must be a color hex string.");
426
- }
177
+ public void setNotificationIconColor(String colorString, Callback successCallback, Callback errorCallback) {
178
+ processErrorStringToCallback(
179
+ this.manager.setNotificationIconColor(colorString),
180
+ successCallback,
181
+ errorCallback
182
+ );
427
183
  }
428
184
 
429
185
  @ReactMethod
430
- public void setNotificationActivity(final String activityName, final Callback successCallback, final Callback errorCallback) {
431
- try {
432
- SMManager.NOTIFICATION_ACTIVITY = (Class<? extends Activity>) Class.forName(activityName);
433
- successCallback.invoke();
434
- } catch (ClassNotFoundException e) {
435
- errorCallback.invoke(String.format("Activity %s not found.", activityName));
436
- }
186
+ public void setNotificationActivity(String activityName, Callback successCallback, Callback errorCallback) {
187
+ processErrorStringToCallback(
188
+ Manager.setNotificationActivity(activityName),
189
+ successCallback,
190
+ errorCallback
191
+ );
437
192
  }
438
193
 
439
194
  @ReactMethod
440
195
  public void getGCMToken(Callback callback) {
441
- final String gcmToken = smManager.getGCMToken();
442
- callback.invoke(gcmToken);
196
+ callback.invoke(this.manager.getGCMToken());
443
197
  }
444
198
 
445
199
  @ReactMethod
446
200
  public void getRemoteMessagesDisplayType(Callback successCallback) {
447
- final SMRemoteMessageDisplayType smRemoteMessageDisplayType = smManager.getRemoteMessagesDisplayType();
448
- final RemoteMessageDisplayType remoteMessageDisplayType = RemoteMessageDisplayType.valueOf(smRemoteMessageDisplayType);
449
- final Integer resultingRemoteMessageDisplayTypeIndex = remoteMessageDisplayType.getIndex();
450
-
451
- successCallback.invoke(resultingRemoteMessageDisplayTypeIndex);
201
+ successCallback.invoke(this.manager.getRemoteMessagesDisplayType());
452
202
  }
453
203
 
454
204
  @ReactMethod
455
205
  public void areNotificationsEnabled(Callback successCallback) {
456
- final Boolean areNotificationsEnabled = smManager.areNotificationEnabled();
457
-
458
- successCallback.invoke(areNotificationsEnabled);
206
+ successCallback.invoke(this.manager.areNotificationsEnabled());
459
207
  }
460
208
 
461
209
  @ReactMethod
462
210
  public void subscribeToEvents(ReadableArray customEvents) {
463
- final Activity currentActivity = getCurrentActivity();
464
-
465
- if (currentActivity != null)
466
- {
467
- if (currentActivity instanceof AppCompatActivity)
468
- {
469
- AppCompatActivity thisActivity = (AppCompatActivity)currentActivity;
470
- DeviceEventManagerModule.RCTDeviceEventEmitter rctDeviceEventEmitter = reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class);
471
-
472
- thisActivity.runOnUiThread(() -> {
473
- if (!areObserverStarted)
474
- {
475
- Log.d(RN_SELLIGENT_NAME, "Instantiating the observers on the UI thread");
476
- SMObserverManager observerManager = smManager.getObserverManager();
477
-
478
- // Token received
479
- final Observer<String> tokenObserver = token -> {
480
- String eventName = BroadcastEventType.ReceivedGCMToken.getBroadcastEventType();
481
- GCMTokenBroadcastEventDataParser broadcastEventDataParser = new GCMTokenBroadcastEventDataParser();
482
- final WritableMap data = broadcastEventDataParser.wrap(token);
483
- rctDeviceEventEmitter.emit(eventName, getBroadcastData(eventName, data));
484
- };
485
- observerManager.observeToken(thisActivity, tokenObserver);
486
-
487
- // Device id received
488
- final Observer<String> deviceIdObserver = deviceId -> {
489
- String eventName = BroadcastEventType.ReceivedDeviceId.getBroadcastEventType();
490
- DeviceIdBroadcastEventDataParser broadcastEventDataParser = new DeviceIdBroadcastEventDataParser();
491
- final WritableMap data = broadcastEventDataParser.wrap(deviceId);
492
- rctDeviceEventEmitter.emit(eventName, getBroadcastData(eventName, data));
493
- };
494
- observerManager.observeDeviceId(thisActivity, deviceIdObserver);
495
-
496
- // InApp messages received
497
- final Observer<SMInAppMessage[]> inAppMessageObserver = inAppMessages -> {
498
- if (inAppMessages != null)
499
- {
500
- String eventName = BroadcastEventType.ReceivedInAppMessage.getBroadcastEventType();
501
- InAppMessageBroadcastEventDataParser broadcastEventDataParser = new InAppMessageBroadcastEventDataParser();
502
- final WritableMap data = broadcastEventDataParser.wrap(inAppMessages);
503
- rctDeviceEventEmitter.emit(eventName, getBroadcastData(eventName, data));
504
- }
505
- };
506
- observerManager.observeInAppMessages(thisActivity, inAppMessageObserver);
507
-
508
- // Button clicked
509
- final Observer<SMNotificationButton> clickedButtonObserver = button -> {
510
- if (button != null)
511
- {
512
- String eventName = BroadcastEventType.ButtonClicked.getBroadcastEventType();
513
- ButtonBroadcastEventDataParser broadcastEventDataParser = new ButtonBroadcastEventDataParser();
514
- final WritableMap data = broadcastEventDataParser.wrap(button);
515
- rctDeviceEventEmitter.emit(eventName, getBroadcastData(eventName, data));
516
- }
517
- };
518
- observerManager.observeClickedButton(thisActivity, clickedButtonObserver);
519
-
520
- // Message dismissed
521
- final Observer<Void> dismissedMessageObserver = object -> {
522
- String eventName = BroadcastEventType.WillDismissNotification.getBroadcastEventType();
523
- rctDeviceEventEmitter.emit(eventName, getBroadcastData(eventName, null));
524
- };
525
- observerManager.observeDismissedMessage(thisActivity, dismissedMessageObserver);
526
-
527
- // Message displayed
528
- final Observer<Void> displayedMessageObserver = object -> {
529
- String eventName = BroadcastEventType.WillDisplayNotification.getBroadcastEventType();
530
- rctDeviceEventEmitter.emit(eventName, getBroadcastData(eventName, null));
531
- };
532
- observerManager.observeDisplayedMessage(thisActivity, displayedMessageObserver);
533
-
534
- // Push received
535
- final Observer<SMNotificationMessage> pushReceivedObserver = notificationMessage -> {
536
- if (notificationMessage != null)
537
- {
538
- String eventName = BroadcastEventType.ReceivedNotification.getBroadcastEventType();
539
- NotificationMessageBroadcastEventDataParser broadcastEventDataParser = new NotificationMessageBroadcastEventDataParser();
540
- final WritableMap data = broadcastEventDataParser.wrap(notificationMessage);
541
- rctDeviceEventEmitter.emit(eventName, getBroadcastData(eventName, data));
542
- }
543
- };
544
- observerManager.observePushReceived(thisActivity, pushReceivedObserver);
545
-
546
- // Custom events
547
- final Observer<String> customEventObserver = event -> rctDeviceEventEmitter.emit(BroadcastEventType.TriggeredCustomEvent.getBroadcastEventType(), getBroadcastData(event, null));
548
- observerManager.observeEvent(thisActivity, customEventObserver);
549
-
550
- areObserverStarted = true;
551
- }
552
- else
553
- {
554
- Log.d(RN_SELLIGENT_NAME, "Observers already instantiated");
555
- }
556
- });
557
- }
558
- else
559
- {
560
- final LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(currentActivity);
561
-
562
- if (eventReceiver == null) {
563
- eventReceiver = new EventReceiver(reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class));
564
- } else {
565
- localBroadcastManager.unregisterReceiver(eventReceiver);
566
- }
567
-
568
- final IntentFilter filter = new IntentFilter();
569
- filter.addAction(SMManager.BROADCAST_EVENT_RECEIVED_IN_APP_MESSAGE);
570
- filter.addAction(SMManager.BROADCAST_EVENT_WILL_DISPLAY_NOTIFICATION);
571
- filter.addAction(SMManager.BROADCAST_EVENT_WILL_DISMISS_NOTIFICATION);
572
- filter.addAction(SMManager.BROADCAST_EVENT_BUTTON_CLICKED);
573
- filter.addAction(SMManager.BROADCAST_EVENT_RECEIVED_GCM_TOKEN);
574
-
575
- for (int i = 0; i < customEvents.size(); i++) {
576
- filter.addAction(customEvents.getString(i));
577
- }
578
-
579
- localBroadcastManager.registerReceiver(eventReceiver, filter);
580
- }
211
+ Activity currentActivity = this.getCurrentActivity();
212
+
213
+ if (currentActivity == null) { return; }
214
+
215
+ if (currentActivity instanceof AppCompatActivity) {
216
+ AppCompatActivity activity = (AppCompatActivity)currentActivity;
217
+
218
+ activity.runOnUiThread(() ->
219
+ this.manager.initializeObservers(activity, this::broadcastEvent)
220
+ );
221
+
222
+ return;
581
223
  }
582
- }
583
224
 
584
- WritableMap getBroadcastData(String eventName, WritableMap data)
585
- {
586
- final WritableMap broadcastData = new WritableNativeMap();
225
+ LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(currentActivity);
587
226
 
588
- broadcastData.putString("broadcastEventType", eventName);
589
- broadcastData.putMap("data", data);
227
+ if (this.eventReceiver == null) {
228
+ this.eventReceiver = new EventReceiver(
229
+ reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class
230
+ ));
231
+ }
232
+ else {
233
+ localBroadcastManager.unregisterReceiver(this.eventReceiver);
234
+ }
590
235
 
591
- return broadcastData;
236
+ localBroadcastManager.registerReceiver(
237
+ this.eventReceiver,
238
+ Manager.eventsIntentFilter(customEvents.toArrayList())
239
+ );
592
240
  }
593
241
 
594
242
  @ReactMethod
595
243
  public void setFirebaseToken(String token) {
596
- smManager.setFirebaseToken(token);
244
+ this.manager.setFirebaseToken(token);
597
245
  }
598
246
 
247
+ @SuppressLint("UnspecifiedRegisterReceiverFlag")
599
248
  @Override
600
249
  public void onHostResume() {
601
- final Activity currentActivity = getCurrentActivity();
250
+ Activity currentActivity = this.getCurrentActivity();
602
251
 
603
- if (currentActivity != null) {
604
- if (receiver == null)
605
- {
606
- receiver = new SMForegroundGcmBroadcastReceiver(currentActivity);
607
- }
608
- currentActivity.registerReceiver(receiver, receiver.getIntentFilter());
252
+ if (currentActivity == null) { return; }
253
+
254
+ if (this.receiver == null) {
255
+ this.receiver = new SMForegroundGcmBroadcastReceiver(currentActivity);
256
+ }
609
257
 
610
- smManager.checkAndDisplayMessage(currentActivity.getIntent(), currentActivity);
258
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) {
259
+ currentActivity.registerReceiver(this.receiver, this.receiver.getIntentFilter(), Context.RECEIVER_NOT_EXPORTED);
611
260
  }
261
+ else {
262
+ currentActivity.registerReceiver(this.receiver, this.receiver.getIntentFilter());
263
+ }
264
+
265
+ this.manager.checkAndDisplayMessage(currentActivity.getIntent(), currentActivity, this::broadcastEvent);
612
266
  }
613
267
 
614
268
  @Override
615
269
  public void onHostPause() {
616
- final Activity currentActivity = getCurrentActivity();
270
+ Activity currentActivity = this.getCurrentActivity();
617
271
 
618
- if (currentActivity != null) {
619
- currentActivity.unregisterReceiver(receiver);
620
- }
272
+ if (currentActivity == null) { return; }
273
+
274
+ currentActivity.unregisterReceiver(this.receiver);
621
275
  }
622
276
 
623
277
  @Override
@@ -625,14 +279,30 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
625
279
 
626
280
  @Override
627
281
  public void onNewIntent(Intent intent) {
628
- final Activity currentActivity = getCurrentActivity();
282
+ Activity currentActivity = this.getCurrentActivity();
629
283
 
630
- if (currentActivity != null) {
631
- currentActivity.setIntent(intent);
632
- smManager.checkAndDisplayMessage(intent, currentActivity);
633
- }
284
+ if (currentActivity == null) { return; }
285
+
286
+ currentActivity.setIntent(intent);
287
+ this.manager.checkAndDisplayMessage(intent, currentActivity, this::broadcastEvent);
634
288
  }
635
289
 
636
290
  @Override
637
291
  public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) { }
292
+
293
+ private void broadcastEvent(String eventName, Map<String, Object> data) {
294
+ this.reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(
295
+ eventName,
296
+ RNHelpers.convertMapToWritableMap(data)
297
+ );
298
+ }
299
+
300
+ private void processErrorStringToCallback(String error, Callback successCallback, Callback errorCallback) {
301
+ if (error == null) {
302
+ successCallback.invoke();
303
+ return;
304
+ }
305
+
306
+ errorCallback.invoke(error);
307
+ }
638
308
  }
@@ -1,7 +1,7 @@
1
-
2
1
  package com.selligent;
3
2
 
4
- import java.util.Arrays;
3
+ import androidx.annotation.NonNull;
4
+
5
5
  import java.util.Collections;
6
6
  import java.util.List;
7
7
 
@@ -10,19 +10,22 @@ import com.facebook.react.bridge.NativeModule;
10
10
  import com.facebook.react.bridge.ReactApplicationContext;
11
11
  import com.facebook.react.uimanager.ViewManager;
12
12
  import com.facebook.react.bridge.JavaScriptModule;
13
+
13
14
  public class RNSelligentPackage implements ReactPackage {
15
+ @NonNull
14
16
  @Override
15
- public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
16
- return Arrays.<NativeModule>asList(new RNSelligent(reactContext));
17
+ public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
18
+ return Collections.singletonList(new RNSelligent(reactContext));
17
19
  }
18
20
 
19
- // Deprecated from RN 0.47
20
21
  public List<Class<? extends JavaScriptModule>> createJSModules() {
21
- return Collections.emptyList();
22
+ return Collections.emptyList();
22
23
  }
23
24
 
25
+ @NonNull
24
26
  @Override
25
- public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
26
- return Collections.emptyList();
27
+ @SuppressWarnings("rawtypes")
28
+ public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
29
+ return Collections.emptyList();
27
30
  }
28
31
  }
package/constants.d.ts CHANGED
@@ -74,4 +74,5 @@ export namespace BroadcastEventType {
74
74
  const RECEIVED_REMOTE_NOTIFICATION = "ReceivedRemoteNotification";
75
75
  const UNIVERSAL_LINK_EXECUTED = "UniversalLinkExecuted";
76
76
  const TRIGGERED_CUSTOM_EVENT = "TriggeredCustomEvent";
77
+ const DISPLAYING_IN_APP_MESSAGE = "DisplayingInAppMessage";
77
78
  }
package/constants.js CHANGED
@@ -174,7 +174,9 @@ const SelligentConstants = {
174
174
  /** Received an universal link execution */
175
175
  UNIVERSAL_LINK_EXECUTED: "UniversalLinkExecuted",
176
176
  /** A custom event has been triggered */
177
- TRIGGERED_CUSTOM_EVENT: "TriggeredCustomEvent"
177
+ TRIGGERED_CUSTOM_EVENT: "TriggeredCustomEvent",
178
+ /** An IAM is about to be displayed (when `customInAppUi` is set to `true` in `selligent.json`) */
179
+ DISPLAYING_IN_APP_MESSAGE: "DisplayingInAppMessage"
178
180
  },
179
181
 
180
182
  };
@@ -66,6 +66,7 @@ The following properties can be used in the `selligent.json` to further configur
66
66
  | url | string | The Marigold Engage webservice url to be used to integrate with your Marigold Engage platform |
67
67
  | clientId | string | The Marigold Engage client id to be used to integrate with your Marigold Engage platform |
68
68
  | privateKey | string | The Marigold Engage private key to be used to integrate with your Marigold Engage platform |
69
+ | customInAppUi | boolean| When this is enabled and a "push + inapp" notification is clicked, the SDK will NOT display the inApp message and instead a `SelligentConstants.BroadcastEventType.DISPLAYING_IN_APP_MESSAGE` event will be sent |
69
70
  | delayedPushAction | boolean| (iOS Only) Optin for a specific push action handling (wait for React UI to be ready) when coming from a push message and having the app killed |
70
71
  | interceptSelligentUniversalLinks | boolean| (iOS Only) Optin to customly handle the execution of universal links coming from a Push/IAM [more information](#universal-linking---ios) |
71
72
  | clearCacheIntervalValue | [enum](#clearcacheintervalvalue) | How much time the SDK will keep things in cache |
@@ -482,7 +483,7 @@ The `data` property is an object itself containing more information specific to
482
483
 
483
484
  | Property | Type | Description |
484
485
  | -------- | ------ | ------------------ |
485
- | id | string | Internal id of the message |
486
+ | id | string | Internal id of the message |
486
487
  | title | string | Title of the message |
487
488
 
488
489
  ```javascript
@@ -512,7 +513,7 @@ The response of the success callback is an array of objects which contain the in
512
513
  | -------------- | ------------------------------------------------------------------------------- | ---------------------------------------------------------- |
513
514
  | id | string | Internal id of the IAM |
514
515
  | title | string | Title of the IAM |
515
- | body | string | Body of the IAM |
516
+ | body | string | Body of the IAM. For message of type `ALERT` it will be the text corresponding to the body of the Alert, for type `HTML` it will be the html code, for type `URL`, `IMAGE` and `PASSBOOK` it will be an URL. |
516
517
  | type | [enum](#inappmessagetype) | Type of the IAM |
517
518
  | creationDate | number | Creation date of the IAM in unix time |
518
519
  | expirationDate | number | Expiration date of the IAM in unix time |
@@ -529,6 +530,36 @@ The `buttons` property is an array of button-objects which contain the informati
529
530
  | value | string | Value of the button of the in app message | Both |
530
531
  | type | number | Type of the button of the in app message | Both |
531
532
 
533
+ - When the IAM is linked to a push notification, you can set `customInAppUi` to `true` in `selligent.json` and subscribe to `SelligentConstants.BroadcastEventType.DISPLAYING_IN_APP_MESSAGE` events through the `Selligent.subscribeToEvents`, to know when messages are about to be displayed.
534
+ You will also need to set `addInAppMessageFromPushToInAppMessageList` to `true` in `selligent.json` to be able to retrieve the full object calling `Selligent.getInAppMessages` and do not forget to use the [IAM Helper methods](#iam-helper-methods) to properly track Open and Click interactions.
535
+ For Android, to avoid the SDK directly displaying the IAM if the App is in foreground, do also set `remoteMessageDisplayType` to `22` (NOTIFICATION) in `selligent.json`.
536
+ The response of the success callback is an object which contains information on the type of broadcast event and the data attached to it.
537
+
538
+ | Property | Type | Description |
539
+ | ------------------ | ------------------------------------------------------- | ----------------------------------------------------------------- |
540
+ | broadcastEventType | [enum](#broadcasteventtype) | The type of broadcast event |
541
+ | data | object | Contains more information specific to the type of broadcast event |
542
+
543
+ The `data` property is an object itself containing more information specific to the type of the broadcast event:
544
+
545
+ - DISPLAYING_IN_APP_MESSAGE
546
+
547
+ | Property | Type | Description |
548
+ | -------- | ------ | ------------------ |
549
+ | id | string | Internal id of the message |
550
+ | title | string | Title of the message |
551
+
552
+ ```javascript
553
+ Selligent.subscribeToEvents(
554
+ () => {},
555
+ () => {},
556
+ (response) => {
557
+ if (response?.broadcastEventType === SelligentConstants.BroadcastEventType.DISPLAYING_IN_APP_MESSAGE) {
558
+ }
559
+ }
560
+ )
561
+ ```
562
+
532
563
  To display any of these messages, you can call `Selligent.displayMessage`:
533
564
 
534
565
  ### Selligent.displayMessage
@@ -596,7 +627,7 @@ In the other hand, you can also use the native methods `RNSelligent/willPresentN
596
627
 
597
628
  ### IAM Helper methods
598
629
 
599
- If you decide to display the AIM on your own (without `Selligent.displayMessage` and `Selligent.displayNotification`), listening for new messages with the `Selligent.subscribeToEvents` and/or getting the full list with `Selligent.getInAppMessages`. You will be able to build your own layout with the object provided from the mentioned functions and then you can use the helper methods described here to still push KPI statistics to the Marigold Engage platform:
630
+ If you decide to display the IAM on your own (without `Selligent.displayMessage` and `Selligent.displayNotification`), listening for new messages with the `Selligent.subscribeToEvents` and/or getting the full list with `Selligent.getInAppMessages`. You will be able to build your own layout with the object provided from the mentioned functions and then you can use the helper methods described here to still push KPI statistics to the Marigold Engage platform:
600
631
 
601
632
  - setInAppMessageAsSeen: sets an IAM as seen and sends the corresponding `Opened` event to the Marigold Engage platform
602
633
 
@@ -905,3 +936,4 @@ Defines the type of a broadcast event.
905
936
  | RECEIVED_REMOTE_NOTIFICATION | string | ReceivedRemoteNotification | A remote notification has been received |
906
937
  | iOS.UNIVERSAL_LINK_EXECUTED | string | UniversalLinkExecuted | An universal link has been executed |
907
938
  | TRIGGERED_CUSTOM_EVENT | string | TriggeredCustomEvent | A custom event has been triggered |
939
+ | DISPLAYING_IN_APP_MESSAGE | string | DisplayingInAppMessage | An IAM is about to be displayed (when `customInAppUi` is set to `true` in `selligent.json`) |
package/index.js CHANGED
@@ -306,6 +306,7 @@ export default Object.assign(
306
306
  RNSEventEmitter.addListener(SelligentConstants.BroadcastEventType.RECEIVED_DEVICE_ID, eventCallback);
307
307
  RNSEventEmitter.addListener(SelligentConstants.BroadcastEventType.RECEIVED_REMOTE_NOTIFICATION, eventCallback);
308
308
  RNSEventEmitter.addListener(SelligentConstants.BroadcastEventType.TRIGGERED_CUSTOM_EVENT, eventCallback);
309
+ RNSEventEmitter.addListener(SelligentConstants.BroadcastEventType.DISPLAYING_IN_APP_MESSAGE, eventCallback);
309
310
 
310
311
  if (Platform.OS === "ios") {
311
312
  RNSEventEmitter.addListener(SelligentConstants.BroadcastEventType.UNIVERSAL_LINK_EXECUTED, eventCallback);
@@ -148,7 +148,8 @@ RCT_EXPORT_METHOD(subscribeToEvents:(NSArray<NSString *> *)events) {
148
148
  @"ReceivedRemoteNotification",
149
149
  @"ReceivedDeviceId",
150
150
  @"UniversalLinkExecuted",
151
- @"TriggeredCustomEvent"
151
+ @"TriggeredCustomEvent",
152
+ @"DisplayingInAppMessage"
152
153
  ];
153
154
  }
154
155
 
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  },
5
5
  "name": "@selligent-marketing-cloud/selligent-react-native",
6
6
  "title": "Marigold Engage React Native",
7
- "version": "3.5.1",
7
+ "version": "3.7.0",
8
8
  "description": "React Native wrapper for the Marigold Engage Android and iOS SDKs",
9
9
  "main": "index.js",
10
10
  "repository": {