@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/index.js CHANGED
@@ -1,8 +1,9 @@
1
- import { NativeModules, Platform } from 'react-native'
1
+ import { NativeEventEmitter, NativeModules, Platform } from 'react-native'
2
2
  import SelligentConstants from './constants'
3
3
  import SelligentHelpers from './helpers'
4
4
 
5
5
  const { RNSelligent } = NativeModules
6
+ export const RNSEventEmitter = new NativeEventEmitter(RNSelligent)
6
7
 
7
8
  // Check if Native version of Selligent found
8
9
  SelligentHelpers.isNativeSelligentFound(RNSelligent)
@@ -11,7 +12,7 @@ SelligentHelpers.isNativeSelligentFound(RNSelligent)
11
12
  // export default RNSelligent;
12
13
 
13
14
  // platform specific code
14
- var platformSpecificMethods = {}
15
+ let platformSpecificMethods = {};
15
16
 
16
17
  if (Platform.OS === 'android') {
17
18
  platformSpecificMethods = require('./index.android.js').default
@@ -27,30 +28,27 @@ export default Object.assign(
27
28
  // Basic SMManager
28
29
 
29
30
  /**
30
- * Returns the version of the underlying Selligent SDK.
31
+ * Returns the version of the underlying Selligent native SDK.
31
32
  *
32
33
  * @param {function} successCallback Callback function on success.
33
34
  */
34
35
  getVersionLib: function (successCallback) {
35
36
  RNSelligent.getVersionLib(successCallback)
36
- return
37
37
  },
38
- // DataTransaction
39
38
 
40
39
  // InAppMessage
41
40
 
42
41
  /**
43
- * Get in app messages.
42
+ * Gets all known (and not deleted/expired) in app messages.
44
43
  *
45
44
  * @param {function} successCallback Callback function on success.
46
45
  */
47
46
  getInAppMessages: function (successCallback) {
48
47
  RNSelligent.getInAppMessages(successCallback)
49
- return
50
48
  },
51
49
 
52
50
  /**
53
- * Set in app message as seen
51
+ * Sets an in app message as seen
54
52
  *
55
53
  * @param {function} successCallback Callback function on success.
56
54
  * @param {function} errorCallback Callback function on error.
@@ -69,7 +67,50 @@ export default Object.assign(
69
67
  }
70
68
 
71
69
  RNSelligent.setInAppMessageAsSeen(messageId, _successCallback, errorCallback)
72
- return
70
+ },
71
+
72
+ /**
73
+ * Sets an in app message as unseen
74
+ *
75
+ * @param {function} successCallback Callback function on success.
76
+ * @param {function} errorCallback Callback function on error.
77
+ * @param {string} messageId Message id to identify the message which has been unseen.
78
+ */
79
+ setInAppMessageAsUnseen: function (successCallback, errorCallback, messageId) {
80
+ // check if required options are valid
81
+ if (!SelligentHelpers.typeMatches(messageId, 'string')) {
82
+ errorCallback(SelligentHelpers.wrongArgumentError('Expected a string.'))
83
+ return
84
+ }
85
+
86
+ // continue if options are valid
87
+ const _successCallback = () => {
88
+ successCallback(SelligentHelpers.SUCCESS)
89
+ }
90
+
91
+ RNSelligent.setInAppMessageAsUnseen(messageId, _successCallback, errorCallback)
92
+ },
93
+
94
+ /**
95
+ * Sets an in app message as deleted
96
+ *
97
+ * @param {function} successCallback Callback function on success.
98
+ * @param {function} errorCallback Callback function on error.
99
+ * @param {string} messageId Message id to identify the message which has been deleted.
100
+ */
101
+ setInAppMessageAsDeleted: function (successCallback, errorCallback, messageId) {
102
+ // check if required options are valid
103
+ if (!SelligentHelpers.typeMatches(messageId, 'string')) {
104
+ errorCallback(SelligentHelpers.wrongArgumentError('Expected a string.'))
105
+ return
106
+ }
107
+
108
+ // continue if options are valid
109
+ const _successCallback = () => {
110
+ successCallback(SelligentHelpers.SUCCESS)
111
+ }
112
+
113
+ RNSelligent.setInAppMessageAsDeleted(messageId, _successCallback, errorCallback)
73
114
  },
74
115
 
75
116
  /**
@@ -77,7 +118,7 @@ export default Object.assign(
77
118
  *
78
119
  * @param {function} successCallback Callback function on success.
79
120
  * @param {function} errorCallback Callback function on error.
80
- * @param {string} buttonId Button id to identify the message.
121
+ * @param {string} buttonId Button id to identify the button.
81
122
  * @param {string} messageId Message id to identify the message.
82
123
  */
83
124
  executeButtonAction: function (successCallback, errorCallback, buttonId, messageId) {
@@ -85,7 +126,7 @@ export default Object.assign(
85
126
  errorCallback(SelligentHelpers.wrongArgumentError('Expected buttonId to be a string.'))
86
127
  return
87
128
  }
88
- if (!SelligentHelpers.typeMatches(messageId, 'string')) {
129
+ else if (!SelligentHelpers.typeMatches(messageId, 'string')) {
89
130
  errorCallback(SelligentHelpers.wrongArgumentError('Expected messageId to be a string.'))
90
131
  return
91
132
  }
@@ -95,39 +136,43 @@ export default Object.assign(
95
136
  }
96
137
 
97
138
  RNSelligent.executeButtonAction(buttonId, messageId, _successCallback, errorCallback)
98
- return
99
139
  },
100
140
 
101
- // Location
141
+ /**
142
+ * Displays an inapp message given its id, (optionally with a specific templateId to use custom styles).
143
+ * @deprecated Use displayMessage instead.
144
+ *
145
+ * @param {function} successCallback Callback function on success.
146
+ * @param {function} errorCallback Callback function on error.
147
+ * @param {string} notificationId Id of the notification.
148
+ * @param {string} templateId Id of the template from where to get the styles.
149
+ */
150
+ displayNotification: function (successCallback, errorCallback, notificationId, templateId) {
151
+ this.displayMessage(successCallback, errorCallback, notificationId, templateId)
152
+ },
102
153
 
103
154
  /**
104
- * Enable/disable geolocation.
105
- *
155
+ * Displays an inapp message given its id, (optionally with a specific templateId to use custom styles for iOS).
156
+ *
106
157
  * @param {function} successCallback Callback function on success.
107
158
  * @param {function} errorCallback Callback function on error.
108
- * @param {boolean} enabled Boolean to enable or disable geolocation.
159
+ * @param {string} messageId Id of the message.
160
+ * @param {string} templateId Id of the template from where to get the styles (iOS only).
109
161
  */
110
- enableGeolocation: function (successCallback, errorCallback, enabled) {
111
- // check if required options are valid
112
- if (!SelligentHelpers.typeMatches(enabled, 'boolean')) {
113
- errorCallback(SelligentHelpers.wrongArgumentError('Expected a boolean.'))
162
+ displayMessage: function (successCallback, errorCallback, messageId, templateId) {
163
+ if (!SelligentHelpers.typeMatches(messageId, 'string') || messageId.length === 0) {
164
+ errorCallback(SelligentHelpers.wrongArgumentError('Expected a string (not empty) messageId.'))
114
165
  return
115
166
  }
116
167
 
117
- // continue if options are valid
118
168
  successCallback(SelligentHelpers.SUCCESS)
119
- RNSelligent.enableGeolocation(enabled)
120
- return
121
- },
122
169
 
123
- /**
124
- * Check if geolocation is enabled or disabled.
125
- *
126
- * @param {function} successCallback Callback function on success.
127
- */
128
- isGeolocationEnabled: function (successCallback) {
129
- RNSelligent.isGeolocationEnabled(successCallback)
130
- return
170
+ if (Platform.OS === 'ios') {
171
+ RNSelligent.displayNotification(messageId, templateId)
172
+ }
173
+ else if (Platform.OS === 'android') {
174
+ RNSelligent.displayMessage(messageId)
175
+ }
131
176
  },
132
177
 
133
178
  // Event
@@ -159,11 +204,10 @@ export default Object.assign(
159
204
  if (event.hasOwnProperty('email')) {
160
205
  console.warn("Email prop is not used with \"custom\" event type and will be ignored.");
161
206
  }
162
- } else {
163
- if (!SelligentHelpers.hasRequiredParameterAndMatchesType(event, 'email', 'string')) {
164
- errorCallback(SelligentHelpers.wrongArgumentError('Expected an object with the key "email".'))
165
- return
166
- }
207
+ }
208
+ else if (!SelligentHelpers.hasRequiredParameterAndMatchesType(event, 'email', 'string')) {
209
+ errorCallback(SelligentHelpers.wrongArgumentError('Expected an object with the key "email".'))
210
+ return
167
211
  }
168
212
 
169
213
  if (!SelligentHelpers.hasOptionalParameterAndMatchesType(event, 'shouldCache', 'boolean')) {
@@ -173,7 +217,6 @@ export default Object.assign(
173
217
 
174
218
  // continue if options are valid
175
219
  RNSelligent.sendEvent(event, successCallback, errorCallback)
176
- return
177
220
  },
178
221
  // Device Id
179
222
  /**
@@ -183,7 +226,6 @@ export default Object.assign(
183
226
  */
184
227
  getDeviceId: function (successCallback) {
185
228
  RNSelligent.getDeviceId(successCallback)
186
- return
187
229
  },
188
230
 
189
231
  // Remote Notifications
@@ -205,18 +247,24 @@ export default Object.assign(
205
247
  // continue if options are valid
206
248
  successCallback(SelligentHelpers.SUCCESS)
207
249
  RNSelligent.enableNotifications(enabled)
208
- return
209
250
  },
210
251
 
211
252
  /**
212
- * Display the last received remote push notification
253
+ * Displays the last received remote push notification content (optionally, on iOS, with a specific templateId to use custom styles).
213
254
  *
214
255
  * @param {function} successCallback Callback function on success.
256
+ * @param {string} templateId Id of the template from where to get the styles.
215
257
  */
216
- displayLastReceivedRemotePushNotification: function (successCallback) {
258
+ displayLastReceivedRemotePushNotification: function (successCallback, templateId) {
217
259
  successCallback(SelligentHelpers.SUCCESS)
218
- RNSelligent.displayLastReceivedRemotePushNotification()
219
- return
260
+ RNSelligent.displayLastReceivedRemotePushNotification(templateId)
261
+ },
262
+
263
+ /**
264
+ * Displays the last received remote push notification (if any).
265
+ */
266
+ displayLastReceivedNotification: function() {
267
+ RNSelligent.displayLastReceivedNotification()
220
268
  },
221
269
 
222
270
  /**
@@ -226,7 +274,67 @@ export default Object.assign(
226
274
  */
227
275
  getLastRemotePushNotification: function (successCallback) {
228
276
  RNSelligent.getLastRemotePushNotification(successCallback)
229
- return
277
+ },
278
+
279
+ /**
280
+ * Subscribe to events.
281
+ *
282
+ * @param {function} successCallback Callback function on success.
283
+ * @param {function} errorCallback Callback function on error.
284
+ * @param {function} eventCallback Callback function on event.
285
+ * @param {array} customEvents Array of custom events to subscribe to.
286
+ */
287
+ subscribeToEvents: function (successCallback, errorCallback, eventCallback, customEvents = []) {
288
+ if (customEvents !== undefined) {
289
+ if (!SelligentHelpers.typeMatches(customEvents, 'array')) {
290
+ errorCallback(SelligentHelpers.createTypeErrorMessage('customEvents', customEvents, 'array'))
291
+ return
292
+ }
293
+
294
+ // check if values are all strings
295
+ const arrayLength = customEvents.length;
296
+ for (let i = 0; i < arrayLength; i++) {
297
+ if (!SelligentHelpers.typeMatches(customEvents[i], 'string')) {
298
+ errorCallback(SelligentHelpers.wrongArgumentError('Expected an array of strings.'))
299
+ return
300
+ }
301
+ }
302
+ }
303
+
304
+ RNSEventEmitter.addListener(SelligentConstants.BroadcastEventType.BUTTON_CLICKED, eventCallback);
305
+ RNSEventEmitter.addListener(SelligentConstants.BroadcastEventType.RECEIVED_IN_APP_MESSAGE, eventCallback);
306
+ RNSEventEmitter.addListener(SelligentConstants.BroadcastEventType.WILL_DISPLAY_NOTIFICATION, eventCallback);
307
+ RNSEventEmitter.addListener(SelligentConstants.BroadcastEventType.WILL_DISMISS_NOTIFICATION, eventCallback);
308
+ RNSEventEmitter.addListener(SelligentConstants.BroadcastEventType.RECEIVED_DEVICE_ID, eventCallback);
309
+ RNSEventEmitter.addListener(SelligentConstants.BroadcastEventType.RECEIVED_REMOTE_NOTIFICATION, eventCallback);
310
+ RNSEventEmitter.addListener(SelligentConstants.BroadcastEventType.TRIGGERED_CUSTOM_EVENT, eventCallback);
311
+
312
+ if (Platform.OS === "ios") {
313
+ RNSEventEmitter.addListener(SelligentConstants.BroadcastEventType.UNIVERSAL_LINK_EXECUTED, eventCallback);
314
+ }
315
+ else if (Platform.OS === "android") {
316
+ RNSEventEmitter.addListener(SelligentConstants.BroadcastEventType.RECEIVED_GCM_TOKEN, eventCallback);
317
+ }
318
+
319
+ successCallback(SelligentHelpers.SUCCESS)
320
+ RNSelligent.subscribeToEvents(customEvents)
321
+ },
322
+
323
+ /**
324
+ * Subscribe to event.
325
+ *
326
+ * @param {function} eventCallback Callback function on event.
327
+ * @param {string} eventName Name of the custom event to subscribe to.
328
+ */
329
+ subscribeToEvent: function (eventCallback, eventName) {
330
+ if (Object.values(SelligentConstants.BroadcastEventType).includes(eventName)) {
331
+ RNSEventEmitter.addListener(eventName, eventCallback)
332
+ }
333
+ else {
334
+ RNSEventEmitter.addListener(SelligentConstants.BroadcastEventType.TRIGGERED_CUSTOM_EVENT, eventCallback)
335
+ }
336
+
337
+ RNSelligent.subscribeToEvents([eventName])
230
338
  }
231
339
  },
232
340
  { ...platformSpecificMethods }
@@ -0,0 +1,21 @@
1
+ //
2
+ // RNSelligentMapper.h
3
+ // SelligentDevAppRN
4
+ //
5
+ // Created by Marc Biosca on 16/5/23.
6
+ // Copyright © 2023 Facebook. All rights reserved.
7
+ //
8
+
9
+ #if __has_include(<React/RCTBridgeModule.h>)
10
+ #import <React/RCTBridgeModule.h>
11
+ #import <React/RCTEventEmitter.h>
12
+ #else
13
+ #import "RCTBridgeModule.h"
14
+ #import <RCTEventEmitter.h>
15
+ #endif
16
+
17
+ @import RNSelligentMobileSDK;
18
+
19
+ @interface RNSelligentMapper : RCTEventEmitter <RCTBridgeModule, RNSelligentEventHandlerProtocol>
20
+
21
+ @end
@@ -0,0 +1,151 @@
1
+ #import "RNSelligentMapper.h"
2
+
3
+ @implementation RNSelligentMapper
4
+
5
+ RCT_EXPORT_MODULE(RNSelligent)
6
+
7
+ - (instancetype) init {
8
+ self = [super init];
9
+
10
+ RNSelligent.eventDelegate = self;
11
+
12
+ return self;
13
+ }
14
+
15
+ + (BOOL) requiresMainQueueSetup {
16
+ return true;
17
+ }
18
+
19
+ #pragma mark - Helpers
20
+
21
+ RCT_EXPORT_METHOD(getVersionLib:(RCTResponseSenderBlock)callback) {
22
+ callback(@[[RNSelligent getVersionLib], [NSNull null]]);
23
+ }
24
+
25
+ RCT_EXPORT_METHOD(getDeviceId:(RCTResponseSenderBlock)callback) {
26
+ callback(@[[RNSelligent getDeviceId], [NSNull null]]);
27
+ }
28
+
29
+ RCT_EXPORT_METHOD(executePushAction) {
30
+ [RNSelligent executePushAction];
31
+ }
32
+
33
+ RCT_EXPORT_METHOD(applyLogLevel:(NSArray<NSNumber *> *)logLevels) {
34
+ [RNSelligent applyLogLevel:logLevels];
35
+ }
36
+
37
+ #pragma mark - Push
38
+
39
+ RCT_EXPORT_METHOD(enableNotifications:(BOOL)enable) {
40
+ [RNSelligent enableNotifications:enable];
41
+ }
42
+
43
+ RCT_EXPORT_METHOD(registerForProvisionalRemoteNotification) {
44
+ [RNSelligent registerForProvisionalRemoteNotification];
45
+ }
46
+
47
+ RCT_EXPORT_METHOD(displayLastReceivedRemotePushNotification:(NSString *)templateId) {
48
+ [RNSelligent displayLastReceivedRemotePushNotificationWithTemplateId:templateId];
49
+ }
50
+
51
+ RCT_EXPORT_METHOD(getLastRemotePushNotification:(RCTResponseSenderBlock)callback) {
52
+ callback(@[[RNSelligent getLastRemotePushNotification] ?: [NSNull null], [NSNull null]]);
53
+ }
54
+
55
+ #pragma mark - IAM
56
+
57
+ RCT_EXPORT_METHOD(enableInAppMessages:(BOOL)enabled) {
58
+ [RNSelligent enableInAppMessages:enabled];
59
+ }
60
+
61
+ RCT_EXPORT_METHOD(getInAppMessages:(RCTResponseSenderBlock)callback) {
62
+ callback(@[[RNSelligent getInAppMessages] ?: [NSNull null], [NSNull null]]);
63
+ }
64
+
65
+ RCT_EXPORT_METHOD(setInAppMessageAsSeen:(NSString *)messageId successCallback:(RCTResponseSenderBlock)successCallback errorCallback:(RCTResponseSenderBlock)errorCallback) {
66
+ NSString* errorMessage = [RNSelligent setInAppMessageAsSeen:messageId seen:true];
67
+
68
+ if (errorMessage) {
69
+ errorCallback(@[errorMessage]);
70
+ return;
71
+ }
72
+
73
+ successCallback(@[[NSNull null]]);
74
+ }
75
+
76
+ RCT_EXPORT_METHOD(setInAppMessageAsUnseen:(NSString *)messageId successCallback:(RCTResponseSenderBlock)successCallback errorCallback:(RCTResponseSenderBlock)errorCallback) {
77
+ NSString* errorMessage = [RNSelligent setInAppMessageAsSeen:messageId seen:false];
78
+
79
+ if (errorMessage) {
80
+ errorCallback(@[errorMessage]);
81
+ return;
82
+ }
83
+
84
+ successCallback(@[[NSNull null]]);
85
+ }
86
+
87
+ RCT_EXPORT_METHOD(setInAppMessageAsDeleted:(NSString *)messageId successCallback:(RCTResponseSenderBlock)successCallback errorCallback:(RCTResponseSenderBlock)errorCallback) {
88
+ NSString* errorMessage = [RNSelligent setInAppMessageAsDeleted:messageId];
89
+
90
+ if (errorMessage) {
91
+ errorCallback(@[errorMessage]);
92
+ return;
93
+ }
94
+
95
+ successCallback(@[[NSNull null]]);
96
+ }
97
+
98
+ RCT_EXPORT_METHOD(executeButtonAction: (NSString *)buttonId messageId:(NSString *)messageId successCallback:(RCTResponseSenderBlock)successCallback errorCallback:(RCTResponseSenderBlock)errorCallback) {
99
+ NSString* errorMessage = [RNSelligent executeButtonAction:buttonId messageId:messageId];
100
+
101
+ if (errorMessage) {
102
+ errorCallback(@[errorMessage]);
103
+ return;
104
+ }
105
+
106
+ successCallback(@[[NSNull null]]);
107
+ }
108
+
109
+ RCT_EXPORT_METHOD(displayNotification:(NSString *)notificationId templateId:(NSString *)templateId) {
110
+ [RNSelligent displayNotification:notificationId templateId:templateId];
111
+ }
112
+
113
+ #pragma mark - Events
114
+
115
+ RCT_EXPORT_METHOD(sendEvent:(NSDictionary *)data successCallback:(RCTResponseSenderBlock)successCallback errorCallback:(RCTResponseSenderBlock)errorCallback) {
116
+ [RNSelligent sendEvent:data completion:^(BOOL status, NSString *message) {
117
+ if (status) {
118
+ successCallback(@[message, [NSNull null]]);
119
+ return;
120
+ }
121
+
122
+ errorCallback(@[message, [NSNull null]]);
123
+ }];
124
+ }
125
+
126
+ RCT_EXPORT_METHOD(subscribeToEvents:(NSArray<NSString *> *)events) {
127
+ [RNSelligent subscribeToEvents:events];
128
+ }
129
+
130
+ RCT_EXPORT_METHOD(displayLastReceivedNotification) {
131
+ [RNSelligent displayLastReceivedNotification];
132
+ }
133
+
134
+ - (void) sendBroadcastEventWithName:(NSString * _Nonnull)name type:(NSString * _Nonnull)type data:(NSDictionary * _Nullable)data {
135
+ [self sendEventWithName:name body:@{@"data": data ?: [NSNull null], @"broadcastEventType": type}];
136
+ }
137
+
138
+ - (NSArray<NSString *> *) supportedEvents {
139
+ return @[
140
+ @"ButtonClicked",
141
+ @"ReceivedInAppMessage",
142
+ @"WillDisplayNotification",
143
+ @"WillDismissNotification",
144
+ @"ReceivedRemoteNotification",
145
+ @"ReceivedDeviceId",
146
+ @"UniversalLinkExecuted",
147
+ @"TriggeredCustomEvent"
148
+ ];
149
+ }
150
+
151
+ @end
@@ -0,0 +1,40 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>AvailableLibraries</key>
6
+ <array>
7
+ <dict>
8
+ <key>LibraryIdentifier</key>
9
+ <string>ios-arm64_x86_64-simulator</string>
10
+ <key>LibraryPath</key>
11
+ <string>RNSelligentMobileSDK.framework</string>
12
+ <key>SupportedArchitectures</key>
13
+ <array>
14
+ <string>arm64</string>
15
+ <string>x86_64</string>
16
+ </array>
17
+ <key>SupportedPlatform</key>
18
+ <string>ios</string>
19
+ <key>SupportedPlatformVariant</key>
20
+ <string>simulator</string>
21
+ </dict>
22
+ <dict>
23
+ <key>LibraryIdentifier</key>
24
+ <string>ios-arm64</string>
25
+ <key>LibraryPath</key>
26
+ <string>RNSelligentMobileSDK.framework</string>
27
+ <key>SupportedArchitectures</key>
28
+ <array>
29
+ <string>arm64</string>
30
+ </array>
31
+ <key>SupportedPlatform</key>
32
+ <string>ios</string>
33
+ </dict>
34
+ </array>
35
+ <key>CFBundlePackageType</key>
36
+ <string>XFWK</string>
37
+ <key>XCFrameworkFormatVersion</key>
38
+ <string>1.0</string>
39
+ </dict>
40
+ </plist>