@selligent-marketing-cloud/selligent-react-native 3.1.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.
- package/README.md +43 -1550
- package/RNSelligent.podspec +8 -15
- package/android/build.gradle +46 -79
- package/android/src/main/java/com/selligent/BroadcastEventType.java +4 -1
- package/android/src/main/java/com/selligent/ButtonAction.java +81 -0
- package/android/src/main/java/com/selligent/ButtonBroadcastEventDataParser.java +9 -3
- package/android/src/main/java/com/selligent/DeviceIdBroadcastEventDataParser.java +15 -0
- package/android/src/main/java/com/selligent/EventType.java +1 -1
- package/android/src/main/java/com/selligent/GCMTokenBroadcastEventDataParser.java +6 -1
- package/android/src/main/java/com/selligent/InAppMessageBroadcastEventDataParser.java +7 -1
- package/android/src/main/java/com/selligent/NotificationMessageBroadcastEventDataParser.java +19 -0
- package/android/src/main/java/com/selligent/RNSelligent.java +195 -56
- package/android/src/main/java/com/selligent/SMSettingsFactory.java +0 -1
- package/android/src/main/java/com/selligent/Settings.java +0 -9
- package/constants.d.ts +7 -33
- package/constants.js +51 -85
- package/documentation/README.md +826 -0
- package/helpers.js +5 -6
- package/index.android.js +8 -83
- package/index.d.ts +33 -43
- package/index.ios.js +25 -76
- package/index.js +153 -45
- package/ios/RNSelligentMapper.h +21 -0
- package/ios/RNSelligentMapper.m +151 -0
- package/ios/RNSelligentMobileSDK.xcframework/Info.plist +40 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/Headers/RNSelligentMobileSDK-Swift.h +350 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/Info.plist +0 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios.abi.json +2603 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +59 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios.swiftinterface +59 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/Modules/module.modulemap +4 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/RNSelligentMobileSDK +0 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/_CodeSignature/CodeResources +179 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Headers/RNSelligentMobileSDK-Swift.h +696 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Info.plist +0 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios-simulator.abi.json +2603 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +59 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +59 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +2603 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +59 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +59 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/module.modulemap +4 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/RNSelligentMobileSDK +0 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/_CodeSignature/CodeResources +234 -0
- package/package.json +30 -11
- package/.gitattributes +0 -1
- package/CHANGELOG.md +0 -68
- package/android/README.md +0 -15
- package/android/build/generated/source/buildConfig/debug/com/selligent/BuildConfig.java +0 -12
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +0 -9
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output-metadata.json +0 -18
- package/android/build/intermediates/aar_metadata/debug/aar-metadata.properties +0 -4
- package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +0 -1
- package/android/build/intermediates/compile_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/compile_r_class_jar/debug/R.jar +0 -0
- package/android/build/intermediates/compile_symbol_list/debug/R.txt +0 -6781
- package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +0 -1
- package/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +0 -2
- package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +0 -2
- package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +0 -2
- package/android/build/intermediates/incremental/packageDebugAssets/merger.xml +0 -2
- package/android/build/intermediates/javac/debug/classes/com/selligent/BroadcastDataFactory$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/BroadcastDataFactory.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/BroadcastEventDataParser.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/BroadcastEventType.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/BuildConfig.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/ButtonBroadcastEventDataParser.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/ClearCacheIntervalValue.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/Event.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/EventReceiver.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/EventType.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/GCMTokenBroadcastEventDataParser.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/InAppMessageBroadcastEventDataParser.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/InAppMessageRefreshType.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/RNSelligent$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/RNSelligent$2.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/RNSelligent$3.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/RNSelligent$4.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/RNSelligent$5.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/RNSelligent.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/RNSelligentPackage.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/RemoteMessageDisplayType.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/SMEventFactory$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/SMEventFactory.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/SMSettingsFactory.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/Settings.class +0 -0
- package/android/build/intermediates/local_only_symbol_list/debug/R-def.txt +0 -2
- package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +0 -11
- package/android/build/intermediates/merged_manifest/debug/AndroidManifest.xml +0 -9
- package/android/build/intermediates/navigation_json/debug/navigation.json +0 -1
- package/android/build/intermediates/packaged_manifests/debug/output-metadata.json +0 -18
- package/android/build/intermediates/runtime_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt +0 -5100
- package/android/build/outputs/logs/manifest-merger-debug-report.txt +0 -25
- package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
- package/android/libs/sdk-release.aar +0 -0
- package/documentation/add_json_file.png +0 -0
- package/documentation/add_lib_file.png +0 -0
- package/ios/BackgroundFetchResult.h +0 -5
- package/ios/ClearCacheInterval.h +0 -7
- package/ios/ClientSettings.h +0 -22
- package/ios/ClientSettings.m +0 -39
- package/ios/EnumMapper.h +0 -36
- package/ios/EnumMapper.m +0 -121
- package/ios/Event+SMEvent.h +0 -13
- package/ios/Event+SMEvent.m +0 -41
- package/ios/Event.h +0 -12
- package/ios/Event.m +0 -24
- package/ios/EventType.h +0 -7
- package/ios/InAppMessageRefreshType.h +0 -6
- package/ios/InAppMessageSettings.h +0 -9
- package/ios/InAppMessageSettings.m +0 -19
- package/ios/LocationAuthorisationStatus.h +0 -6
- package/ios/LocationAuthorisationType.h +0 -4
- package/ios/LogLevel.h +0 -9
- package/ios/NotificationButtonType.h +0 -15
- package/ios/ParsableObject.h +0 -5
- package/ios/RNSelligent.h +0 -22
- package/ios/RNSelligent.m +0 -347
- package/ios/RemoteMessageDisplayType.h +0 -5
- package/ios/SMManagerSetting+ClientSettings.h +0 -9
- package/ios/SMManagerSetting+ClientSettings.m +0 -73
- package/ios/SelligentLogger.h +0 -7
- package/ios/SelligentLogger.m +0 -9
- package/ios/SelligentReactNative.xcodeproj/project.pbxproj +0 -446
- package/ios/include/SMBaseMessage.h +0 -48
- package/ios/include/SMBlock.h +0 -21
- package/ios/include/SMClearCache.h +0 -34
- package/ios/include/SMContentAlignment.h +0 -27
- package/ios/include/SMDeviceInfos.h +0 -38
- package/ios/include/SMDisplayMode.h +0 -27
- package/ios/include/SMEvent.h +0 -69
- package/ios/include/SMEventUser.h +0 -20
- package/ios/include/SMEventUserLogin.h +0 -42
- package/ios/include/SMEventUserLogout.h +0 -42
- package/ios/include/SMEventUserRegistration.h +0 -42
- package/ios/include/SMEventUserUnregistration.h +0 -42
- package/ios/include/SMFailure.h +0 -19
- package/ios/include/SMHelper.h +0 -51
- package/ios/include/SMInAppContentHTMLViewController.h +0 -59
- package/ios/include/SMInAppContentImageViewController.h +0 -36
- package/ios/include/SMInAppContentMessage.h +0 -56
- package/ios/include/SMInAppContentStyleOptions.h +0 -511
- package/ios/include/SMInAppContentType.h +0 -35
- package/ios/include/SMInAppContentURLViewController.h +0 -36
- package/ios/include/SMInAppContentViewController.h +0 -31
- package/ios/include/SMInAppMessage.h +0 -51
- package/ios/include/SMInAppMessageType.h +0 -50
- package/ios/include/SMInAppRefreshType.h +0 -29
- package/ios/include/SMLink.h +0 -39
- package/ios/include/SMLog.h +0 -54
- package/ios/include/SMManager+DataTransaction.h +0 -33
- package/ios/include/SMManager+InAppContent.h +0 -170
- package/ios/include/SMManager+InAppMessage.h +0 -172
- package/ios/include/SMManager+Location.h +0 -41
- package/ios/include/SMManager+Log.h +0 -31
- package/ios/include/SMManager+RemoteNotification.h +0 -171
- package/ios/include/SMManager+SMEvent.h +0 -67
- package/ios/include/SMManager+SMLink.h +0 -44
- package/ios/include/SMManager+SilentPush.h +0 -53
- package/ios/include/SMManager+StyleOptions.h +0 -36
- package/ios/include/SMManager+UserNotification.h +0 -180
- package/ios/include/SMManager+ViewController.h +0 -45
- package/ios/include/SMManager.h +0 -69
- package/ios/include/SMManagerHelper.h +0 -18
- package/ios/include/SMManagerInAppMessageDelegate.h +0 -24
- package/ios/include/SMManagerSetting+Location.h +0 -27
- package/ios/include/SMManagerSetting.h +0 -180
- package/ios/include/SMManagerSettingIAC.h +0 -48
- package/ios/include/SMManagerSettingIAM.h +0 -49
- package/ios/include/SMManagerUniversalLinksDelegate.h +0 -23
- package/ios/include/SMMessage.h +0 -21
- package/ios/include/SMNSNotification.h +0 -81
- package/ios/include/SMNotificationAnnotationData.h +0 -33
- package/ios/include/SMNotificationButtonData.h +0 -20
- package/ios/include/SMNotificationButtonType.h +0 -90
- package/ios/include/SMNotificationMessage.h +0 -31
- package/ios/include/SMRemoteMessageDisplayType.h +0 -32
- package/ios/include/SMSuccess.h +0 -16
- package/ios/libSelligentMobile.a +0 -0
- 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
|
-
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
*
|
|
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 {
|
|
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
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
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>
|