@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
package/helpers.js CHANGED
@@ -1,6 +1,4 @@
1
- import {Platform} from 'react-native'
2
-
3
- var SelligentHelpers = {};
1
+ const SelligentHelpers = {};
4
2
 
5
3
  // ARGUMENTS SUCCESS MESSAGES
6
4
  SelligentHelpers.SUCCESS = "Action successful";
@@ -65,15 +63,16 @@ SelligentHelpers.wrongArgumentError = function (message) {
65
63
  }
66
64
 
67
65
  SelligentHelpers.constantIsValid = function (constants, constantToVerify) {
68
- var occursInConstants = false,
66
+ let occursInConstants = false,
69
67
  occursInAndroidSubConstants = false,
70
68
  occursInIOSSubConstants = false;
71
69
 
72
- Object.keys(constants).map(function (constant) {
73
- if (constants[constant] == constantToVerify) {
70
+ Object.keys(constants).forEach(function (constant) {
71
+ if (constants[constant] === constantToVerify) {
74
72
  occursInConstants = true;
75
73
  }
76
74
  });
75
+
77
76
  return occursInConstants || occursInAndroidSubConstants || occursInIOSSubConstants;
78
77
  };
79
78
 
package/index.android.js CHANGED
@@ -1,10 +1,9 @@
1
1
  // Android specific methods
2
- import { NativeEventEmitter, NativeModules } from 'react-native'
2
+ import { NativeModules } from 'react-native'
3
3
  import SelligentConstants from './constants'
4
4
  import SelligentHelpers from './helpers'
5
5
 
6
6
  const { RNSelligent } = NativeModules
7
- const RNSEventEmitter = new NativeEventEmitter(RNSelligent)
8
7
 
9
8
  export default {
10
9
  // Basic SMManager
@@ -18,17 +17,20 @@ export default {
18
17
  *
19
18
  * @param {function} successCallback Callback function on success.
20
19
  * @param {function} errorCallback Callback function on error.
21
- * @param {(boolean|InAppMessageRefreshType)} options Boolean to enable/disable in-app messages or an enum InAppMessageRefreshType to enable and set which in-app messages should be enabled.
20
+ * @param {(boolean|InAppMessageRefreshType)} enabled Boolean to enable/disable in-app messages or an enum InAppMessageRefreshType to enable and set which in-app messages should be enabled.
22
21
  */
23
22
  enableInAppMessages: function (successCallback, errorCallback, enabled) {
24
23
  if (!SelligentHelpers.typeMatches(enabled, 'number') && !SelligentHelpers.typeMatches(enabled, 'boolean')) {
25
24
  errorCallback(SelligentHelpers.wrongArgumentError('Expected a boolean or a number.'))
26
25
  return
27
26
  }
27
+ else if (SelligentHelpers.typeMatches(enabled, 'number') && !Object.values(SelligentConstants.InAppMessageRefreshType).includes(enabled)) {
28
+ errorCallback(SelligentHelpers.wrongArgumentError('Value should be one from InAppMessageRefreshType'))
29
+ return
30
+ }
28
31
 
29
32
  successCallback(SelligentHelpers.SUCCESS)
30
33
  RNSelligent.enableInAppMessages({ enabled })
31
- return
32
34
  },
33
35
 
34
36
  /**
@@ -40,31 +42,13 @@ export default {
40
42
  return RNSelligent.areInAppMessagesEnabled(successCallback)
41
43
  },
42
44
 
43
- /**
44
- * Display message on Android.
45
- *
46
- * @param {function} successCallback Callback function on success.
47
- * @param {function} errorCallback Callback function on error.
48
- * @param {string} messageId Id of the message.
49
- */
50
- displayMessage: function (successCallback, errorCallback, messageId) {
51
- if (!SelligentHelpers.typeMatches(messageId, 'string')) {
52
- errorCallback(SelligentHelpers.wrongArgumentError('Expected a string.'))
53
- return
54
- }
55
-
56
- successCallback(SelligentHelpers.SUCCESS)
57
- RNSelligent.displayMessage(messageId)
58
- return
59
- },
60
-
61
45
  // Log
62
46
  /**
63
47
  * Enable logging messages on Android.
64
48
  *
65
49
  * @param {function} successCallback Callback function on success.
66
50
  * @param {function} errorCallback Callback function on error.
67
- * @param {boolean} shouldEnableLoggingMessages Boolean to enable/disable logging messages on Android.
51
+ * @param {boolean} enabled Boolean to enable/disable logging messages on Android.
68
52
  */
69
53
  enableAndroidLogging: function (successCallback, errorCallback, enabled) {
70
54
  if (!SelligentHelpers.typeMatches(enabled, 'boolean')) {
@@ -74,7 +58,6 @@ export default {
74
58
 
75
59
  successCallback(SelligentHelpers.SUCCESS)
76
60
  RNSelligent.setDebug(enabled)
77
- return
78
61
  },
79
62
  // Remote Notification
80
63
 
@@ -85,7 +68,6 @@ export default {
85
68
  */
86
69
  areNotificationsEnabled: function (successCallback) {
87
70
  RNSelligent.areNotificationsEnabled(successCallback)
88
- return
89
71
  },
90
72
 
91
73
  /**
@@ -103,7 +85,6 @@ export default {
103
85
 
104
86
  successCallback(SelligentHelpers.SUCCESS)
105
87
  RNSelligent.setNotificationSmallIcon(iconName)
106
- return
107
88
  },
108
89
 
109
90
  /**
@@ -121,7 +102,6 @@ export default {
121
102
 
122
103
  successCallback(SelligentHelpers.SUCCESS)
123
104
  RNSelligent.setNotificationLargeIcon(iconName)
124
- return
125
105
  },
126
106
 
127
107
  /**
@@ -142,7 +122,6 @@ export default {
142
122
  }
143
123
 
144
124
  RNSelligent.setNotificationIconColor(color, _successCallback, errorCallback)
145
- return
146
125
  },
147
126
 
148
127
  /**
@@ -163,7 +142,6 @@ export default {
163
142
  }
164
143
 
165
144
  RNSelligent.setNotificationActivity(activityName, _successCallback, errorCallback)
166
- return
167
145
  },
168
146
 
169
147
  /**
@@ -173,69 +151,17 @@ export default {
173
151
  */
174
152
  getGCMToken: function (successCallback) {
175
153
  RNSelligent.getGCMToken(successCallback)
176
- return
177
154
  },
178
155
 
179
156
  /**
180
157
  * Get remote messages display type.
181
158
  *
182
159
  * @param {function} successCallback Callback function on success.
183
- * @param {function} errorCallback Callback function on error.
184
160
  */
185
161
  getRemoteMessagesDisplayType: function (successCallback) {
186
162
  RNSelligent.getRemoteMessagesDisplayType(successCallback)
187
- return
188
163
  },
189
- // Broadcasts Events
190
-
191
- /**
192
- * Subscribe to events.
193
- *
194
- * @param {function} successCallback Callback function on success.
195
- * @param {function} errorCallback Callback function on error.
196
- * @param {function} eventCallback Callback function on event.
197
- * @param {array} customEvents Array of custom events to subscribe to.
198
- */
199
- subscribeToEvents: function (successCallback, errorCallback, eventCallback, customEvents = []) {
200
-
201
- if (customEvents !== undefined) {
202
- if (!SelligentHelpers.typeMatches(customEvents, 'array')) {
203
- errorCallback(SelligentHelpers.createTypeErrorMessage('customEvents', customEvents, 'array'))
204
- return
205
- }
206
-
207
- // check if values are all strings
208
- var arrayLength = customEvents.length
209
- for (var i = 0; i < arrayLength; i++) {
210
- if (!SelligentHelpers.typeMatches(customEvents[i], 'string')) {
211
- errorCallback(SelligentHelpers.wrongArgumentError('Expected an array of strings.'))
212
- return
213
- }
214
- }
215
- }
216
-
217
- RNSEventEmitter.addListener(SelligentConstants.BroadcastEventType.BUTTON_CLICKED, eventCallback);
218
- RNSEventEmitter.addListener(SelligentConstants.BroadcastEventType.RECEIVED_IN_APP_MESSAGE, eventCallback);
219
- RNSEventEmitter.addListener(SelligentConstants.BroadcastEventType.WILL_DISPLAY_NOTIFICATION, eventCallback);
220
- RNSEventEmitter.addListener(SelligentConstants.BroadcastEventType.WILL_DISMISS_NOTIFICATION, eventCallback);
221
- RNSEventEmitter.addListener(SelligentConstants.BroadcastEventType.RECEIVED_GCM_TOKEN, eventCallback);
222
-
223
- successCallback(SelligentHelpers.SUCCESS)
224
- RNSelligent.subscribeToEvents(customEvents)
225
- return
226
- },
227
-
228
- /**
229
- * Subscribe to event.
230
- *
231
- * @param {function} eventCallback Callback function on event.
232
- * @param {string} eventName Name of the event to subscribe to.
233
- */
234
- subscribeToEvent: function (eventCallback, eventName) {
235
- RNSEventEmitter.addListener(eventName, eventCallback);
236
- return
237
- },
238
-
164
+
239
165
  /**
240
166
  * Set the firebase (GCM) token
241
167
  *
@@ -251,6 +177,5 @@ export default {
251
177
 
252
178
  successCallback(SelligentHelpers.SUCCESS)
253
179
  RNSelligent.setFirebaseToken(token)
254
- return
255
180
  },
256
181
  }
package/index.d.ts CHANGED
@@ -5,18 +5,22 @@ export function setInAppMessageAsSeen(
5
5
  errorCallback: Function,
6
6
  messageId: string
7
7
  ): void;
8
- export function executeButtonAction(
8
+ export function setInAppMessageAsUnseen(
9
9
  successCallback: Function,
10
10
  errorCallback: Function,
11
- buttonId: string,
12
11
  messageId: string
13
12
  ): void;
14
- export function enableGeolocation(
13
+ export function setInAppMessageAsDeleted(
15
14
  successCallback: Function,
16
15
  errorCallback: Function,
17
- enabled: boolean
16
+ messageId: string
17
+ ): void;
18
+ export function executeButtonAction(
19
+ successCallback: Function,
20
+ errorCallback: Function,
21
+ buttonId: string,
22
+ messageId: string
18
23
  ): void;
19
- export function isGeolocationEnabled(successCallback: Function): void;
20
24
  export function sendEvent(
21
25
  successCallback: Function,
22
26
  errorCallback: Function,
@@ -28,57 +32,53 @@ export function enableNotifications(
28
32
  errorCallback: Function,
29
33
  enabled: boolean
30
34
  ): void;
31
- export function registerForProvisionalRemoteNotification(
32
- successCallback: Function
33
- ): void;
34
35
  export function displayLastReceivedRemotePushNotification(
35
- successCallback: Function
36
+ successCallback: Function,
37
+ templateId?: string
36
38
  ): void;
39
+ export function displayLastReceivedNotification(): void;
37
40
  export function getLastRemotePushNotification(successCallback: Function): void;
38
-
39
- // IOS
40
41
  export function enableInAppMessages(
41
42
  successCallback: Function,
42
43
  errorCallback: Function,
43
- enabled: boolean
44
+ enabled: boolean | number
44
45
  ): void;
45
- export function enableiOSLogging(
46
+ export function subscribeToEvents(
46
47
  successCallback: Function,
47
48
  errorCallback: Function,
48
- logLevels: any[]
49
+ eventCallback: Function,
50
+ customEvents?: any[]
51
+ ): void;
52
+ export function subscribeToEvent(
53
+ eventCallback: Function,
54
+ eventName: string
49
55
  ): void;
50
56
  export function displayNotification(
51
57
  successCallback: Function,
52
58
  errorCallback: Function,
53
- notificationId: string
54
- ): void;
55
- export function registerRemoteNotificationFetchCompletionHandler(
56
- successCallback: Function,
57
- eventCallback: Function
59
+ notificationId: string,
60
+ templateId?: string
58
61
  ): void;
59
- export function forceRemoteNotificationBackgroundFetchResult(
62
+ export function displayMessage(
60
63
  successCallback: Function,
61
64
  errorCallback: Function,
62
- iOSBackgroundFetchResult: any
65
+ messageId: string,
66
+ templateId?: string
63
67
  ): void;
64
- export function subscribeToEvents(
68
+
69
+ // IOS
70
+ export function enableiOSLogging(
65
71
  successCallback: Function,
66
72
  errorCallback: Function,
67
- eventCallback: Function
73
+ logLevels: any[]
68
74
  ): void;
75
+ export function registerForProvisionalRemoteNotification(
76
+ successCallback: Function
77
+ ): void;
78
+ export function executePushAction(): void;
69
79
 
70
80
  // ANDROID
71
- export function enableInAppMessages(
72
- successCallback: Function,
73
- errorCallback: Function,
74
- enabled: boolean | number
75
- ): void;
76
81
  export function areInAppMessagesEnabled(successCallback: Function): any;
77
- export function displayMessage(
78
- successCallback: Function,
79
- errorCallback: Function,
80
- messageId: string
81
- ): void;
82
82
  export function enableAndroidLogging(
83
83
  successCallback: Function,
84
84
  errorCallback: Function,
@@ -107,16 +107,6 @@ export function setNotificationActivity(
107
107
  ): void;
108
108
  export function getGCMToken(successCallback: Function): void;
109
109
  export function getRemoteMessagesDisplayType(successCallback: Function): void;
110
- export function subscribeToEvents(
111
- successCallback: Function,
112
- errorCallback: Function,
113
- eventCallback: Function,
114
- customEvents?: any[]
115
- ): void;
116
- export function subscribeToEvent(
117
- eventCallback: Function,
118
- eventName: string
119
- ): void;
120
110
  export function setFirebaseToken(
121
111
  successCallback: Function,
122
112
  errorCallback: Function,
package/index.ios.js CHANGED
@@ -1,10 +1,9 @@
1
1
  // iOS specific methods
2
- import { NativeEventEmitter, NativeModules } from 'react-native'
2
+ import { NativeModules } from 'react-native'
3
3
  import SelligentConstants from './constants'
4
4
  import SelligentHelpers from './helpers'
5
5
 
6
6
  const { RNSelligent } = NativeModules
7
- const RNSEventEmitter = new NativeEventEmitter(RNSelligent)
8
7
 
9
8
  export default {
10
9
  // Basic SMManager
@@ -16,17 +15,30 @@ export default {
16
15
  *
17
16
  * @param {function} successCallback Callback function on success.
18
17
  * @param {function} errorCallback Callback function on error.
19
- * @param {boolean} enabled Boolean to enable/disable in-app messages.
18
+ * @param {boolean | number} enabled Boolean to enable/disable in-app messages.
20
19
  */
21
20
  enableInAppMessages: function (successCallback, errorCallback, enabled) {
22
- if (!SelligentHelpers.typeMatches(enabled, 'boolean')) {
23
- errorCallback(SelligentHelpers.wrongArgumentError('Expected a boolean.'))
21
+ if (!SelligentHelpers.typeMatches(enabled, 'number') && !SelligentHelpers.typeMatches(enabled, 'boolean')) {
22
+ errorCallback(SelligentHelpers.wrongArgumentError('Expected a boolean or a number.'))
24
23
  return
25
24
  }
26
25
 
26
+ let result;
27
+
28
+ if (typeof enabled === 'boolean'){
29
+ result = enabled
30
+ }
31
+ else {
32
+ if (!Object.values(SelligentConstants.InAppMessageRefreshType).includes(enabled)) {
33
+ errorCallback(SelligentHelpers.wrongArgumentError('Value should be one from InAppMessageRefreshType'))
34
+ return
35
+ }
36
+
37
+ result = enabled !== SelligentConstants.InAppMessageRefreshType.NONE;
38
+ }
39
+
27
40
  successCallback(SelligentHelpers.SUCCESS)
28
- RNSelligent.enableInAppMessages(enabled)
29
- return
41
+ RNSelligent.enableInAppMessages(result)
30
42
  },
31
43
  // Log
32
44
 
@@ -44,8 +56,8 @@ export default {
44
56
  }
45
57
 
46
58
  // check if values are all numbers and iOS Loglevels
47
- var arrayLength = logLevels.length
48
- for (var i = 0; i < arrayLength; i++) {
59
+ const arrayLength = logLevels.length;
60
+ for (let i = 0; i < arrayLength; i++) {
49
61
 
50
62
  if (!SelligentHelpers.typeMatches(logLevels[i], 'number')) {
51
63
  errorCallback(SelligentHelpers.wrongArgumentError('Expected a number.'))
@@ -60,58 +72,9 @@ export default {
60
72
 
61
73
  successCallback(SelligentHelpers.SUCCESS)
62
74
  RNSelligent.applyLogLevel(logLevels)
63
- return
64
75
  },
65
76
  // Remote Notification
66
77
 
67
- /**
68
- * Display notification by id on iOS.
69
- *
70
- * @param {function} successCallback Callback function on success.
71
- * @param {function} errorCallback Callback function on error.
72
- * @param {string} notificationId Id of the notification.
73
- */
74
- displayNotification: function (successCallback, errorCallback, notificationId) {
75
- if (!SelligentHelpers.typeMatches(notificationId, 'string') || notificationId.length === 0) {
76
- errorCallback(SelligentHelpers.wrongArgumentError('Expected a string (not empty).'))
77
- return
78
- }
79
-
80
- successCallback(SelligentHelpers.SUCCESS)
81
- RNSelligent.displayNotification(notificationId)
82
- return
83
- },
84
-
85
- /**
86
- * Register a completion handler for successfully fetching remote notifications.
87
- *
88
- * @param {function} successCallback Completion handler.
89
- * @param {function} eventCallback Callback function on event.
90
- */
91
- registerRemoteNotificationFetchCompletionHandler: function (successCallback, eventCallback) {
92
- RNSEventEmitter.addListener(SelligentConstants.RemoteNotification.FETCHED_REMOTE_NOTIFICATION, eventCallback);
93
- successCallback(SelligentHelpers.SUCCESS)
94
- return
95
- },
96
-
97
- /**
98
- * Force the result of a remote notification fetch to be a specific value.
99
- *
100
- * @param {function} successCallback Callback function on success.
101
- * @param {function} errorCallback Callback function on error.
102
- * @param {iOSBackgroundFetchResult} iOSBackgroundFetchResult Type of result to force, when fetching remote notifications.
103
- */
104
- forceRemoteNotificationBackgroundFetchResult: function (successCallback, errorCallback, iOSBackgroundFetchResult) {
105
- if (!SelligentHelpers.typeMatches(iOSBackgroundFetchResult, 'number') || !SelligentHelpers.constantIsValid(SelligentConstants.iOSBackgroundFetchResult, iOSBackgroundFetchResult)) {
106
- errorCallback(SelligentHelpers.wrongArgumentError('Expected a value of Selligent constant enum "iOSBackgroundFetchResult".'))
107
- return
108
- }
109
-
110
- successCallback(SelligentHelpers.SUCCESS)
111
- RNSelligent.forceRemoteNotificationBackgroundFetchResult(iOSBackgroundFetchResult)
112
- return
113
- },
114
-
115
78
  /**
116
79
  * Register for Provisional Push Notifications.
117
80
  *
@@ -120,26 +83,12 @@ export default {
120
83
  registerForProvisionalRemoteNotification: function (successCallback) {
121
84
  successCallback(SelligentHelpers.SUCCESS)
122
85
  RNSelligent.registerForProvisionalRemoteNotification()
123
- return
124
86
  },
125
87
 
126
- // Broadcasts Events
127
-
128
88
  /**
129
- * Subscribe to events.
130
- *
131
- * @param {function} successCallback Callback function on success.
132
- * @param {function} errorCallback Callback function on error.
133
- * @param {function} eventCallback Callback function on event.
89
+ * Tells the Selligent SDK to execute the action associated to the last push clicked, when using `delayedPushAction` feature
134
90
  */
135
- subscribeToEvents: function (successCallback, errorCallback, eventCallback) {
136
- RNSEventEmitter.addListener(SelligentConstants.BroadcastEventType.RECEIVED_IN_APP_MESSAGE, eventCallback);
137
- RNSEventEmitter.addListener(SelligentConstants.BroadcastEventType.WILL_DISPLAY_NOTIFICATION, eventCallback);
138
- RNSEventEmitter.addListener(SelligentConstants.BroadcastEventType.WILL_DISMISS_NOTIFICATION, eventCallback);
139
- RNSEventEmitter.addListener(SelligentConstants.BroadcastEventType.RECEIVED_REMOTE_NOTIFICATION, eventCallback);
140
-
141
- successCallback(SelligentHelpers.SUCCESS)
142
- RNSelligent.subscribeToEvents()
143
- return
91
+ executePushAction: function () {
92
+ RNSelligent.executePushAction()
144
93
  }
145
- }
94
+ }