@selligent-marketing-cloud/selligent-react-native 3.2.6 → 3.3.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.
Files changed (41) hide show
  1. package/README.md +28 -42
  2. package/RNSelligentMapper.podspec +22 -0
  3. package/android/build.gradle +6 -4
  4. package/android/src/main/java/com/selligent/BroadcastDataFactory.java +12 -6
  5. package/android/src/main/java/com/selligent/ButtonAction.java +2 -1
  6. package/android/src/main/java/com/selligent/ButtonBroadcastEventDataParser.java +9 -1
  7. package/android/src/main/java/com/selligent/Event.java +3 -3
  8. package/android/src/main/java/com/selligent/InAppMessageBroadcastEventDataParser.java +9 -1
  9. package/android/src/main/java/com/selligent/RNSelligent.java +96 -75
  10. package/android/src/main/java/com/selligent/SMEventFactory.java +2 -1
  11. package/android/src/main/java/com/selligent/SMSettingsFactory.java +3 -0
  12. package/android/src/main/java/com/selligent/Settings.java +15 -3
  13. package/documentation/README.md +52 -11
  14. package/index.android.js +0 -9
  15. package/index.js +9 -0
  16. package/ios/RNSelligentMapper.m +8 -4
  17. package/package.json +2 -3
  18. package/RNSelligent.podspec +0 -21
  19. package/ios/RNSelligentMobileSDK.xcframework/Info.plist +0 -40
  20. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/Headers/RNSelligentMobileSDK-Swift.h +0 -350
  21. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/Info.plist +0 -0
  22. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios.abi.json +0 -2603
  23. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +0 -59
  24. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  25. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios.swiftinterface +0 -59
  26. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/Modules/module.modulemap +0 -4
  27. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/RNSelligentMobileSDK +0 -0
  28. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/_CodeSignature/CodeResources +0 -179
  29. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Headers/RNSelligentMobileSDK-Swift.h +0 -696
  30. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Info.plist +0 -0
  31. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios-simulator.abi.json +0 -2603
  32. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +0 -59
  33. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  34. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +0 -59
  35. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +0 -2603
  36. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +0 -59
  37. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  38. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +0 -59
  39. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/module.modulemap +0 -4
  40. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/RNSelligentMobileSDK +0 -0
  41. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/_CodeSignature/CodeResources +0 -234
@@ -34,28 +34,45 @@ import com.selligent.sdk.SMCallback;
34
34
  import com.selligent.sdk.SMEvent;
35
35
  import com.selligent.sdk.SMForegroundGcmBroadcastReceiver;
36
36
  import com.selligent.sdk.SMInAppMessage;
37
- import com.selligent.sdk.SMInAppMessageReturn;
38
37
  import com.selligent.sdk.SMInAppRefreshType;
39
38
  import com.selligent.sdk.SMManager;
40
39
  import com.selligent.sdk.SMNotificationButton;
41
40
  import com.selligent.sdk.SMNotificationMessage;
41
+ import com.selligent.sdk.SMObserverManager;
42
42
  import com.selligent.sdk.SMRemoteMessageDisplayType;
43
43
  import com.selligent.sdk.SMSettings;
44
44
 
45
- import java.util.ArrayList;
46
45
  import java.util.HashMap;
47
46
 
48
47
  public class RNSelligent extends ReactContextBaseJavaModule implements LifecycleEventListener, ActivityEventListener {
49
48
 
49
+ private static final String RN_SELLIGENT_NAME = "RNSelligent";
50
50
  private final ReactApplicationContext reactContext;
51
51
  private final SMManager smManager;
52
- private EventReceiver eventReceiver;
53
- private SMForegroundGcmBroadcastReceiver receiver;
52
+ EventReceiver eventReceiver;
53
+ SMForegroundGcmBroadcastReceiver receiver;
54
54
  private static SMInAppRefreshType inAppMessageRefreshType;
55
55
 
56
56
  public static final String REACT_CLASS = "SelligentReactNative"; // for logging purposes
57
57
 
58
- private boolean areObserverStarted = false;
58
+ boolean areObserverStarted = false;
59
+
60
+ //region getter
61
+ static SMManager getSMManager()
62
+ {
63
+ return SMManager.getInstance();
64
+ }
65
+
66
+ static String getSelligentSettings()
67
+ {
68
+ return BuildConfig.SELLIGENT_SETTINGS;
69
+ }
70
+
71
+ static Class<? extends Activity> getActivityClass(String notificationActivityName) throws Exception
72
+ {
73
+ return (Class<? extends Activity>) Class.forName(notificationActivityName);
74
+ }
75
+ //endregion
59
76
 
60
77
 
61
78
  public RNSelligent(ReactApplicationContext reactContext) {
@@ -63,28 +80,28 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
63
80
  this.reactContext = reactContext;
64
81
  reactContext.addLifecycleEventListener(this);
65
82
  reactContext.addActivityEventListener(this);
66
- this.smManager = SMManager.getInstance();
83
+ this.smManager = getSMManager();
67
84
  }
68
85
 
69
86
  @Override
70
87
  public String getName() {
71
- return "RNSelligent";
88
+ return RN_SELLIGENT_NAME;
72
89
  }
73
90
 
74
91
  public static void configure(Application application) {
75
92
  try {
76
93
  final HashMap<String, Object> settingsHashMap = new Gson().fromJson(
77
- BuildConfig.SELLIGENT_SETTINGS, new TypeToken<HashMap<String, Object>>() {}.getType()
94
+ getSelligentSettings(), new TypeToken<HashMap<String, Object>>() {}.getType()
78
95
  );
79
96
  final Settings settings = Settings.fromHashMap(settingsHashMap);
80
97
  final SMSettings smSettings = SMSettingsFactory.getSMSettings(settings);
81
98
  final String notificationActivityName = settings.getActivityName();
82
99
 
83
- SMManager.NOTIFICATION_ACTIVITY = (Class<? extends Activity>) Class.forName(notificationActivityName);
100
+ SMManager.NOTIFICATION_ACTIVITY = getActivityClass(notificationActivityName);
84
101
  inAppMessageRefreshType = settings.getInAppMessageRefreshType().getSmInAppRefreshType();
85
102
 
86
- final SMManager smManager = SMManager.getInstance();
87
- SMManager.DEBUG = BuildConfig.BUILD_TYPE.equals("debug");
103
+ final SMManager smManager = getSMManager();
104
+ SMManager.DEBUG = BuildConfig.BUILD_TYPE.equals("debug") || settings.getEnableAndroidLogging();
88
105
  smManager.start(smSettings, application);
89
106
 
90
107
  final Resources resources = application.getResources();
@@ -108,12 +125,12 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
108
125
  final int color = Color.parseColor(settings.getNotificationIconColor());
109
126
  smManager.setNotificationIconColor(color);
110
127
  } catch (IllegalArgumentException e) {
111
- Log.e("RNSelligent", "notificationIconColor must be a color hex string.");
128
+ Log.e(RN_SELLIGENT_NAME, "notificationIconColor must be a color hex string.");
112
129
  }
113
130
  }
114
131
 
115
- } catch (ClassNotFoundException e) {
116
- Log.e("RNSelligent", "SMManager start failed: an error occurred while setting the NotificationActivity", e);
132
+ } catch (Exception e) {
133
+ Log.e(RN_SELLIGENT_NAME, "SMManager start failed: an error occurred while setting the NotificationActivity", e);
117
134
  }
118
135
  }
119
136
 
@@ -127,17 +144,18 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
127
144
 
128
145
  @ReactMethod
129
146
  public void enableInAppMessages(ReadableMap enabled) {
130
- final ReadableType enabledType = enabled.getType("enabled");
147
+ final String enabledProperty = "enabled";
148
+ final ReadableType enabledType = enabled.getType(enabledProperty);
131
149
 
132
150
  if (enabledType == ReadableType.Boolean) {
133
- enableInAppMessages(enabled.getBoolean("enabled"));
151
+ enableInAppMessages(enabled.getBoolean(enabledProperty));
134
152
  }
135
153
  else if (enabledType == ReadableType.Number) {
136
- enableInAppMessages(enabled.getInt("enabled"));
154
+ enableInAppMessages(enabled.getInt(enabledProperty));
137
155
  }
138
156
  }
139
157
 
140
- private void enableInAppMessages(Boolean enable) {
158
+ private void enableInAppMessages(boolean enable) {
141
159
  if (enable) {
142
160
  smManager.enableInAppMessages(inAppMessageRefreshType);
143
161
  } else {
@@ -146,8 +164,8 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
146
164
  }
147
165
 
148
166
  private void enableInAppMessages(Integer inAppMessageRefreshTypeIndex) {
149
- final InAppMessageRefreshType inAppMessageRefreshType = InAppMessageRefreshType.valueOf(inAppMessageRefreshTypeIndex);
150
- final SMInAppRefreshType smInAppRefreshType = inAppMessageRefreshType.getSmInAppRefreshType();
167
+ final InAppMessageRefreshType refreshType = InAppMessageRefreshType.valueOf(inAppMessageRefreshTypeIndex);
168
+ final SMInAppRefreshType smInAppRefreshType = refreshType.getSmInAppRefreshType();
151
169
 
152
170
  smManager.enableInAppMessages(smInAppRefreshType);
153
171
  }
@@ -169,47 +187,44 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
169
187
 
170
188
  @ReactMethod
171
189
  public void getInAppMessages(final Callback successCallback) {
172
- smManager.getInAppMessages(new SMInAppMessageReturn() {
173
- @Override
174
- public void onRetrieve(ArrayList<SMInAppMessage> inAppMessages) {
175
- WritableArray resultingMessagesArray = new WritableNativeArray();
190
+ smManager.getInAppMessages(inAppMessages -> {
191
+ WritableArray resultingMessagesArray = new WritableNativeArray();
176
192
 
177
- for (SMInAppMessage message : inAppMessages) {
178
- WritableMap messageMap = new WritableNativeMap();
193
+ for (SMInAppMessage message : inAppMessages) {
194
+ WritableMap messageMap = new WritableNativeMap();
179
195
 
180
- messageMap.putString("id", message.id);
181
- messageMap.putString("title", message.title);
182
- messageMap.putString("body", message.getBody());
183
- messageMap.putDouble("creationDate", message.getCreationDate());
184
- messageMap.putDouble("expirationDate", message.getExpirationDate());
185
- messageMap.putDouble("receptionDate", message.getReceptionDate());
186
- messageMap.putBoolean("hasBeenSeen", message.hasBeenSeen());
187
- messageMap.putDouble("type", message.getType().getValue());
196
+ messageMap.putString("id", message.id);
197
+ messageMap.putString("title", message.title);
198
+ messageMap.putString("body", message.getBody());
199
+ messageMap.putDouble("creationDate", message.getCreationDate());
200
+ messageMap.putDouble("expirationDate", message.getExpirationDate());
201
+ messageMap.putDouble("receptionDate", message.getReceptionDate());
202
+ messageMap.putBoolean("hasBeenSeen", message.hasBeenSeen());
203
+ messageMap.putDouble("type", message.getType().getValue());
188
204
 
189
- WritableArray buttonsArray = new WritableNativeArray();
205
+ WritableArray buttonsArray = new WritableNativeArray();
190
206
 
191
- SMNotificationButton buttons[] = message.getButtons();
207
+ SMNotificationButton[] buttons = message.getButtons();
192
208
 
193
- if(buttons != null) {
194
- for(SMNotificationButton button : buttons) {
195
- WritableMap buttonMap = new WritableNativeMap();
209
+ if(buttons != null) {
210
+ for(SMNotificationButton button : buttons) {
211
+ WritableMap buttonMap = new WritableNativeMap();
196
212
 
197
- buttonMap.putString("id", button.id);
198
- buttonMap.putString("value", button.value);
199
- buttonMap.putString("label", button.label);
200
- buttonMap.putInt("type", button.type);
213
+ buttonMap.putString("id", button.id);
214
+ buttonMap.putString("value", button.value);
215
+ buttonMap.putString("label", button.label);
216
+ buttonMap.putInt("type", button.type);
201
217
 
202
- buttonsArray.pushMap(buttonMap);
203
- }
218
+ buttonsArray.pushMap(buttonMap);
204
219
  }
205
-
206
- messageMap.putArray("buttons", buttonsArray);
207
-
208
- resultingMessagesArray.pushMap(messageMap);
209
220
  }
210
221
 
211
- successCallback.invoke(resultingMessagesArray);
222
+ messageMap.putArray("buttons", buttonsArray);
223
+
224
+ resultingMessagesArray.pushMap(messageMap);
212
225
  }
226
+
227
+ successCallback.invoke(resultingMessagesArray);
213
228
  });
214
229
  }
215
230
 
@@ -268,24 +283,28 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
268
283
 
269
284
  @ReactMethod
270
285
  public void executeButtonAction(final String buttonId, final String messageId, final Callback successCallback, final Callback errorCallback) {
271
- smManager.getInAppMessages(new SMInAppMessageReturn() {
272
- @Override
273
- public void onRetrieve(ArrayList<SMInAppMessage> inAppMessages) {
274
- for(SMInAppMessage message : inAppMessages) {
275
- if(message.id.equals(messageId)) {
276
- for(SMNotificationButton button : message.getButtons()) {
277
- if(button.id.equals(buttonId)) {
286
+ smManager.getInAppMessages(inAppMessages -> {
287
+ for(SMInAppMessage message : inAppMessages) {
288
+ if(message.id.equals(messageId))
289
+ {
290
+ SMNotificationButton[] buttons = message.getButtons();
291
+ if (buttons != null)
292
+ {
293
+ for (SMNotificationButton button : message.getButtons())
294
+ {
295
+ if (button.id.equals(buttonId))
296
+ {
278
297
  smManager.executeButtonAction(reactContext, button, message);
279
298
  successCallback.invoke();
280
299
  return;
281
300
  }
282
301
  }
283
- errorCallback.invoke("buttonId does not exist in message.");
284
- return;
285
302
  }
303
+ errorCallback.invoke("buttonId does not exist in message.");
304
+ return;
286
305
  }
287
- errorCallback.invoke(String.format("No message with id %s found", messageId));
288
306
  }
307
+ errorCallback.invoke(String.format("No message with id %s found", messageId));
289
308
  });
290
309
  }
291
310
 
@@ -320,13 +339,17 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
320
339
 
321
340
  @ReactMethod
322
341
  public void enableNotifications(Boolean enable) {
323
- if (enable) {
342
+ if (Boolean.TRUE.equals(enable)) {
324
343
  smManager.enableNotifications();
325
344
  } else {
326
345
  smManager.disableNotifications();
327
346
  }
328
347
  }
329
348
 
349
+ public static void enableNotifications() {
350
+ SMManager.getInstance().enableNotifications();
351
+ }
352
+
330
353
  @ReactMethod
331
354
  public void displayLastReceivedRemotePushNotification(String templateId) {
332
355
  final Activity currentActivity = getCurrentActivity();
@@ -437,7 +460,8 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
437
460
  thisActivity.runOnUiThread(() -> {
438
461
  if (!areObserverStarted)
439
462
  {
440
- Log.d("RNSelligent", "Instantiating the observers on the UI thread");
463
+ Log.d(RN_SELLIGENT_NAME, "Instantiating the observers on the UI thread");
464
+ SMObserverManager observerManager = smManager.getObserverManager();
441
465
 
442
466
  // Token received
443
467
  final Observer<String> tokenObserver = token -> {
@@ -446,7 +470,7 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
446
470
  final WritableMap data = broadcastEventDataParser.wrap(token);
447
471
  rctDeviceEventEmitter.emit(eventName, getBroadcastData(eventName, data));
448
472
  };
449
- SMManager.getInstance().getObserverManager().observeToken(thisActivity, tokenObserver);
473
+ observerManager.observeToken(thisActivity, tokenObserver);
450
474
 
451
475
  // Device id received
452
476
  final Observer<String> deviceIdObserver = deviceId -> {
@@ -455,7 +479,7 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
455
479
  final WritableMap data = broadcastEventDataParser.wrap(deviceId);
456
480
  rctDeviceEventEmitter.emit(eventName, getBroadcastData(eventName, data));
457
481
  };
458
- SMManager.getInstance().getObserverManager().observeDeviceId(thisActivity, deviceIdObserver);
482
+ observerManager.observeDeviceId(thisActivity, deviceIdObserver);
459
483
 
460
484
  // InApp messages received
461
485
  final Observer<SMInAppMessage[]> inAppMessageObserver = inAppMessages -> {
@@ -467,7 +491,7 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
467
491
  rctDeviceEventEmitter.emit(eventName, getBroadcastData(eventName, data));
468
492
  }
469
493
  };
470
- SMManager.getInstance().getObserverManager().observeInAppMessages(thisActivity, inAppMessageObserver);
494
+ observerManager.observeInAppMessages(thisActivity, inAppMessageObserver);
471
495
 
472
496
  // Button clicked
473
497
  final Observer<SMNotificationButton> clickedButtonObserver = button -> {
@@ -479,21 +503,21 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
479
503
  rctDeviceEventEmitter.emit(eventName, getBroadcastData(eventName, data));
480
504
  }
481
505
  };
482
- SMManager.getInstance().getObserverManager().observeClickedButton(thisActivity, clickedButtonObserver);
506
+ observerManager.observeClickedButton(thisActivity, clickedButtonObserver);
483
507
 
484
508
  // Message dismissed
485
509
  final Observer<Void> dismissedMessageObserver = object -> {
486
510
  String eventName = BroadcastEventType.WillDismissNotification.getBroadcastEventType();
487
511
  rctDeviceEventEmitter.emit(eventName, getBroadcastData(eventName, null));
488
512
  };
489
- SMManager.getInstance().getObserverManager().observeDismissedMessage(thisActivity, dismissedMessageObserver);
513
+ observerManager.observeDismissedMessage(thisActivity, dismissedMessageObserver);
490
514
 
491
515
  // Message displayed
492
516
  final Observer<Void> displayedMessageObserver = object -> {
493
517
  String eventName = BroadcastEventType.WillDisplayNotification.getBroadcastEventType();
494
518
  rctDeviceEventEmitter.emit(eventName, getBroadcastData(eventName, null));
495
519
  };
496
- SMManager.getInstance().getObserverManager().observeDisplayedMessage(thisActivity, displayedMessageObserver);
520
+ observerManager.observeDisplayedMessage(thisActivity, displayedMessageObserver);
497
521
 
498
522
  // Push received
499
523
  final Observer<SMNotificationMessage> pushReceivedObserver = notificationMessage -> {
@@ -505,19 +529,17 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
505
529
  rctDeviceEventEmitter.emit(eventName, getBroadcastData(eventName, data));
506
530
  }
507
531
  };
508
- SMManager.getInstance().getObserverManager().observePushReceived(thisActivity, pushReceivedObserver);
532
+ observerManager.observePushReceived(thisActivity, pushReceivedObserver);
509
533
 
510
534
  // Custom events
511
- final Observer<String> customEventObserver = event -> {
512
- rctDeviceEventEmitter.emit(BroadcastEventType.TriggeredCustomEvent.getBroadcastEventType(), getBroadcastData(event, null));
513
- };
514
- SMManager.getInstance().getObserverManager().observeEvent(thisActivity, customEventObserver);
535
+ final Observer<String> customEventObserver = event -> rctDeviceEventEmitter.emit(BroadcastEventType.TriggeredCustomEvent.getBroadcastEventType(), getBroadcastData(event, null));
536
+ observerManager.observeEvent(thisActivity, customEventObserver);
515
537
 
516
538
  areObserverStarted = true;
517
539
  }
518
540
  else
519
541
  {
520
- Log.d("RNSelligent", "Observers already instantiated");
542
+ Log.d(RN_SELLIGENT_NAME, "Observers already instantiated");
521
543
  }
522
544
  });
523
545
  }
@@ -601,5 +623,4 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
601
623
 
602
624
  @Override
603
625
  public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) { }
604
-
605
626
  }
@@ -11,6 +11,7 @@ import com.selligent.sdk.SMEventUserUnregister;
11
11
  import java.util.Hashtable;
12
12
 
13
13
  class SMEventFactory {
14
+ private SMEventFactory(){}
14
15
 
15
16
  public static SMEvent getSMEvent(Event event, SMCallback callback) {
16
17
  final EventType type = event.getType();
@@ -27,7 +28,7 @@ class SMEventFactory {
27
28
  case UserLogout:
28
29
  return new SMEventUserLogout(email, data, callback);
29
30
  case Custom:
30
- return new SMEvent(data, callback);
31
+ return new SMEvent(null, data, callback);
31
32
  default:
32
33
  throw new IllegalArgumentException("SMManager sendEvent failed: you provided an invalid EventType");
33
34
  }
@@ -1,8 +1,10 @@
1
1
  package com.selligent;
2
2
 
3
3
  import com.selligent.sdk.SMSettings;
4
+ import com.selligent.sdk.SMFrameworkType;
4
5
 
5
6
  class SMSettingsFactory {
7
+ private SMSettingsFactory(){}
6
8
 
7
9
  public static SMSettings getSMSettings(Settings settings) {
8
10
  final SMSettings smSettings = new SMSettings();
@@ -16,6 +18,7 @@ class SMSettingsFactory {
16
18
  smSettings.NotificationChannelId = settings.getNotificationChannelId();
17
19
  smSettings.NotificationChannelName = settings.getNotificationChannelName();
18
20
  smSettings.NotificationChannelDescription = settings.getNotificationChannelDescription();
21
+ smSettings.FrameworkType = SMFrameworkType.reactNative;
19
22
 
20
23
  final ClearCacheIntervalValue clearCacheIntervalValue = settings.getClearCacheIntervalValue();
21
24
  if (clearCacheIntervalValue != null) {
@@ -1,7 +1,7 @@
1
1
  package com.selligent;
2
2
 
3
3
 
4
- import java.util.HashMap;
4
+ import java.util.Map;
5
5
 
6
6
  class Settings {
7
7
 
@@ -22,6 +22,7 @@ class Settings {
22
22
  private String notificationChannelId = "SMChannel001";
23
23
  private String notificationChannelName = "SMDefaultChannel";
24
24
  private String notificationChannelDescription = "";
25
+ private Boolean enableAndroidLogging = false;
25
26
 
26
27
  private Settings() { }
27
28
 
@@ -85,7 +86,9 @@ class Settings {
85
86
  return notificationChannelDescription;
86
87
  }
87
88
 
88
- public static Settings fromHashMap(HashMap<String, Object> settingsHashMap) {
89
+ public Boolean getEnableAndroidLogging() { return enableAndroidLogging; }
90
+
91
+ public static Settings fromHashMap(Map<String, Object> settingsHashMap) {
89
92
  final Settings settings = new Settings();
90
93
 
91
94
  settings.url = (String) settingsHashMap.get("url");
@@ -101,7 +104,7 @@ class Settings {
101
104
  settings.notificationLargeIcon = (String) settingsHashMap.get("notificationLargeIcon");
102
105
  }
103
106
 
104
- if(settingsHashMap.containsKey("notificationIconColor")) {
107
+ if (settingsHashMap.containsKey("notificationIconColor")) {
105
108
  settings.notificationIconColor = (String) settingsHashMap.get("notificationIconColor");
106
109
  }
107
110
 
@@ -120,24 +123,33 @@ class Settings {
120
123
  if (settingsHashMap.containsKey("loadCacheAsynchronously")) {
121
124
  settings.loadCacheAsynchronously = (Boolean) settingsHashMap.get("loadCacheAsynchronously");
122
125
  }
126
+
123
127
  if (settingsHashMap.containsKey("notificationChannelId")) {
124
128
  settings.notificationChannelId = (String) settingsHashMap.get("notificationChannelId");
125
129
  }
130
+
126
131
  if (settingsHashMap.containsKey("notificationChannelName")) {
127
132
  settings.notificationChannelName = (String) settingsHashMap.get("notificationChannelName");
128
133
  }
134
+
129
135
  if (settingsHashMap.containsKey("notificationChannelDescription")) {
130
136
  settings.notificationChannelDescription = (String) settingsHashMap.get("notificationChannelDescription");
131
137
  }
132
138
 
139
+ if (settingsHashMap.containsKey("enableAndroidLogging")) {
140
+ settings.enableAndroidLogging = (Boolean) settingsHashMap.get("enableAndroidLogging");
141
+ }
142
+
133
143
  final Double clearCacheIndex = (Double) settingsHashMap.get("clearCacheIntervalValue");
134
144
  if (clearCacheIndex != null) {
135
145
  settings.clearCacheIntervalValue = ClearCacheIntervalValue.valueOf(clearCacheIndex.intValue());
136
146
  }
147
+
137
148
  final Double inAppMsgRefreshIndex = (Double) settingsHashMap.get("inAppMessageRefreshType");
138
149
  if (inAppMsgRefreshIndex != null) {
139
150
  settings.inAppMessageRefreshType = InAppMessageRefreshType.valueOf(inAppMsgRefreshIndex.intValue());
140
151
  }
152
+
141
153
  final Double remoteMsgRefreshIndex = (Double) settingsHashMap.get("remoteMessageDisplayType");
142
154
  if (remoteMsgRefreshIndex != null) {
143
155
  settings.remoteMessageDisplayType = RemoteMessageDisplayType.valueOf(remoteMsgRefreshIndex.intValue());
@@ -73,7 +73,9 @@ The following properties can be used in the `selligent.json` to further configur
73
73
  | remoteMessageDisplayType | [enum](#remotemessagesdisplaytype) | The behaviour when receiving a push notification with the app in foreground |
74
74
  | appGroupId | string |(iOS Only) The appgroup id necessary for the correct communication between the app and the app extensions |
75
75
  | shouldClearBadge | boolean | (iOS Only) Whether or not, clicking a push notification should reset the badge number |
76
- | shouldDisplayRemoteNotification | boolean | (iOS Only) Whether or not, the SDK should try to display the content linked to a push message (usually, inapp messages) or it will be handled customly |
76
+ | shouldDisplayRemoteNotification | boolean | (iOS Only) Whether or not, the SDK should try to display the content linked to a push message (usually, inapp messages) or it will be handled customly
77
+ | enableiOSLogging | [enum](#iosloglevel) | Log level used since the app launch |
78
+ | enableAndroidLogging | boolean | (Android Only) Whether or not, the SDK logging will be enabled since the app launch |
77
79
  | doNotListenToThePush | boolean | (Android Only) Whether or not, the SDK will listen for pushs from google |
78
80
  | doNotFetchTheToken | boolean | (Android Only) Whether or not, the SDK will listen for push tokens from google |
79
81
  | loadCacheAsynchronously | boolean | (Android Only) Whether or not, the SDK load the cache asynchronously |
@@ -89,7 +91,44 @@ The following properties can be used in the `selligent.json` to further configur
89
91
 
90
92
  Follow the [iOS](https://github.com/SelligentMarketingCloud/MobileSDK-iOS/tree/master/Documentation#create-an-apns-key) & [Android](https://github.com/SelligentMarketingCloud/MobileSDK-Android/tree/master/Documentation#creating-an-application) native SDKs guides in order to optin for push notifications in Apple & Google.
91
93
 
92
- **For iOS**, there are some extra steps you need to follow in the native part of the ReactNative project:
94
+ **For Android**, if targeting API level 33 and above:
95
+ 1. Add this to request the push permission and let the SDK know when it is accepted, in the activity where you want to:
96
+ ```java
97
+ import com.selligent.RNSelligent;
98
+
99
+ public class MainActivity extends ReactActivity {
100
+ final int NOTIFICATION_PERMISSION_REQUEST_CODE = 1111;
101
+
102
+ @Override
103
+ public void onStart()
104
+ {
105
+ if (Build.VERSION.SDK_INT > Build.VERSION_CODES.S_V2)
106
+ {
107
+ if (ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED)
108
+ {
109
+ ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.POST_NOTIFICATIONS}, NOTIFICATION_PERMISSION_REQUEST_CODE);
110
+ }
111
+ }
112
+
113
+ super.onStart();
114
+ }
115
+
116
+ @Override
117
+ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults)
118
+ {
119
+ super.onRequestPermissionsResult(requestCode, permissions, grantResults);
120
+
121
+ if (requestCode == NOTIFICATION_PERMISSION_REQUEST_CODE)
122
+ {
123
+ if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED)
124
+ {
125
+ RNSelligent.enableNotifications();
126
+ }
127
+ }
128
+ }
129
+ ```
130
+
131
+ **For iOS**:
93
132
 
94
133
  1. For push notifications you need to delegate some of the `AppDelegate.m` methods to the SDK:
95
134
 
@@ -158,14 +197,16 @@ Follow the [iOS](https://github.com/SelligentMarketingCloud/MobileSDK-iOS/tree/m
158
197
  ```javascript
159
198
  import Selligent from "@selligent-marketing-cloud/selligent-react-native"; // Add Selligent import
160
199
 
161
- Selligent.enableNotifications(
162
- (response) => { // success callback
163
- },
164
- (error) => { // error callback
165
- },
166
- true
167
- )
168
-
200
+ if (Platform.OS === 'ios') {
201
+ Selligent.enableNotifications(
202
+ (response) => { // success callback
203
+ },
204
+ (error) => { // error callback
205
+ },
206
+ true
207
+ )
208
+ }
209
+
169
210
  Selligent.registerForProvisionalRemoteNotification(
170
211
  () => { // success callback
171
212
  }
@@ -231,7 +272,7 @@ This is because the JS layer is loaded **after** the native iOS SDK executes the
231
272
  if (Platform.OS === 'ios') {
232
273
  /* Tells the Selligent SDK to execute the action associated to the last push clicked, when using `delayedPushAction` feature.
233
274
  If you are having problems with deeplinks or 'Push + InApp Message' where the splash screen gets stuck or the push action not visible,
234
- make sure you control when the splash screen is dismissed and call this method afterwards (if the dismiss is async, call this method once the async process is completely finished)
275
+ make sure you control when the splash screen is dismissed (i.e https://docs.expo.dev/versions/latest/sdk/splash-screen/) and call this method afterwards (if the dismiss is async, call this method once the async process is completely finished)
235
276
  */
236
277
  Selligent.executePushAction()
237
278
  }
package/index.android.js CHANGED
@@ -33,15 +33,6 @@ export default {
33
33
  RNSelligent.enableInAppMessages({ enabled })
34
34
  },
35
35
 
36
- /**
37
- * To check if in app messages are enabled on Android.
38
- *
39
- * @param {function} successCallback Callback function on success.
40
- */
41
- areInAppMessagesEnabled: function (successCallback) {
42
- return RNSelligent.areInAppMessagesEnabled(successCallback)
43
- },
44
-
45
36
  // Log
46
37
  /**
47
38
  * Enable logging messages on Android.
package/index.js CHANGED
@@ -37,6 +37,15 @@ export default Object.assign(
37
37
  },
38
38
 
39
39
  // InAppMessage
40
+
41
+ /**
42
+ * To check if in app messages are enabled.
43
+ *
44
+ * @param {function} successCallback Callback function on success.
45
+ */
46
+ areInAppMessagesEnabled: function (successCallback) {
47
+ return RNSelligent.areInAppMessagesEnabled(successCallback)
48
+ },
40
49
 
41
50
  /**
42
51
  * Gets all known (and not deleted/expired) in app messages.
@@ -44,6 +44,10 @@ RCT_EXPORT_METHOD(registerForProvisionalRemoteNotification) {
44
44
  [RNSelligent registerForProvisionalRemoteNotification];
45
45
  }
46
46
 
47
+ RCT_EXPORT_METHOD(displayLastReceivedNotification) {
48
+ [RNSelligent displayLastReceivedNotification];
49
+ }
50
+
47
51
  RCT_EXPORT_METHOD(displayLastReceivedRemotePushNotification:(NSString *)templateId) {
48
52
  [RNSelligent displayLastReceivedRemotePushNotificationWithTemplateId:templateId];
49
53
  }
@@ -58,6 +62,10 @@ RCT_EXPORT_METHOD(enableInAppMessages:(BOOL)enabled) {
58
62
  [RNSelligent enableInAppMessages:enabled];
59
63
  }
60
64
 
65
+ RCT_EXPORT_METHOD(areInAppMessagesEnabled:(RCTResponseSenderBlock)callback) {
66
+ callback(@[@([RNSelligent areInAppMessagesEnabled]), [NSNull null]]);
67
+ }
68
+
61
69
  RCT_EXPORT_METHOD(getInAppMessages:(RCTResponseSenderBlock)callback) {
62
70
  callback(@[[RNSelligent getInAppMessages] ?: [NSNull null], [NSNull null]]);
63
71
  }
@@ -127,10 +135,6 @@ RCT_EXPORT_METHOD(subscribeToEvents:(NSArray<NSString *> *)events) {
127
135
  [RNSelligent subscribeToEvents:events];
128
136
  }
129
137
 
130
- RCT_EXPORT_METHOD(displayLastReceivedNotification) {
131
- [RNSelligent displayLastReceivedNotification];
132
- }
133
-
134
138
  - (void) sendBroadcastEventWithName:(NSString * _Nonnull)name type:(NSString * _Nonnull)type data:(NSDictionary * _Nullable)data {
135
139
  [self sendEventWithName:name body:@{@"data": data ?: [NSNull null], @"broadcastEventType": type}];
136
140
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  },
5
5
  "name": "@selligent-marketing-cloud/selligent-react-native",
6
6
  "title": "Selligent React Native",
7
- "version": "3.2.6",
7
+ "version": "3.3.0",
8
8
  "description": "React Native wrapper for the Selligent Marketing Cloud Android and iOS SDKs",
9
9
  "main": "index.js",
10
10
  "repository": {
@@ -38,10 +38,9 @@
38
38
  "test": "jest"
39
39
  },
40
40
  "files": [
41
- "/RNSelligent.podspec",
41
+ "/RNSelligentMapper.podspec",
42
42
  "/*.js",
43
43
  "/*.ts",
44
- "/ios/RNSelligentMobileSDK.xcframework",
45
44
  "/ios/*.h",
46
45
  "/ios/*.m",
47
46
  "/android/src/main",