@selligent-marketing-cloud/selligent-react-native 3.0.0 → 3.2.6

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 (184) hide show
  1. package/README.md +43 -1550
  2. package/RNSelligent.podspec +8 -15
  3. package/android/build.gradle +48 -81
  4. package/android/src/main/java/com/selligent/BroadcastEventType.java +4 -1
  5. package/android/src/main/java/com/selligent/ButtonAction.java +81 -0
  6. package/android/src/main/java/com/selligent/ButtonBroadcastEventDataParser.java +9 -3
  7. package/android/src/main/java/com/selligent/DeviceIdBroadcastEventDataParser.java +15 -0
  8. package/android/src/main/java/com/selligent/EventType.java +1 -1
  9. package/android/src/main/java/com/selligent/GCMTokenBroadcastEventDataParser.java +6 -1
  10. package/android/src/main/java/com/selligent/InAppMessageBroadcastEventDataParser.java +7 -1
  11. package/android/src/main/java/com/selligent/NotificationMessageBroadcastEventDataParser.java +19 -0
  12. package/android/src/main/java/com/selligent/RNSelligent.java +195 -56
  13. package/android/src/main/java/com/selligent/SMSettingsFactory.java +0 -1
  14. package/android/src/main/java/com/selligent/Settings.java +0 -9
  15. package/constants.d.ts +7 -33
  16. package/constants.js +51 -85
  17. package/documentation/README.md +826 -0
  18. package/helpers.js +5 -6
  19. package/index.android.js +8 -83
  20. package/index.d.ts +33 -43
  21. package/index.ios.js +25 -76
  22. package/index.js +153 -45
  23. package/ios/RNSelligentMapper.h +21 -0
  24. package/ios/RNSelligentMapper.m +151 -0
  25. package/ios/RNSelligentMobileSDK.xcframework/Info.plist +40 -0
  26. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/Headers/RNSelligentMobileSDK-Swift.h +350 -0
  27. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/Info.plist +0 -0
  28. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios.abi.json +2603 -0
  29. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +59 -0
  30. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  31. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios.swiftinterface +59 -0
  32. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/Modules/module.modulemap +4 -0
  33. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/RNSelligentMobileSDK +0 -0
  34. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/_CodeSignature/CodeResources +179 -0
  35. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Headers/RNSelligentMobileSDK-Swift.h +696 -0
  36. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Info.plist +0 -0
  37. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios-simulator.abi.json +2603 -0
  38. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +59 -0
  39. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  40. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +59 -0
  41. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +2603 -0
  42. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +59 -0
  43. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  44. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +59 -0
  45. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/module.modulemap +4 -0
  46. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/RNSelligentMobileSDK +0 -0
  47. package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/_CodeSignature/CodeResources +234 -0
  48. package/package.json +30 -11
  49. package/.gitattributes +0 -1
  50. package/CHANGELOG.md +0 -60
  51. package/android/README.md +0 -15
  52. package/android/build/generated/source/buildConfig/debug/com/selligent/BuildConfig.java +0 -12
  53. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +0 -9
  54. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output-metadata.json +0 -18
  55. package/android/build/intermediates/aar_metadata/debug/aar-metadata.properties +0 -4
  56. package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +0 -1
  57. package/android/build/intermediates/compile_library_classes_jar/debug/classes.jar +0 -0
  58. package/android/build/intermediates/compile_r_class_jar/debug/R.jar +0 -0
  59. package/android/build/intermediates/compile_symbol_list/debug/R.txt +0 -6548
  60. package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +0 -1
  61. package/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +0 -2
  62. package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +0 -2
  63. package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +0 -2
  64. package/android/build/intermediates/incremental/packageDebugAssets/merger.xml +0 -2
  65. package/android/build/intermediates/javac/debug/classes/com/selligent/BroadcastDataFactory$1.class +0 -0
  66. package/android/build/intermediates/javac/debug/classes/com/selligent/BroadcastDataFactory.class +0 -0
  67. package/android/build/intermediates/javac/debug/classes/com/selligent/BroadcastEventDataParser.class +0 -0
  68. package/android/build/intermediates/javac/debug/classes/com/selligent/BroadcastEventType.class +0 -0
  69. package/android/build/intermediates/javac/debug/classes/com/selligent/BuildConfig.class +0 -0
  70. package/android/build/intermediates/javac/debug/classes/com/selligent/ButtonBroadcastEventDataParser.class +0 -0
  71. package/android/build/intermediates/javac/debug/classes/com/selligent/ClearCacheIntervalValue.class +0 -0
  72. package/android/build/intermediates/javac/debug/classes/com/selligent/Event.class +0 -0
  73. package/android/build/intermediates/javac/debug/classes/com/selligent/EventReceiver.class +0 -0
  74. package/android/build/intermediates/javac/debug/classes/com/selligent/EventType.class +0 -0
  75. package/android/build/intermediates/javac/debug/classes/com/selligent/GCMTokenBroadcastEventDataParser.class +0 -0
  76. package/android/build/intermediates/javac/debug/classes/com/selligent/InAppMessageBroadcastEventDataParser.class +0 -0
  77. package/android/build/intermediates/javac/debug/classes/com/selligent/InAppMessageRefreshType.class +0 -0
  78. package/android/build/intermediates/javac/debug/classes/com/selligent/RNSelligent$1.class +0 -0
  79. package/android/build/intermediates/javac/debug/classes/com/selligent/RNSelligent$2.class +0 -0
  80. package/android/build/intermediates/javac/debug/classes/com/selligent/RNSelligent$3.class +0 -0
  81. package/android/build/intermediates/javac/debug/classes/com/selligent/RNSelligent$4.class +0 -0
  82. package/android/build/intermediates/javac/debug/classes/com/selligent/RNSelligent$5.class +0 -0
  83. package/android/build/intermediates/javac/debug/classes/com/selligent/RNSelligent.class +0 -0
  84. package/android/build/intermediates/javac/debug/classes/com/selligent/RNSelligentPackage.class +0 -0
  85. package/android/build/intermediates/javac/debug/classes/com/selligent/RemoteMessageDisplayType.class +0 -0
  86. package/android/build/intermediates/javac/debug/classes/com/selligent/SMEventFactory$1.class +0 -0
  87. package/android/build/intermediates/javac/debug/classes/com/selligent/SMEventFactory.class +0 -0
  88. package/android/build/intermediates/javac/debug/classes/com/selligent/SMSettingsFactory.class +0 -0
  89. package/android/build/intermediates/javac/debug/classes/com/selligent/Settings.class +0 -0
  90. package/android/build/intermediates/local_only_symbol_list/debug/R-def.txt +0 -2
  91. package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +0 -11
  92. package/android/build/intermediates/merged_manifest/debug/AndroidManifest.xml +0 -9
  93. package/android/build/intermediates/navigation_json/debug/navigation.json +0 -1
  94. package/android/build/intermediates/packaged_manifests/debug/output-metadata.json +0 -18
  95. package/android/build/intermediates/runtime_library_classes_jar/debug/classes.jar +0 -0
  96. package/android/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt +0 -4894
  97. package/android/build/outputs/logs/manifest-merger-debug-report.txt +0 -25
  98. package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
  99. package/android/libs/sdk-release.aar +0 -0
  100. package/documentation/add_json_file.png +0 -0
  101. package/documentation/add_lib_file.png +0 -0
  102. package/ios/BackgroundFetchResult.h +0 -5
  103. package/ios/ClearCacheInterval.h +0 -7
  104. package/ios/ClientSettings.h +0 -22
  105. package/ios/ClientSettings.m +0 -39
  106. package/ios/EnumMapper.h +0 -36
  107. package/ios/EnumMapper.m +0 -121
  108. package/ios/Event+SMEvent.h +0 -13
  109. package/ios/Event+SMEvent.m +0 -41
  110. package/ios/Event.h +0 -12
  111. package/ios/Event.m +0 -24
  112. package/ios/EventType.h +0 -7
  113. package/ios/InAppMessageRefreshType.h +0 -6
  114. package/ios/InAppMessageSettings.h +0 -9
  115. package/ios/InAppMessageSettings.m +0 -19
  116. package/ios/LocationAuthorisationStatus.h +0 -6
  117. package/ios/LocationAuthorisationType.h +0 -4
  118. package/ios/LogLevel.h +0 -9
  119. package/ios/NotificationButtonType.h +0 -15
  120. package/ios/ParsableObject.h +0 -5
  121. package/ios/RNSelligent.h +0 -22
  122. package/ios/RNSelligent.m +0 -347
  123. package/ios/RemoteMessageDisplayType.h +0 -5
  124. package/ios/SMManagerSetting+ClientSettings.h +0 -9
  125. package/ios/SMManagerSetting+ClientSettings.m +0 -73
  126. package/ios/SelligentLogger.h +0 -7
  127. package/ios/SelligentLogger.m +0 -9
  128. package/ios/SelligentReactNative.xcodeproj/project.pbxproj +0 -446
  129. package/ios/include/SMBaseMessage.h +0 -48
  130. package/ios/include/SMBlock.h +0 -21
  131. package/ios/include/SMClearCache.h +0 -34
  132. package/ios/include/SMContentAlignment.h +0 -27
  133. package/ios/include/SMDeviceInfos.h +0 -38
  134. package/ios/include/SMDisplayMode.h +0 -27
  135. package/ios/include/SMEvent.h +0 -69
  136. package/ios/include/SMEventUser.h +0 -20
  137. package/ios/include/SMEventUserLogin.h +0 -42
  138. package/ios/include/SMEventUserLogout.h +0 -42
  139. package/ios/include/SMEventUserRegistration.h +0 -42
  140. package/ios/include/SMEventUserUnregistration.h +0 -42
  141. package/ios/include/SMFailure.h +0 -19
  142. package/ios/include/SMHelper.h +0 -51
  143. package/ios/include/SMInAppContentHTMLViewController.h +0 -59
  144. package/ios/include/SMInAppContentImageViewController.h +0 -36
  145. package/ios/include/SMInAppContentMessage.h +0 -56
  146. package/ios/include/SMInAppContentStyleOptions.h +0 -511
  147. package/ios/include/SMInAppContentType.h +0 -35
  148. package/ios/include/SMInAppContentURLViewController.h +0 -36
  149. package/ios/include/SMInAppContentViewController.h +0 -31
  150. package/ios/include/SMInAppMessage.h +0 -51
  151. package/ios/include/SMInAppMessageType.h +0 -50
  152. package/ios/include/SMInAppRefreshType.h +0 -29
  153. package/ios/include/SMLink.h +0 -39
  154. package/ios/include/SMLog.h +0 -54
  155. package/ios/include/SMManager+DataTransaction.h +0 -33
  156. package/ios/include/SMManager+InAppContent.h +0 -170
  157. package/ios/include/SMManager+InAppMessage.h +0 -172
  158. package/ios/include/SMManager+Location.h +0 -41
  159. package/ios/include/SMManager+Log.h +0 -31
  160. package/ios/include/SMManager+RemoteNotification.h +0 -171
  161. package/ios/include/SMManager+SMEvent.h +0 -67
  162. package/ios/include/SMManager+SMLink.h +0 -44
  163. package/ios/include/SMManager+SilentPush.h +0 -53
  164. package/ios/include/SMManager+StyleOptions.h +0 -36
  165. package/ios/include/SMManager+UserNotification.h +0 -180
  166. package/ios/include/SMManager+ViewController.h +0 -45
  167. package/ios/include/SMManager.h +0 -69
  168. package/ios/include/SMManagerHelper.h +0 -18
  169. package/ios/include/SMManagerInAppMessageDelegate.h +0 -24
  170. package/ios/include/SMManagerSetting+Location.h +0 -27
  171. package/ios/include/SMManagerSetting.h +0 -180
  172. package/ios/include/SMManagerSettingIAC.h +0 -48
  173. package/ios/include/SMManagerSettingIAM.h +0 -49
  174. package/ios/include/SMManagerUniversalLinksDelegate.h +0 -23
  175. package/ios/include/SMMessage.h +0 -21
  176. package/ios/include/SMNSNotification.h +0 -81
  177. package/ios/include/SMNotificationAnnotationData.h +0 -33
  178. package/ios/include/SMNotificationButtonData.h +0 -20
  179. package/ios/include/SMNotificationButtonType.h +0 -90
  180. package/ios/include/SMNotificationMessage.h +0 -31
  181. package/ios/include/SMRemoteMessageDisplayType.h +0 -32
  182. package/ios/include/SMSuccess.h +0 -16
  183. package/ios/libSelligentMobile.a +0 -0
  184. package/trigger.yml +0 -9
@@ -6,6 +6,9 @@ import android.app.Application;
6
6
  import android.content.Intent;
7
7
  import android.content.IntentFilter;
8
8
  import android.content.res.Resources;
9
+
10
+ import androidx.appcompat.app.AppCompatActivity;
11
+ import androidx.lifecycle.Observer;
9
12
  import androidx.localbroadcastmanager.content.LocalBroadcastManager;
10
13
 
11
14
  import android.graphics.Color;
@@ -28,7 +31,6 @@ import com.facebook.react.modules.core.DeviceEventManagerModule;
28
31
  import com.google.gson.Gson;
29
32
  import com.google.gson.reflect.TypeToken;
30
33
  import com.selligent.sdk.SMCallback;
31
- import com.selligent.sdk.SMDeviceInfos;
32
34
  import com.selligent.sdk.SMEvent;
33
35
  import com.selligent.sdk.SMForegroundGcmBroadcastReceiver;
34
36
  import com.selligent.sdk.SMInAppMessage;
@@ -36,6 +38,7 @@ import com.selligent.sdk.SMInAppMessageReturn;
36
38
  import com.selligent.sdk.SMInAppRefreshType;
37
39
  import com.selligent.sdk.SMManager;
38
40
  import com.selligent.sdk.SMNotificationButton;
41
+ import com.selligent.sdk.SMNotificationMessage;
39
42
  import com.selligent.sdk.SMRemoteMessageDisplayType;
40
43
  import com.selligent.sdk.SMSettings;
41
44
 
@@ -48,9 +51,12 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
48
51
  private final SMManager smManager;
49
52
  private EventReceiver eventReceiver;
50
53
  private SMForegroundGcmBroadcastReceiver receiver;
54
+ private static SMInAppRefreshType inAppMessageRefreshType;
51
55
 
52
56
  public static final String REACT_CLASS = "SelligentReactNative"; // for logging purposes
53
57
 
58
+ private boolean areObserverStarted = false;
59
+
54
60
 
55
61
  public RNSelligent(ReactApplicationContext reactContext) {
56
62
  super(reactContext);
@@ -75,8 +81,10 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
75
81
  final String notificationActivityName = settings.getActivityName();
76
82
 
77
83
  SMManager.NOTIFICATION_ACTIVITY = (Class<? extends Activity>) Class.forName(notificationActivityName);
84
+ inAppMessageRefreshType = settings.getInAppMessageRefreshType().getSmInAppRefreshType();
78
85
 
79
86
  final SMManager smManager = SMManager.getInstance();
87
+ SMManager.DEBUG = BuildConfig.BUILD_TYPE.equals("debug");
80
88
  smManager.start(smSettings, application);
81
89
 
82
90
  final Resources resources = application.getResources();
@@ -120,16 +128,18 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
120
128
  @ReactMethod
121
129
  public void enableInAppMessages(ReadableMap enabled) {
122
130
  final ReadableType enabledType = enabled.getType("enabled");
131
+
123
132
  if (enabledType == ReadableType.Boolean) {
124
133
  enableInAppMessages(enabled.getBoolean("enabled"));
125
- } else if (enabledType == ReadableType.Number) {
134
+ }
135
+ else if (enabledType == ReadableType.Number) {
126
136
  enableInAppMessages(enabled.getInt("enabled"));
127
137
  }
128
138
  }
129
139
 
130
140
  private void enableInAppMessages(Boolean enable) {
131
141
  if (enable) {
132
- smManager.enableInAppMessages(SMInAppRefreshType.Daily);
142
+ smManager.enableInAppMessages(inAppMessageRefreshType);
133
143
  } else {
134
144
  smManager.disableInAppMessages();
135
145
  }
@@ -153,7 +163,7 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
153
163
  final Activity currentActivity = getCurrentActivity();
154
164
 
155
165
  if (currentActivity != null) {
156
- smManager.displayMessage(messageId, currentActivity);
166
+ smManager.displayInAppMessage(messageId, currentActivity);
157
167
  }
158
168
  }
159
169
 
@@ -187,7 +197,6 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
187
197
  buttonMap.putString("id", button.id);
188
198
  buttonMap.putString("value", button.value);
189
199
  buttonMap.putString("label", button.label);
190
- buttonMap.putInt("action", button.action.getValue());
191
200
  buttonMap.putInt("type", button.type);
192
201
 
193
202
  buttonsArray.pushMap(buttonMap);
@@ -206,18 +215,54 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
206
215
 
207
216
  @ReactMethod
208
217
  public void setInAppMessageAsSeen(final String messageId, final Callback successCallback, final Callback errorCallback) {
209
- smManager.getInAppMessages(new SMInAppMessageReturn() {
210
- @Override
211
- public void onRetrieve(ArrayList<SMInAppMessage> inAppMessages) {
212
- for(SMInAppMessage message : inAppMessages) {
213
- if(message.id.equals(messageId)) {
214
- smManager.setInAppMessageAsSeen(message);
215
- successCallback.invoke();
216
- return;
217
- }
218
+ smManager.getInAppMessages(inAppMessages ->
219
+ {
220
+ for(SMInAppMessage message : inAppMessages)
221
+ {
222
+ if(message.id.equals(messageId))
223
+ {
224
+ smManager.setInAppMessageAsSeen(message);
225
+ successCallback.invoke();
226
+ return;
218
227
  }
219
- errorCallback.invoke(String.format("No message with id %s found", messageId));
220
228
  }
229
+ errorCallback.invoke(String.format("No message with id %s found", messageId));
230
+ });
231
+ }
232
+
233
+ @ReactMethod
234
+ public void setInAppMessageAsUnseen(final String messageId, final Callback successCallback, final Callback errorCallback)
235
+ {
236
+ smManager.getInAppMessages(inAppMessages ->
237
+ {
238
+ for(SMInAppMessage message : inAppMessages)
239
+ {
240
+ if(message.id.equals(messageId))
241
+ {
242
+ smManager.setInAppMessageAsUnseen(message);
243
+ successCallback.invoke();
244
+ return;
245
+ }
246
+ }
247
+ errorCallback.invoke(String.format("No message with id %s found", messageId));
248
+ });
249
+ }
250
+
251
+ @ReactMethod
252
+ public void setInAppMessageAsDeleted(final String messageId, final Callback successCallback, final Callback errorCallback)
253
+ {
254
+ smManager.getInAppMessages(inAppMessages ->
255
+ {
256
+ for(SMInAppMessage message : inAppMessages)
257
+ {
258
+ if(message.id.equals(messageId))
259
+ {
260
+ smManager.deleteInAppMessage(messageId);
261
+ successCallback.invoke();
262
+ return;
263
+ }
264
+ }
265
+ errorCallback.invoke(String.format("No message with id %s found", messageId));
221
266
  });
222
267
  }
223
268
 
@@ -249,21 +294,6 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
249
294
  SMManager.DEBUG = enable;
250
295
  }
251
296
 
252
- @ReactMethod
253
- public void enableGeolocation(Boolean enable) {
254
- if (enable) {
255
- smManager.enableGeolocation();
256
- } else {
257
- smManager.disableGeolocation();
258
- }
259
- }
260
-
261
- @ReactMethod
262
- public void isGeolocationEnabled(Callback successCallback) {
263
- final Boolean isGeolocationEnabled = smManager.isGeolocationEnabled();
264
- successCallback.invoke(isGeolocationEnabled);
265
- }
266
-
267
297
  @ReactMethod
268
298
  public void sendEvent(ReadableMap eventMap, final Callback successCallback, final Callback errorCallback) {
269
299
  final Event event = Event.fromHashMap(eventMap.toHashMap());
@@ -298,25 +328,29 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
298
328
  }
299
329
 
300
330
  @ReactMethod
301
- public void displayLastReceivedRemotePushNotification() {
331
+ public void displayLastReceivedRemotePushNotification(String templateId) {
302
332
  final Activity currentActivity = getCurrentActivity();
303
333
 
304
334
  if (currentActivity != null) {
305
- smManager.displayLastReceivedRemotePushNotification(currentActivity);
335
+ smManager.displayLastReceivedNotificationContent(currentActivity);
306
336
  }
307
337
  }
308
338
 
339
+ @ReactMethod
340
+ public void displayLastReceivedNotification()
341
+ {
342
+ smManager.displayLastReceivedNotification();
343
+ }
344
+
309
345
  @ReactMethod
310
346
  public void getLastRemotePushNotification(Callback successCallback) {
311
- final HashMap<String, String> notificationMap = smManager.getLastRemotePushNotification();
347
+ final SMNotificationMessage notification = smManager.retrieveLastReceivedNotificationContent();
312
348
 
313
349
  WritableMap resultingNotificationMap = new WritableNativeMap();
314
- if (notificationMap != null) {
315
- final String id = notificationMap.get("id");
316
- final String title = notificationMap.get("title");
317
-
318
- resultingNotificationMap.putString("id", id);
319
- resultingNotificationMap.putString("title", title);
350
+
351
+ if (notification != null) {
352
+ resultingNotificationMap.putString("id", notification.getId());
353
+ resultingNotificationMap.putString("title", notification.getNotificationTitle());
320
354
  }
321
355
 
322
356
  successCallback.invoke(resultingNotificationMap);
@@ -393,31 +427,136 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
393
427
  public void subscribeToEvents(ReadableArray customEvents) {
394
428
  final Activity currentActivity = getCurrentActivity();
395
429
 
396
- if (currentActivity != null) {
430
+ if (currentActivity != null)
431
+ {
432
+ if (currentActivity instanceof AppCompatActivity)
433
+ {
434
+ AppCompatActivity thisActivity = (AppCompatActivity)currentActivity;
435
+ DeviceEventManagerModule.RCTDeviceEventEmitter rctDeviceEventEmitter = reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class);
436
+
437
+ thisActivity.runOnUiThread(() -> {
438
+ if (!areObserverStarted)
439
+ {
440
+ Log.d("RNSelligent", "Instantiating the observers on the UI thread");
441
+
442
+ // Token received
443
+ final Observer<String> tokenObserver = token -> {
444
+ String eventName = BroadcastEventType.ReceivedGCMToken.getBroadcastEventType();
445
+ GCMTokenBroadcastEventDataParser broadcastEventDataParser = new GCMTokenBroadcastEventDataParser();
446
+ final WritableMap data = broadcastEventDataParser.wrap(token);
447
+ rctDeviceEventEmitter.emit(eventName, getBroadcastData(eventName, data));
448
+ };
449
+ SMManager.getInstance().getObserverManager().observeToken(thisActivity, tokenObserver);
450
+
451
+ // Device id received
452
+ final Observer<String> deviceIdObserver = deviceId -> {
453
+ String eventName = BroadcastEventType.ReceivedDeviceId.getBroadcastEventType();
454
+ DeviceIdBroadcastEventDataParser broadcastEventDataParser = new DeviceIdBroadcastEventDataParser();
455
+ final WritableMap data = broadcastEventDataParser.wrap(deviceId);
456
+ rctDeviceEventEmitter.emit(eventName, getBroadcastData(eventName, data));
457
+ };
458
+ SMManager.getInstance().getObserverManager().observeDeviceId(thisActivity, deviceIdObserver);
459
+
460
+ // InApp messages received
461
+ final Observer<SMInAppMessage[]> inAppMessageObserver = inAppMessages -> {
462
+ if (inAppMessages != null)
463
+ {
464
+ String eventName = BroadcastEventType.ReceivedInAppMessage.getBroadcastEventType();
465
+ InAppMessageBroadcastEventDataParser broadcastEventDataParser = new InAppMessageBroadcastEventDataParser();
466
+ final WritableMap data = broadcastEventDataParser.wrap(inAppMessages);
467
+ rctDeviceEventEmitter.emit(eventName, getBroadcastData(eventName, data));
468
+ }
469
+ };
470
+ SMManager.getInstance().getObserverManager().observeInAppMessages(thisActivity, inAppMessageObserver);
471
+
472
+ // Button clicked
473
+ final Observer<SMNotificationButton> clickedButtonObserver = button -> {
474
+ if (button != null)
475
+ {
476
+ String eventName = BroadcastEventType.ButtonClicked.getBroadcastEventType();
477
+ ButtonBroadcastEventDataParser broadcastEventDataParser = new ButtonBroadcastEventDataParser();
478
+ final WritableMap data = broadcastEventDataParser.wrap(button);
479
+ rctDeviceEventEmitter.emit(eventName, getBroadcastData(eventName, data));
480
+ }
481
+ };
482
+ SMManager.getInstance().getObserverManager().observeClickedButton(thisActivity, clickedButtonObserver);
483
+
484
+ // Message dismissed
485
+ final Observer<Void> dismissedMessageObserver = object -> {
486
+ String eventName = BroadcastEventType.WillDismissNotification.getBroadcastEventType();
487
+ rctDeviceEventEmitter.emit(eventName, getBroadcastData(eventName, null));
488
+ };
489
+ SMManager.getInstance().getObserverManager().observeDismissedMessage(thisActivity, dismissedMessageObserver);
490
+
491
+ // Message displayed
492
+ final Observer<Void> displayedMessageObserver = object -> {
493
+ String eventName = BroadcastEventType.WillDisplayNotification.getBroadcastEventType();
494
+ rctDeviceEventEmitter.emit(eventName, getBroadcastData(eventName, null));
495
+ };
496
+ SMManager.getInstance().getObserverManager().observeDisplayedMessage(thisActivity, displayedMessageObserver);
497
+
498
+ // Push received
499
+ final Observer<SMNotificationMessage> pushReceivedObserver = notificationMessage -> {
500
+ if (notificationMessage != null)
501
+ {
502
+ String eventName = BroadcastEventType.ReceivedNotification.getBroadcastEventType();
503
+ NotificationMessageBroadcastEventDataParser broadcastEventDataParser = new NotificationMessageBroadcastEventDataParser();
504
+ final WritableMap data = broadcastEventDataParser.wrap(notificationMessage);
505
+ rctDeviceEventEmitter.emit(eventName, getBroadcastData(eventName, data));
506
+ }
507
+ };
508
+ SMManager.getInstance().getObserverManager().observePushReceived(thisActivity, pushReceivedObserver);
397
509
 
398
- final LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(currentActivity);
510
+ // 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);
399
515
 
400
- if (eventReceiver == null) {
401
- eventReceiver = new EventReceiver(reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class));
402
- } else {
403
- localBroadcastManager.unregisterReceiver(eventReceiver);
516
+ areObserverStarted = true;
517
+ }
518
+ else
519
+ {
520
+ Log.d("RNSelligent", "Observers already instantiated");
521
+ }
522
+ });
404
523
  }
524
+ else
525
+ {
526
+ final LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(currentActivity);
405
527
 
406
- final IntentFilter filter = new IntentFilter();
407
- filter.addAction(SMManager.BROADCAST_EVENT_RECEIVED_IN_APP_MESSAGE);
408
- filter.addAction(SMManager.BROADCAST_EVENT_RECEIVED_IN_APP_CONTENTS);
409
- filter.addAction(SMManager.BROADCAST_EVENT_WILL_DISPLAY_NOTIFICATION);
410
- filter.addAction(SMManager.BROADCAST_EVENT_WILL_DISMISS_NOTIFICATION);
411
- filter.addAction(SMManager.BROADCAST_EVENT_BUTTON_CLICKED);
412
- filter.addAction(SMManager.BROADCAST_EVENT_RECEIVED_GCM_TOKEN);
413
- for (int i = 0; i < customEvents.size(); i++) {
414
- filter.addAction(customEvents.getString(i));
415
- }
528
+ if (eventReceiver == null) {
529
+ eventReceiver = new EventReceiver(reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class));
530
+ } else {
531
+ localBroadcastManager.unregisterReceiver(eventReceiver);
532
+ }
533
+
534
+ final IntentFilter filter = new IntentFilter();
535
+ filter.addAction(SMManager.BROADCAST_EVENT_RECEIVED_IN_APP_MESSAGE);
536
+ filter.addAction(SMManager.BROADCAST_EVENT_WILL_DISPLAY_NOTIFICATION);
537
+ filter.addAction(SMManager.BROADCAST_EVENT_WILL_DISMISS_NOTIFICATION);
538
+ filter.addAction(SMManager.BROADCAST_EVENT_BUTTON_CLICKED);
539
+ filter.addAction(SMManager.BROADCAST_EVENT_RECEIVED_GCM_TOKEN);
416
540
 
417
- localBroadcastManager.registerReceiver(eventReceiver, filter);
541
+ for (int i = 0; i < customEvents.size(); i++) {
542
+ filter.addAction(customEvents.getString(i));
543
+ }
544
+
545
+ localBroadcastManager.registerReceiver(eventReceiver, filter);
546
+ }
418
547
  }
419
548
  }
420
549
 
550
+ WritableMap getBroadcastData(String eventName, WritableMap data)
551
+ {
552
+ final WritableMap broadcastData = new WritableNativeMap();
553
+
554
+ broadcastData.putString("broadcastEventType", eventName);
555
+ broadcastData.putMap("data", data);
556
+
557
+ return broadcastData;
558
+ }
559
+
421
560
  @ReactMethod
422
561
  public void setFirebaseToken(String token) {
423
562
  smManager.setFirebaseToken(token);
@@ -9,7 +9,6 @@ class SMSettingsFactory {
9
9
  smSettings.WebServiceUrl = settings.getUrl();
10
10
  smSettings.ClientId = settings.getClientId();
11
11
  smSettings.PrivateKey = settings.getPrivateKey();
12
- smSettings.ConfigureGeolocation = settings.getConfigureLocationServices();
13
12
  smSettings.AddInAppMessageFromPushToInAppMessageList = settings.getAddInAppMessageFromPushToInAppMessageList();
14
13
  smSettings.DoNotFetchTheToken = settings.getDoNotFetchTheToken();
15
14
  smSettings.DoNotListenToThePush = settings.getDoNotListenToThePush();
@@ -16,7 +16,6 @@ class Settings {
16
16
  private Boolean doNotFetchTheToken = false;
17
17
  private Boolean doNotListenToThePush = false;
18
18
  private Boolean loadCacheAsynchronously = false;
19
- private Boolean configureLocationServices = false;
20
19
  private ClearCacheIntervalValue clearCacheIntervalValue;
21
20
  private InAppMessageRefreshType inAppMessageRefreshType;
22
21
  private RemoteMessageDisplayType remoteMessageDisplayType;
@@ -54,10 +53,6 @@ class Settings {
54
53
  return notificationIconColor;
55
54
  }
56
55
 
57
- public Boolean getConfigureLocationServices() {
58
- return configureLocationServices;
59
- }
60
-
61
56
  public Boolean getDoNotListenToThePush() { return doNotListenToThePush; }
62
57
 
63
58
  public Boolean getAddInAppMessageFromPushToInAppMessageList() { return addInAppMessageFromPushToInAppMessageList; }
@@ -96,10 +91,6 @@ class Settings {
96
91
  settings.url = (String) settingsHashMap.get("url");
97
92
  settings.clientId = (String) settingsHashMap.get("clientId");
98
93
  settings.privateKey = (String) settingsHashMap.get("privateKey");
99
- if (settingsHashMap.containsKey("configureLocationServices")) {
100
- settings.configureLocationServices = (Boolean) settingsHashMap.get("configureLocationServices");
101
-
102
- }
103
94
  settings.activityName = (String) settingsHashMap.get("fullyQualifiedNotificationActivityClassName");
104
95
 
105
96
  if (settingsHashMap.containsKey("notificationSmallIcon")) {
package/constants.d.ts CHANGED
@@ -31,40 +31,15 @@ export namespace RemoteMessagesDisplayType {
31
31
  const NOTIFICATION = 22;
32
32
  }
33
33
 
34
- export namespace AndroidRemoteMessagesDisplayType {
35
- const AUTOMATIC = 20;
36
- const NONE = 21;
37
- const NOTIFICATION = 22;
38
- }
39
-
40
34
  export namespace iOSLogLevel {
41
35
  const NONE = 50;
42
36
  const INFO = 51;
43
37
  const WARNING = 52;
44
38
  const ERROR = 53;
45
39
  const HTTP_CALL = 54;
46
- const LOCATION = 55;
47
40
  const ALL = 56;
48
41
  }
49
42
 
50
- export namespace iOSBackgroundFetchResult {
51
- const NEW_DATA = 60;
52
- const NO_DATA = 61;
53
- const FAILED = 62;
54
- }
55
-
56
- export namespace iOSLocationAuthorisationStatus {
57
- const UNKNOWN = 70;
58
- const REFUSED = 71;
59
- const GRANTED_IN_USE = 72;
60
- const GRANTED_ALWAYS = 73;
61
- }
62
-
63
- export namespace iOSLocationAuthorisationType {
64
- const IN_USE = 80;
65
- const ALWAYS = 81;
66
- }
67
-
68
43
  export namespace EventType {
69
44
  const USER_REGISTER = 90;
70
45
  const USER_UNREGISTER = 91;
@@ -73,7 +48,7 @@ export namespace EventType {
73
48
  const CUSTOM = 94;
74
49
  }
75
50
 
76
- export namespace iOSNotificationButtonType {
51
+ export namespace NotificationButtonType {
77
52
  const UNKNOWN = 100;
78
53
  const SIMPLE_OPEN_PHONE_CALL = 101;
79
54
  const OPEN_SMS = 102;
@@ -82,12 +57,13 @@ export namespace iOSNotificationButtonType {
82
57
  const OPEN_APPLICATION = 105;
83
58
  const RATE_APPLICATION = 106;
84
59
  const CUSTOM_ACTION_BROADCAST_EVENT = 107;
85
- const RETURN_TEXT = 108;
86
- const RETURN_PHOTO = 109;
87
- const RETURN_TEXT_AND_PHOTO = 110;
88
60
  const PASSBOOK = 111;
61
+ const DEEPLINK = 112;
62
+ const SIMPLE = 113;
89
63
  }
90
64
 
65
+ export import iOSNotificationButtonType = NotificationButtonType;
66
+
91
67
  export namespace BroadcastEventType {
92
68
  const BUTTON_CLICKED = "ButtonClicked";
93
69
  const RECEIVED_IN_APP_MESSAGE = "ReceivedInAppMessage";
@@ -96,8 +72,6 @@ export namespace BroadcastEventType {
96
72
  const RECEIVED_GCM_TOKEN = "ReceivedGCMToken";
97
73
  const RECEIVED_DEVICE_ID = "ReceivedDeviceId";
98
74
  const RECEIVED_REMOTE_NOTIFICATION = "ReceivedRemoteNotification";
99
- }
100
-
101
- export namespace RemoteNotification {
102
- const FETCHED_REMOTE_NOTIFICATION = "FetchedRemoteNotification";
75
+ const UNIVERSAL_LINK_EXECUTED = "UniversalLinkExecuted";
76
+ const TRIGGERED_CUSTOM_EVENT = "TriggeredCustomEvent";
103
77
  }
package/constants.js CHANGED
@@ -1,9 +1,7 @@
1
- import { Platform } from 'react-native'
2
-
3
1
  /**
4
2
  * @module SelligentConstants
5
3
  */
6
- var SelligentConstants = {
4
+ const SelligentConstants = {
7
5
  /**
8
6
  * @description
9
7
  * Defines the interval value to clear the cache.
@@ -13,6 +11,8 @@ var SelligentConstants = {
13
11
  AUTO: 1,
14
12
  /** Don't clear cache */
15
13
  NONE: 2,
14
+ /** Clear cache daily */
15
+ DAY: 3,
16
16
  /** Clear cache weekly */
17
17
  WEEK: 4,
18
18
  /** Clear cache monthly */
@@ -27,6 +27,8 @@ var SelligentConstants = {
27
27
  InAppMessageRefreshType: {
28
28
  /** Refresh in-app messages none */
29
29
  NONE: 10,
30
+ /** Refresh in-app messages minutely */
31
+ MINUTE: 11,
30
32
  /** Refresh in-app messages hourly */
31
33
  HOUR: 12,
32
34
  /** Refresh in-app messages daily */
@@ -58,18 +60,6 @@ var SelligentConstants = {
58
60
  /** Display remote messages as notification */
59
61
  NOTIFICATION: 22
60
62
  },
61
- /**
62
- * @description
63
- * Defines if and how remote messages can be displayed on Android.
64
- */
65
- AndroidRemoteMessagesDisplayType: {
66
- /** Display remote messages automatically */
67
- AUTOMATIC: 20,
68
- /** Don't display remote messages */
69
- NONE: 21,
70
- /** Display remote messages as notification */
71
- NOTIFICATION: 22
72
- },
73
63
  /**
74
64
  * @description
75
65
  * Defines the level of output of logging messages on iOS.
@@ -85,47 +75,9 @@ var SelligentConstants = {
85
75
  ERROR: 53,
86
76
  /** Output HTTPCall */
87
77
  HTTP_CALL: 54,
88
- /** Output location */
89
- LOCATION: 55,
90
78
  /** Output everything */
91
79
  ALL: 56
92
80
  },
93
- /**
94
- * @description
95
- * Description of the possible results of a background fetch on iOS.
96
- */
97
- iOSBackgroundFetchResult: {
98
- /** Background fetch resulted in new data */
99
- NEW_DATA: 60,
100
- /** Background fetch resulted in no new data */
101
- NO_DATA: 61,
102
- /** Background fetch failed */
103
- FAILED: 62
104
- },
105
- /**
106
- * @description
107
- * Description of the possible status of use of location services on a device.
108
- */
109
- iOSLocationAuthorisationStatus: {
110
- /** Status of use of location services is unknown */
111
- UNKNOWN: 70,
112
- /** Use of location services is refused */
113
- REFUSED: 71,
114
- /** Use of location services is granted when in use */
115
- GRANTED_IN_USE: 72,
116
- /** Use of location services is always granted */
117
- GRANTED_ALWAYS: 73
118
- },
119
- /**
120
- * @description
121
- * Defines the level of request for the authorisation of usage of location services on a device.
122
- */
123
- iOSLocationAuthorisationType: {
124
- /** Request authorisation when in location services are in use */
125
- IN_USE: 80,
126
- /** Always request the authorisation of the location services */
127
- ALWAYS: 81
128
- },
129
81
  /**
130
82
  * @description
131
83
  * Defines the type of an event.
@@ -144,7 +96,37 @@ var SelligentConstants = {
144
96
  },
145
97
  /**
146
98
  * @description
147
- * Defines the type of button for notifications on iOS.
99
+ * Defines the type of button for notifications and inapp messages.
100
+ */
101
+ NotificationButtonType: {
102
+ /** Unknown button type */
103
+ UNKNOWN: 100,
104
+ /** Simple open phone call button type */
105
+ SIMPLE_OPEN_PHONE_CALL: 101,
106
+ /** Open sms button type */
107
+ OPEN_SMS: 102,
108
+ /** Open mail button type */
109
+ OPEN_MAIL: 103,
110
+ /** Open browser button type */
111
+ OPEN_BROWSER: 104,
112
+ /** Open application button type */
113
+ OPEN_APPLICATION: 105,
114
+ /** Rate application button type */
115
+ RATE_APPLICATION: 106,
116
+ /** Custom action broadcast event button type */
117
+ CUSTOM_ACTION_BROADCAST_EVENT: 107,
118
+ /** Passbook button type */
119
+ PASSBOOK: 111,
120
+ /** Deeplink button type */
121
+ DEEPLINK: 112,
122
+ /** Simple button type */
123
+ SIMPLE: 112
124
+ },
125
+ /**
126
+ * @description
127
+ * Defines the type of button for notifications and inapp messages on iOS.
128
+ *
129
+ * @deprecated Use NotificationButtonType instead.
148
130
  */
149
131
  iOSNotificationButtonType: {
150
132
  /** Unknown button type */
@@ -163,14 +145,12 @@ var SelligentConstants = {
163
145
  RATE_APPLICATION: 106,
164
146
  /** Custom action broadcast event button type */
165
147
  CUSTOM_ACTION_BROADCAST_EVENT: 107,
166
- /** Return text button type */
167
- RETURN_TEXT: 108,
168
- /** Return photo button type */
169
- RETURN_PHOTO: 109,
170
- /** Return text and photo button type */
171
- RETURN_TEXT_AND_PHOTO: 110,
172
148
  /** Passbook button type */
173
- PASSBOOK: 111
149
+ PASSBOOK: 111,
150
+ /** Deeplink button type */
151
+ DEEPLINK: 112,
152
+ /** Simple button type */
153
+ SIMPLE: 112
174
154
  },
175
155
  /**
176
156
  * @description
@@ -186,31 +166,17 @@ var SelligentConstants = {
186
166
  /** A notification will be dismissed */
187
167
  WILL_DISMISS_NOTIFICATION: "WillDismissNotification",
188
168
  /** A device id has been received */
189
- RECEIVED_DEVICE_ID: "ReceivedDeviceId"
169
+ RECEIVED_DEVICE_ID: "ReceivedDeviceId",
170
+ /** Received GCM TOKEN */
171
+ RECEIVED_GCM_TOKEN: "ReceivedGCMToken",
172
+ /** Received a remote notification */
173
+ RECEIVED_REMOTE_NOTIFICATION: "ReceivedRemoteNotification",
174
+ /** Received an universal link execution */
175
+ UNIVERSAL_LINK_EXECUTED: "UniversalLinkExecuted",
176
+ /** A custom event has been triggered */
177
+ TRIGGERED_CUSTOM_EVENT: "TriggeredCustomEvent"
190
178
  },
191
- /**
192
- * @description
193
- * Defines the type of a Remote Notification.
194
- */
195
- RemoteNotification: {}
196
- };
197
-
198
- // Android specific
199
- if (Platform.OS === 'android') {
200
- /** Clear cache daily */
201
- SelligentConstants.ClearCacheIntervalValue.DAY = 3
202
- /** Refresh in-app messages every minute */
203
- SelligentConstants.InAppMessageRefreshType.MINUTE = 11
204
- /** Received GCM TOKEN */
205
- SelligentConstants.BroadcastEventType.RECEIVED_GCM_TOKEN = "ReceivedGCMToken"
206
- }
207
179
 
208
- // iOS specific
209
- if (Platform.OS === 'ios') {
210
- /** Received a broadcast event */
211
- SelligentConstants.BroadcastEventType.RECEIVED_REMOTE_NOTIFICATION = "ReceivedRemoteNotification"
212
- /** Received a remote notification */
213
- SelligentConstants.RemoteNotification.FETCHED_REMOTE_NOTIFICATION = "FetchedRemoteNotification"
214
- }
180
+ };
215
181
 
216
182
  module.exports = SelligentConstants