@forstaglobal/react-native-mobilesdk 3.9.2-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/LICENSE +13 -0
  2. package/README.md +158 -0
  3. package/android/build.gradle +110 -0
  4. package/android/gradle.properties +5 -0
  5. package/android/src/main/AndroidManifest.xml +3 -0
  6. package/android/src/main/AndroidManifestNew.xml +2 -0
  7. package/android/src/main/java/com/mobilesdk/MobileSdkModule.kt +283 -0
  8. package/android/src/main/java/com/mobilesdk/MobileSdkPackage.kt +17 -0
  9. package/android/src/main/java/com/mobilesdk/module/MobileBridge.kt +15 -0
  10. package/android/src/main/java/com/mobilesdk/module/TriggerCallback.kt +60 -0
  11. package/ios/MobileSdk-Bridging-Header.h +2 -0
  12. package/ios/MobileSdk.mm +118 -0
  13. package/ios/MobileSdk.swift +257 -0
  14. package/ios/Mobilesdk.xcodeproj/project.pbxproj +351 -0
  15. package/ios/Mobilesdk.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
  16. package/ios/Mobilesdk.xcworkspace/contents.xcworkspacedata +10 -0
  17. package/ios/Mobilesdk.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  18. package/ios/Module/Exts.swift +16 -0
  19. package/ios/Module/MobileTriggerCallback.swift +49 -0
  20. package/ios/Module/SdkEmitter.mm +5 -0
  21. package/ios/Module/SdkEmitter.swift +26 -0
  22. package/ios/Podfile +7 -0
  23. package/ios/Podfile.lock +16 -0
  24. package/lib/commonjs/index.js +161 -0
  25. package/lib/commonjs/index.js.map +1 -0
  26. package/lib/commonjs/models/models.js +2 -0
  27. package/lib/commonjs/models/models.js.map +1 -0
  28. package/lib/commonjs/program/triggerCallback.js +38 -0
  29. package/lib/commonjs/program/triggerCallback.js.map +1 -0
  30. package/lib/commonjs/views/surveyWebView.js +60 -0
  31. package/lib/commonjs/views/surveyWebView.js.map +1 -0
  32. package/lib/module/index.js +116 -0
  33. package/lib/module/index.js.map +1 -0
  34. package/lib/module/models/models.js +2 -0
  35. package/lib/module/models/models.js.map +1 -0
  36. package/lib/module/program/triggerCallback.js +31 -0
  37. package/lib/module/program/triggerCallback.js.map +1 -0
  38. package/lib/module/views/surveyWebView.js +50 -0
  39. package/lib/module/views/surveyWebView.js.map +1 -0
  40. package/lib/typescript/index.d.ts +39 -0
  41. package/lib/typescript/index.d.ts.map +1 -0
  42. package/lib/typescript/models/models.d.ts +15 -0
  43. package/lib/typescript/models/models.d.ts.map +1 -0
  44. package/lib/typescript/program/triggerCallback.d.ts +20 -0
  45. package/lib/typescript/program/triggerCallback.d.ts.map +1 -0
  46. package/lib/typescript/views/surveyWebView.d.ts +17 -0
  47. package/lib/typescript/views/surveyWebView.d.ts.map +1 -0
  48. package/package.json +137 -0
  49. package/react-native-mobilesdk.podspec +43 -0
  50. package/src/index.tsx +202 -0
  51. package/src/models/models.ts +16 -0
  52. package/src/program/triggerCallback.ts +51 -0
  53. package/src/views/surveyWebView.tsx +69 -0
package/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Forsta Mobile SDK
2
+
3
+ All Rights Reserved. Forsta confidential information.
4
+
5
+ This code (“Code”) is solely intended to be used by company (“Client”) holding a valid agreement with Forsta for the use by Client of the Forsta Plus Software (“Software”). Forsta grants Client a non-exclusive, non-transferable and time-limited license to install and use the Code in conjunction with the Software. For clarity, no license is being granted to any Software herein, and access to the Software is subject to executed agreements separate from these terms.
6
+
7
+ The Code may be changed by Forsta at any time without prior notice, provided however that relevant documentation shall, before or immediately upon the change having been implemented, be updated on the Forsta Extranet (or any other repository of Documentation as determined by Forsta). CLIENT HEREBY CONFIRMS, UNDERSTANDS AND ACCEPTS THAT UPON UPGRADING TO A NEWER VERSION OF THE CODE, CHANGES IN BEHAVIOUR MAY OCCUR. CLIENT HEREBY EXPLICITLY UNDERTAKES TO PROACTIVELY TEST THE CODE BEFORE MAKING PRODUCTION USE THEREOF.
8
+
9
+ Except to the extent strictly permitted by applicable law notwithstanding contractual prohibition, Client shall not decompile, revise, reverse engineer, modify, or derive source code from the Code.
10
+
11
+ THIS CODE IS PROVIDED BY FORSTA AND “AS AVAILABLE” AND TO THE FULLEST EXTENT PERMITTED BY LAW, FORSTA EXPRESSLY DISCLAIMS ANY AND ALL OTHER WARRANTIES, WHETHER EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, WITH RESPECT TO THE MATERIALS, INCLUDING ANY WARRANTIES OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, OR ANY IMPLIED WARRANTY, CONDITION OR OTHER TERM ARISING FROM A COURSE OF DEALING OR COURSE OF PERFORMANCE. NO ORAL OR WRITTEN INFORMATION PROVIDED BY FORSTA OR ITS EMPLOYEES OR REPRESENTATIVES OF FORSTA WILL CREATE ANY WARRANTY, AND THIS WARRANTY DISCLAIMER SUPERSEDES ANY SUCH INFORMATION. CLIENT ACKNOWLEDGES AND AGREES IT HAS SELECTED THE MATERIALS AND IS SOLELY RESPONSIBLE FOR ANY RESULTS OBTAINED FROM THE MATERIALS AND HAS NOT AND SHALL NOT RELY UPON ANY REPRESENTATIONS OR WARRANTIES AS TO THE SUITABILITY OR UTILITY OF THE MATERIALS TO MEET CLIENT’S NEEDS OR REQUIREMENTS. FORSTA DOES NOT REPRESENT OR WARRANT THAT THE MATERIALS SHALL BE ERROR-FREE.
12
+
13
+ TO THE FULLEST EXTENT ALLOWED BY LAW, FORSTA SHALL NOT UNDER ANY CIRCUMSTANCES, REGARDLESS OF THE FORM OF ACTION OR THE BASIS OF THE CLAIM, BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL, PUNITIVE, OR EXEMPLARY DAMAGES HOWSOEVER CHARACTERIZED, ARISING FROM OR IN ANY MANNER RELATED TO THIS AGREEMENT, ANY ORDER FORM, THE SERVICE, SOFTWARE, DOCUMENTATION, OR THE SUBJECT MATTER HEREOF, INCLUDING BUT NOT LIMITED TO LOSS OF REVENUE OR PROFITS, WASTED ADMINISTRATIVE TIME, COST OF PROCURING OR MIGRATING TO SUBSTITUTE SERVICES, OR DAMAGES RESULTING FROM MISTAKES, OMISSIONS, INTERRUPTIONS, DESTRUCTION, LOSS OR DELETION OF TRANSIENT DATA, OR DELAYS IN OPERATION OR TRANSMISSION. IN THE EVENT OF ANY BREACH BY FORSTA OF THIS AGREEMENT, IN NO EVENT SHALL THE AGGREGATE LIABILITY OF THE BREACHING PARTY EXCEED ONE HUNDRED TWENTY-FIVE PERCENT (125%) OF THE TOTAL AMOUNT INVOICED BY FORSTA TO CLIENT FOR THIS CODE DURING THE PRECEDING TWELVE (12) MONTHS, EXCLUDING SALES TAX.
package/README.md ADDED
@@ -0,0 +1,158 @@
1
+ <br/>
2
+ <p align="center">
3
+ <img src="https://forstaglobal.github.io/DigitalFeedbackMobileSDK/assets/logo.png">
4
+ </p>
5
+
6
+ # Digital Feedback Mobile SDK
7
+
8
+ The Forsta Digital Feedback Mobile SDK provides seamless in-app feedback for any touch point within your mobile application.
9
+
10
+ <br/>
11
+
12
+ ## Documentation
13
+
14
+ Everything you need to get started with integration can be found in the [repository wiki](https://github.com/ForstaGlobal/DigitalFeedbackMobileSDK/wiki).
15
+
16
+ <br/>
17
+
18
+ ## Setup (Android)
19
+
20
+ ### Prerequisites
21
+
22
+ * Android API Level 21 or higher (Android 5.0 and above)
23
+ * [AndroidX](https://developer.android.com/jetpack/androidx/) enabled
24
+ * More information about setup and migration for AndroidX can be found [here](https://developer.android.com/jetpack/androidx/)
25
+ * Dependencies
26
+
27
+ > These dependencies will be automatically downloaded by Gradle sync
28
+
29
+ * AndroidX
30
+ * [Room](https://developer.android.com/jetpack/androidx/releases/room) (2.4.3)
31
+ * [Appcompat](https://developer.android.com/jetpack/androidx/releases/appcompat) (1.4.1)
32
+ * [WebKit](https://developer.android.com/jetpack/androidx/releases/webkit) (1.4.0)
33
+ * [Gson](https://github.com/google/gson) (2.10)
34
+ * [Mozilla Rhino](https://github.com/mozilla/rhino) (1.7.12)
35
+
36
+
37
+ ### Installation
38
+
39
+ Add the SDK dependency to the application level `build.gradle` file.
40
+ ```gradle
41
+ // build.gradle (Module)
42
+ dependencies {
43
+ ...
44
+ implementation 'com.confirmit.mobilesdk:mobilesdk:3.9.2'
45
+ }
46
+ ```
47
+
48
+ Once you make these two changes, simply refresh / sync your gradle dependencies.
49
+
50
+
51
+ ### R8 / ProGuard
52
+
53
+ If you are using R8, the shrinking and obfuscation rules will be included automatically.
54
+
55
+ ProGuard users must manually add following rules.
56
+
57
+ ```gradle
58
+ # Rhino
59
+ -keep class org.mozilla.javascript.** { public *; }
60
+ -dontwarn org.mozilla.javascript.**
61
+ ```
62
+
63
+ <br/>
64
+
65
+ ## Setup (iOS)
66
+
67
+ ### Prerequisites
68
+
69
+ * Xcode 13 or higher
70
+ * Target of iOS 11 or higher
71
+ * Swift 5.5 or higher
72
+
73
+ ### Installation
74
+
75
+ #### 1. Using Swift Package Manager
76
+
77
+ **Step 1.** Add package URL and dependency to `Package.swift`
78
+ ```swift
79
+ // swift-tools-version:5.5
80
+
81
+ import PackageDescription
82
+
83
+ let package = Package(
84
+ name: "<Your Product Name>",
85
+ dependencies: [
86
+ .package(url: "https://github.com/ForstaGlobal/DigitalFeedbackMobileSDK.git", .upToNextMajor(from: "3.9.2"))
87
+ ],
88
+ targets: [
89
+ .target(
90
+ name: "<Your Target Name>",
91
+ dependencies: [
92
+ .product(name: "ConfirmitMobileSDK", package: "DigitalFeedbackMobileSDK")
93
+ ]
94
+ ),
95
+ ]
96
+ )
97
+ ```
98
+
99
+ **Step 2.** Run `swift package resolve`
100
+
101
+ #### 2. Using CocoaPods
102
+
103
+ > Requires CocoaPods 1.10.0 or higher
104
+
105
+ **Step 1.** Add local pod path to the `Podfile`.
106
+ ```ruby
107
+ use_frameworks!
108
+ platform :ios, '12.0'
109
+
110
+ # Your target
111
+ target 'MyApp' do
112
+ # ... others pods
113
+ pod 'ConfirmitMobileSDK', '3.9.2'
114
+ end
115
+ ```
116
+
117
+ **Step 2.** Run `pod update`.
118
+
119
+ #### 3. Manual Method
120
+
121
+ **Step 1.** Clone Github repository.
122
+
123
+ **Step 2.** If the Framework folder doesn't already exist, right-click on your project in the project navigator (top-most entry), and select “New Group”. Name the new group `Frameworks`.
124
+
125
+ **Step 3.** Drag and drop it from Finder into the Frameworks folder. Make sure that the destination is just under the Frameworks folder before dropping.
126
+
127
+ **Step 4.** Then, make sure the following options are selected for adding files:
128
+ * Both “Copy items if needed” and “Create groups” should be checked and selected.
129
+ * Click Finish.
130
+
131
+ <br/>
132
+
133
+ ## Setup (React Native)
134
+
135
+ ### Prerequisites
136
+ * ios
137
+ * Xcode 13 or higher
138
+ * Target of iOS 11 or higher
139
+ * Swift 5.5 or higher
140
+ * android
141
+ * Android API Level 21 or higher (Android 5.0 and above)
142
+ * Dependencies
143
+ * react-native 0.72.4 or higher
144
+ * react-native-webview (>=13.6.2)
145
+ > react-native-webview needs to be installed manually, or else the native modules will have to be linked up manually.
146
+
147
+ ### Installation
148
+
149
+ #### 1. Using NPM
150
+
151
+ **Step 1.** NPM install packages
152
+ ```sh
153
+ npm install react-native-webview@13.6.2
154
+ npm install react-native-mobilesdk
155
+ ```
156
+
157
+ **Step 2.** Run `pod install` inside ios folder
158
+
@@ -0,0 +1,110 @@
1
+ buildscript {
2
+ // Buildscript is evaluated before everything else so we can't use getExtOrDefault
3
+ def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["Mobilesdk_kotlinVersion"]
4
+
5
+ repositories {
6
+ google()
7
+ mavenCentral()
8
+ }
9
+
10
+ dependencies {
11
+ classpath "com.android.tools.build:gradle:7.2.1"
12
+ // noinspection DifferentKotlinGradleVersion
13
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14
+ }
15
+ }
16
+
17
+ def isNewArchitectureEnabled() {
18
+ return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
19
+ }
20
+
21
+ apply plugin: "com.android.library"
22
+ apply plugin: "kotlin-android"
23
+
24
+
25
+ def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
26
+
27
+ if (isNewArchitectureEnabled()) {
28
+ apply plugin: "com.facebook.react"
29
+ }
30
+
31
+ def getExtOrDefault(name) {
32
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["Mobilesdk_" + name]
33
+ }
34
+
35
+ def getExtOrIntegerDefault(name) {
36
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["Mobilesdk_" + name]).toInteger()
37
+ }
38
+
39
+ def supportsNamespace() {
40
+ def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
41
+ def major = parsed[0].toInteger()
42
+ def minor = parsed[1].toInteger()
43
+
44
+ // Namespace support was added in 7.3.0
45
+ if (major == 7 && minor >= 3) {
46
+ return true
47
+ }
48
+
49
+ return major >= 8
50
+ }
51
+
52
+ android {
53
+ if (supportsNamespace()) {
54
+ namespace "com.mobilesdk"
55
+
56
+ sourceSets {
57
+ main {
58
+ manifest.srcFile "src/main/AndroidManifestNew.xml"
59
+ }
60
+ }
61
+ }
62
+
63
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
64
+
65
+ defaultConfig {
66
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
67
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
68
+ buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
69
+ }
70
+ buildTypes {
71
+ release {
72
+ minifyEnabled false
73
+ }
74
+ }
75
+
76
+ lintOptions {
77
+ disable "GradleCompatible"
78
+ }
79
+
80
+ compileOptions {
81
+ sourceCompatibility JavaVersion.VERSION_1_8
82
+ targetCompatibility JavaVersion.VERSION_1_8
83
+ }
84
+
85
+ }
86
+
87
+ repositories {
88
+ mavenCentral()
89
+ google()
90
+ }
91
+
92
+ def kotlin_version = getExtOrDefault("kotlinVersion")
93
+
94
+ dependencies {
95
+ // For < 0.71, this will be from the local maven repo
96
+ // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
97
+ //noinspection GradleDynamicVersion
98
+ implementation "com.facebook.react:react-native:+"
99
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
100
+ implementation 'com.confirmit.mobilesdk:mobilesdk:3.9.2-beta.0'
101
+ implementation project(path: ':react-native-webview')
102
+ }
103
+
104
+ if (isNewArchitectureEnabled()) {
105
+ react {
106
+ jsRootDir = file("../src/")
107
+ libraryName = "MobileSdk"
108
+ codegenJavaPackageName = "com.mobilesdk"
109
+ }
110
+ }
@@ -0,0 +1,5 @@
1
+ Mobilesdk_kotlinVersion=1.7.0
2
+ Mobilesdk_minSdkVersion=21
3
+ Mobilesdk_targetSdkVersion=31
4
+ Mobilesdk_compileSdkVersion=31
5
+ Mobilesdk_ndkversion=21.4.7075529
@@ -0,0 +1,3 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="com.mobilesdk">
3
+ </manifest>
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -0,0 +1,283 @@
1
+ package com.mobilesdk
2
+
3
+ import android.R
4
+ import android.app.Application
5
+ import android.os.Handler
6
+ import android.view.View
7
+ import android.view.ViewGroup
8
+ import com.confirmit.mobilesdk.ConfirmitSDK
9
+ import com.confirmit.mobilesdk.ConfirmitServer
10
+ import com.confirmit.mobilesdk.TriggerSDK
11
+ import com.confirmit.mobilesdk.database.externals.Server
12
+ import com.facebook.react.bridge.Arguments
13
+ import com.facebook.react.bridge.Promise
14
+ import com.facebook.react.bridge.ReactApplicationContext
15
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
16
+ import com.facebook.react.bridge.ReactMethod
17
+ import com.facebook.react.bridge.ReadableMap
18
+ import com.facebook.react.bridge.WritableMap
19
+ import com.facebook.react.modules.core.DeviceEventManagerModule
20
+ import com.facebook.react.uimanager.util.ReactFindViewUtil
21
+ import com.mobilesdk.module.TriggerCallback
22
+ import com.mobilesdk.module.enableSurveyAutoDismiss
23
+ import com.reactnativecommunity.webview.RNCWebViewWrapper
24
+
25
+ class MobileSdkModule(reactContext: ReactApplicationContext) :
26
+ ReactContextBaseJavaModule(reactContext) {
27
+
28
+ companion object {
29
+ const val NAME = "MobileSdk"
30
+
31
+ var application: Application? = null
32
+ }
33
+
34
+ override fun getName(): String {
35
+ return NAME
36
+ }
37
+
38
+ @ReactMethod
39
+ fun injectWebView() {
40
+ Handler(reactApplicationContext.mainLooper).post {
41
+ val viewGroup =
42
+ (reactApplicationContext.currentActivity?.findViewById<View>(R.id.content) as ViewGroup).getChildAt(
43
+ 0
44
+ ) as ViewGroup
45
+ val reactWebView =
46
+ ReactFindViewUtil.findView(viewGroup, "surveyWebViews") as? RNCWebViewWrapper
47
+ reactWebView?.webView?.enableSurveyAutoDismiss {
48
+ reactApplicationContext
49
+ .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
50
+ .emit("__mobileOnSurveyClosed", Arguments.createMap())
51
+ }
52
+ }
53
+ }
54
+
55
+
56
+ @ReactMethod
57
+ fun initSdk() {
58
+ application?.let {
59
+ ConfirmitSDK.Setup(it).configure()
60
+ }
61
+ }
62
+
63
+ @ReactMethod
64
+ fun enableLog(enable: Boolean) {
65
+ ConfirmitSDK.enableLog(enable)
66
+ }
67
+
68
+ // Program
69
+ @ReactMethod
70
+ fun triggerDownload(serverId: String, programKey: String, promise: Promise) {
71
+ val response = TriggerSDK.download(serverId, programKey)
72
+ if (response.result) {
73
+ promise.resolve(response.result)
74
+ } else {
75
+ promise.reject(response.exception)
76
+ }
77
+ }
78
+
79
+ @ReactMethod
80
+ fun deleteProgram(
81
+ serverId: String,
82
+ programKey: String,
83
+ deleteCustomData: Boolean,
84
+ promise: Promise
85
+ ) {
86
+ try {
87
+ TriggerSDK.deleteProgram(serverId, programKey, deleteCustomData)
88
+ } catch (error: Exception) {
89
+ promise.reject(error)
90
+ }
91
+ }
92
+
93
+ @ReactMethod
94
+ fun deleteAll(deleteCustomData: Boolean, promise: Promise) {
95
+ try {
96
+ TriggerSDK.deleteAll(deleteCustomData)
97
+ } catch (error: Exception) {
98
+ promise.reject(error)
99
+ }
100
+ }
101
+
102
+ @ReactMethod
103
+ fun setCallback(serverId: String, programKey: String) {
104
+ TriggerSDK.setCallback(
105
+ serverId,
106
+ programKey,
107
+ TriggerCallback(reactApplicationContext, serverId, programKey)
108
+ )
109
+ }
110
+
111
+ @ReactMethod
112
+ fun removeCallback(serverId: String, programKey: String) {
113
+ TriggerSDK.removeCallback(serverId, programKey)
114
+ }
115
+
116
+ @ReactMethod
117
+ fun notifyEvent(event: String) {
118
+ TriggerSDK.notifyEvent(event)
119
+ }
120
+
121
+ @ReactMethod
122
+ fun notifyEventWithData(event: String, data: ReadableMap) {
123
+ val result = mutableMapOf<String, String>()
124
+ for (entry in data.entryIterator) {
125
+ result[entry.key] = entry.value.toString()
126
+ }
127
+ TriggerSDK.notifyEvent(event, result)
128
+ }
129
+
130
+ @ReactMethod
131
+ fun notifyAppForeground(data: ReadableMap) {
132
+ val result = mutableMapOf<String, String>()
133
+ for (entry in data.entryIterator) {
134
+ result[entry.key] = entry.value.toString()
135
+ }
136
+ TriggerSDK.notifyAppForeground(result)
137
+ }
138
+
139
+ // Server
140
+ @ReactMethod
141
+ fun getUs(promise: Promise) {
142
+ promise.resolve(transformServer(ConfirmitServer.US))
143
+ }
144
+
145
+ @ReactMethod
146
+ fun getUk(promise: Promise) {
147
+ promise.resolve(transformServer(ConfirmitServer.UK))
148
+ }
149
+
150
+ @ReactMethod
151
+ fun getAustralia(promise: Promise) {
152
+ promise.resolve(transformServer(ConfirmitServer.AUSTRALIA))
153
+ }
154
+
155
+ @ReactMethod
156
+ fun getCanada(promise: Promise) {
157
+ promise.resolve(transformServer(ConfirmitServer.CANADA))
158
+ }
159
+
160
+ @ReactMethod
161
+ fun getGermany(promise: Promise) {
162
+ promise.resolve(transformServer(ConfirmitServer.GERMANY))
163
+ }
164
+
165
+ @ReactMethod
166
+ fun getHxPlatform(promise: Promise) {
167
+ promise.resolve(transformServer(ConfirmitServer.HX_PLATFORM))
168
+ }
169
+
170
+ @ReactMethod
171
+ fun getHxAustralia(promise: Promise) {
172
+ promise.resolve(transformServer(ConfirmitServer.HX_AUSTRALIA))
173
+ }
174
+
175
+ @ReactMethod
176
+ fun configureUs(clientId: String, clientSecret: String, promise: Promise) {
177
+ try {
178
+ ConfirmitServer.configureUS(clientId, clientSecret)
179
+ promise.resolve(null)
180
+ } catch (ex: Exception) {
181
+ promise.reject("server", "Failed to configure US")
182
+ }
183
+ }
184
+
185
+ @ReactMethod
186
+ fun configureUk(clientId: String, clientSecret: String, promise: Promise) {
187
+ try {
188
+ ConfirmitServer.configureUK(clientId, clientSecret)
189
+ promise.resolve(null)
190
+ } catch (ex: Exception) {
191
+ promise.reject("server", "Failed to configure UK")
192
+ }
193
+ }
194
+
195
+ @ReactMethod
196
+ fun configureAustralia(clientId: String, clientSecret: String, promise: Promise) {
197
+ try {
198
+ ConfirmitServer.configureAustralia(clientId, clientSecret)
199
+ promise.resolve(null)
200
+ } catch (ex: Exception) {
201
+ promise.reject("server", "Failed to configure Australia")
202
+ }
203
+ }
204
+
205
+ @ReactMethod
206
+ fun configureCanada(clientId: String, clientSecret: String, promise: Promise) {
207
+ try {
208
+ ConfirmitServer.configureCanada(clientId, clientSecret)
209
+ promise.resolve(null)
210
+ } catch (ex: Exception) {
211
+ promise.reject("server", "Failed to configure Canada")
212
+ }
213
+ }
214
+
215
+ @ReactMethod
216
+ fun configureGermany(clientId: String, clientSecret: String, promise: Promise) {
217
+ try {
218
+ ConfirmitServer.configureGermany(clientId, clientSecret)
219
+ promise.resolve(null)
220
+ } catch (ex: Exception) {
221
+ promise.reject("server", "Failed to configure Germany")
222
+ }
223
+ }
224
+
225
+ @ReactMethod
226
+ fun configureHxPlatform(clientId: String, clientSecret: String, promise: Promise) {
227
+ try {
228
+ ConfirmitServer.configureHxPlatform(clientId, clientSecret)
229
+ promise.resolve(null)
230
+ } catch (ex: Exception) {
231
+ promise.reject("server", "Failed to configure HX Platform")
232
+ }
233
+ }
234
+
235
+ @ReactMethod
236
+ fun configureHxAustralia(clientId: String, clientSecret: String, promise: Promise) {
237
+ try {
238
+ ConfirmitServer.configureHxAustralia(clientId, clientSecret)
239
+ promise.resolve(null)
240
+ } catch (ex: Exception) {
241
+ promise.reject("server", "Failed to configure HX Australia")
242
+ }
243
+ }
244
+
245
+ @ReactMethod
246
+ fun configureServer(
247
+ name: String,
248
+ host: String,
249
+ clientId: String,
250
+ clientSecret: String,
251
+ promise: Promise
252
+ ) {
253
+ val server = ConfirmitServer.configure(name, host, clientId, clientSecret)
254
+ promise.resolve(transformServer(server))
255
+ }
256
+
257
+ @ReactMethod
258
+ fun getServer(serverId: String, promise: Promise) {
259
+ ConfirmitServer.getServer(serverId)?.let {
260
+ promise.resolve(transformServer(it))
261
+ return
262
+ }
263
+ promise.reject("server", "failed to get server")
264
+ }
265
+
266
+ @ReactMethod
267
+ fun getServers(promise: Promise) {
268
+ val servers = ConfirmitServer.getServers()
269
+ val result = Arguments.createArray()
270
+ for (server in servers) {
271
+ result.pushMap(transformServer(server))
272
+ }
273
+ promise.resolve(result)
274
+ }
275
+
276
+ private fun transformServer(server: Server): WritableMap {
277
+ return Arguments.createMap().apply {
278
+ putString("host", server.host)
279
+ putString("name", server.name)
280
+ putString("serverId", server.serverId)
281
+ }
282
+ }
283
+ }
@@ -0,0 +1,17 @@
1
+ package com.mobilesdk
2
+
3
+ import com.facebook.react.ReactPackage
4
+ import com.facebook.react.bridge.NativeModule
5
+ import com.facebook.react.bridge.ReactApplicationContext
6
+ import com.facebook.react.uimanager.ViewManager
7
+
8
+
9
+ class MobileSdkPackage : ReactPackage {
10
+ override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
11
+ return listOf(MobileSdkModule(reactContext))
12
+ }
13
+
14
+ override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
15
+ return emptyList()
16
+ }
17
+ }
@@ -0,0 +1,15 @@
1
+ package com.mobilesdk.module
2
+
3
+ import android.webkit.JavascriptInterface
4
+ import android.webkit.WebView
5
+
6
+ fun WebView.enableSurveyAutoDismiss(onSurveyClosed: () -> Unit) {
7
+ class MobileBridge {
8
+ @JavascriptInterface
9
+ fun onSurveyEnd() {
10
+ onSurveyClosed()
11
+ }
12
+ }
13
+
14
+ addJavascriptInterface(MobileBridge(), "mobileBridge")
15
+ }
@@ -0,0 +1,60 @@
1
+ package com.mobilesdk.module
2
+
3
+ import com.confirmit.mobilesdk.trigger.ProgramCallback
4
+ import com.confirmit.mobilesdk.trigger.TriggerInfo
5
+ import com.confirmit.mobilesdk.ui.SurveyFrameConfig
6
+ import com.confirmit.mobilesdk.web.SurveyWebViewFragment
7
+ import com.facebook.react.bridge.Arguments
8
+ import com.facebook.react.bridge.ReactContext
9
+ import com.facebook.react.modules.core.DeviceEventManagerModule
10
+
11
+ class TriggerCallback(
12
+ private val reactContext: ReactContext,
13
+ private val serverId: String,
14
+ private val programKey: String
15
+ ) : ProgramCallback {
16
+ override fun onAppFeedback(triggerInfo: TriggerInfo, data: Map<String, String?>) {}
17
+
18
+ override fun onScenarioError(triggerInfo: TriggerInfo, exception: Exception) {
19
+ reactContext
20
+ .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
21
+ .emit("__mobileOnScenarioError", Arguments.createMap().apply {
22
+ putString("serverId", serverId)
23
+ putString("programKey", programKey)
24
+ putString("error", exception.localizedMessage)
25
+ })
26
+ }
27
+
28
+ override fun onScenarioLoad(triggerInfo: TriggerInfo, exception: Exception?) {
29
+ reactContext
30
+ .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
31
+ .emit("__mobileOnScenarioLoad", Arguments.createMap().apply {
32
+ putString("serverId", serverId)
33
+ putString("programKey", programKey)
34
+ putString("error", exception?.localizedMessage)
35
+ })
36
+ }
37
+
38
+ override fun onSurveyDownloadCompleted(
39
+ triggerInfo: TriggerInfo,
40
+ surveyId: String,
41
+ exception: Exception?
42
+ ) {
43
+ }
44
+
45
+ override fun onSurveyStart(config: SurveyFrameConfig) {}
46
+
47
+ override fun onWebSurveyStart(fragment: SurveyWebViewFragment) {
48
+ val result = fragment.getSurveyUrl()
49
+ val token = result.token
50
+ val url = result.url
51
+ reactContext
52
+ .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
53
+ .emit("__mobileOnWebSurveyStart", Arguments.createMap().apply {
54
+ putString("serverId", serverId)
55
+ putString("programKey", programKey)
56
+ putString("token", token)
57
+ putString("url", url)
58
+ })
59
+ }
60
+ }
@@ -0,0 +1,2 @@
1
+ #import <React/RCTBridgeModule.h>
2
+ #import <React/RCTEventEmitter.h>