@screeb/react-native 2.1.17 → 2.2.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.
- package/README.md +24 -5
- package/{screeb-module.podspec → ScreebReactNative.podspec} +6 -4
- package/android/build.gradle +36 -86
- package/android/gradle.properties +5 -3
- package/android/src/main/AndroidManifest.xml +1 -3
- package/android/src/main/java/app/screeb/reactnative/ScreebReactNativeModule.kt +258 -0
- package/android/src/main/java/app/screeb/reactnative/ScreebReactNativePackage.kt +33 -0
- package/ios/ScreebReactNative.m +63 -0
- package/ios/{ScreebModule.swift → ScreebReactNative.swift} +116 -32
- package/lib/module/NativeScreebReactNative.js +10 -0
- package/lib/module/NativeScreebReactNative.js.map +1 -0
- package/lib/module/index.js +170 -88
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NativeScreebReactNative.d.ts +49 -0
- package/lib/typescript/src/NativeScreebReactNative.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +25 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +153 -59
- package/src/NativeScreebReactNative.ts +81 -0
- package/src/index.tsx +251 -144
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +0 -5
- package/android/gradlew +0 -185
- package/android/gradlew.bat +0 -89
- package/android/src/main/java/com/screebmodule/ScreebModuleModule.kt +0 -186
- package/android/src/main/java/com/screebmodule/ScreebModulePackage.kt +0 -17
- package/ios/ScreebModule-Bridging-Header.h +0 -3
- package/ios/ScreebModule.m +0 -24
- package/ios/ScreebModule.xcodeproj/project.pbxproj +0 -293
- package/lib/commonjs/index.js +0 -130
- package/lib/typescript/index.d.ts +0 -13
package/README.md
CHANGED
|
@@ -17,21 +17,40 @@ A react-native module to integrate Screeb mobile sdk for Android and/or iOS.
|
|
|
17
17
|
|
|
18
18
|
[See here.](https://www.notion.so/screeb/ReactNative-SDK-30e8dc27fa7a4dea979084d83e5140c3)
|
|
19
19
|
|
|
20
|
-
## Run
|
|
20
|
+
## Run examples
|
|
21
|
+
|
|
22
|
+
### React Native CLI example
|
|
21
23
|
|
|
22
24
|
```sh
|
|
23
|
-
|
|
25
|
+
yarn install
|
|
24
26
|
|
|
25
27
|
cd example/
|
|
26
|
-
|
|
28
|
+
yarn install
|
|
27
29
|
|
|
28
30
|
cd ios/
|
|
29
31
|
pod install
|
|
32
|
+
cd ..
|
|
30
33
|
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
yarn android
|
|
35
|
+
yarn ios
|
|
33
36
|
```
|
|
34
37
|
|
|
38
|
+
### Expo example
|
|
39
|
+
|
|
40
|
+
The Expo project lives in `example-expo`. It builds a full native binary (Expo Go will not load custom native modules).
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
yarn install
|
|
44
|
+
|
|
45
|
+
yarn workspace example-expo prebuild
|
|
46
|
+
yarn workspace example-expo ios # or android
|
|
47
|
+
|
|
48
|
+
# in another terminal, from the repo root
|
|
49
|
+
yarn example:expo
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Re-run `prebuild` whenever native configuration changes (for example after toggling the new architecture). Use `yarn workspace example-expo prebuild --clean` if you need to fully regenerate the iOS/Android projects. The `example-expo/react-native.config.js` file ensures the Screeb module is autolinked automatically.
|
|
53
|
+
|
|
35
54
|
## License
|
|
36
55
|
|
|
37
56
|
MIT
|
|
@@ -3,18 +3,20 @@ require "json"
|
|
|
3
3
|
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
4
|
|
|
5
5
|
Pod::Spec.new do |s|
|
|
6
|
-
s.name = "
|
|
6
|
+
s.name = "ScreebReactNative"
|
|
7
7
|
s.version = package["version"]
|
|
8
8
|
s.summary = package["description"]
|
|
9
9
|
s.homepage = package["homepage"]
|
|
10
10
|
s.license = package["license"]
|
|
11
11
|
s.authors = package["author"]
|
|
12
12
|
|
|
13
|
-
s.platforms = { :ios => "
|
|
13
|
+
s.platforms = { :ios => "12.0" }
|
|
14
14
|
s.source = { :git => "https://github.com/ScreebApp/sdk-reactnative.git", :tag => "#{s.version}" }
|
|
15
15
|
|
|
16
|
-
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
16
|
+
s.source_files = "ios/**/*.{h,m,mm,cpp,swift}"
|
|
17
|
+
s.private_header_files = "ios/**/*.h"
|
|
17
18
|
|
|
19
|
+
s.dependency "Screeb", '~> 2.2.0'
|
|
18
20
|
s.dependency "React-Core"
|
|
19
|
-
s
|
|
21
|
+
install_modules_dependencies(s)
|
|
20
22
|
end
|
package/android/build.gradle
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
buildscript {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
ext.getExtOrDefault = {name ->
|
|
3
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['ScreebReactNative_' + name]
|
|
4
|
+
}
|
|
4
5
|
|
|
5
6
|
repositories {
|
|
6
7
|
google()
|
|
@@ -8,30 +9,34 @@ buildscript {
|
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
dependencies {
|
|
11
|
-
classpath
|
|
12
|
+
classpath "com.android.tools.build:gradle:8.7.2"
|
|
12
13
|
// noinspection DifferentKotlinGradleVersion
|
|
13
|
-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$
|
|
14
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
apply plugin: 'com.android.library'
|
|
18
|
-
apply plugin: 'kotlin-android'
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
apply plugin: "com.android.library"
|
|
20
|
+
apply plugin: "kotlin-android"
|
|
21
|
+
|
|
22
|
+
apply plugin: "com.facebook.react"
|
|
23
23
|
|
|
24
24
|
def getExtOrIntegerDefault(name) {
|
|
25
|
-
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties[
|
|
25
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["ScreebReactNative_" + name]).toInteger()
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
android {
|
|
29
|
-
|
|
29
|
+
namespace "app.screeb.reactnative"
|
|
30
|
+
|
|
31
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
32
|
+
|
|
30
33
|
defaultConfig {
|
|
31
|
-
minSdkVersion
|
|
32
|
-
targetSdkVersion getExtOrIntegerDefault(
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
35
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
buildFeatures {
|
|
39
|
+
buildConfig true
|
|
35
40
|
}
|
|
36
41
|
|
|
37
42
|
buildTypes {
|
|
@@ -39,90 +44,35 @@ android {
|
|
|
39
44
|
minifyEnabled false
|
|
40
45
|
}
|
|
41
46
|
}
|
|
47
|
+
|
|
42
48
|
lintOptions {
|
|
43
|
-
disable
|
|
49
|
+
disable "GradleCompatible"
|
|
44
50
|
}
|
|
51
|
+
|
|
45
52
|
compileOptions {
|
|
46
53
|
sourceCompatibility JavaVersion.VERSION_1_8
|
|
47
54
|
targetCompatibility JavaVersion.VERSION_1_8
|
|
48
55
|
}
|
|
56
|
+
|
|
57
|
+
sourceSets {
|
|
58
|
+
main {
|
|
59
|
+
java.srcDirs += [
|
|
60
|
+
"generated/java",
|
|
61
|
+
"generated/jni"
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
}
|
|
49
65
|
}
|
|
50
66
|
|
|
51
67
|
repositories {
|
|
52
68
|
mavenCentral()
|
|
53
69
|
google()
|
|
54
|
-
|
|
55
|
-
def found = false
|
|
56
|
-
def defaultDir = null
|
|
57
|
-
def androidSourcesName = 'React Native sources'
|
|
58
|
-
|
|
59
|
-
if (rootProject.ext.has('reactNativeAndroidRoot')) {
|
|
60
|
-
defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
|
|
61
|
-
} else {
|
|
62
|
-
defaultDir = new File(
|
|
63
|
-
projectDir,
|
|
64
|
-
'/../../../node_modules/react-native/android'
|
|
65
|
-
)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (defaultDir.exists()) {
|
|
69
|
-
maven {
|
|
70
|
-
url defaultDir.toString()
|
|
71
|
-
name androidSourcesName
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}")
|
|
75
|
-
found = true
|
|
76
|
-
} else {
|
|
77
|
-
def parentDir = rootProject.projectDir
|
|
78
|
-
|
|
79
|
-
1.upto(5, {
|
|
80
|
-
if (found) return true
|
|
81
|
-
parentDir = parentDir.parentFile
|
|
82
|
-
|
|
83
|
-
def androidSourcesDir = new File(
|
|
84
|
-
parentDir,
|
|
85
|
-
'node_modules/react-native'
|
|
86
|
-
)
|
|
87
|
-
|
|
88
|
-
def androidPrebuiltBinaryDir = new File(
|
|
89
|
-
parentDir,
|
|
90
|
-
'node_modules/react-native/android'
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
if (androidPrebuiltBinaryDir.exists()) {
|
|
94
|
-
maven {
|
|
95
|
-
url androidPrebuiltBinaryDir.toString()
|
|
96
|
-
name androidSourcesName
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}")
|
|
100
|
-
found = true
|
|
101
|
-
} else if (androidSourcesDir.exists()) {
|
|
102
|
-
maven {
|
|
103
|
-
url androidSourcesDir.toString()
|
|
104
|
-
name androidSourcesName
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}")
|
|
108
|
-
found = true
|
|
109
|
-
}
|
|
110
|
-
})
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (!found) {
|
|
114
|
-
throw new GradleException(
|
|
115
|
-
"${project.name}: unable to locate React Native android sources. " +
|
|
116
|
-
"Ensure you have you installed React Native as a dependency in your project and try again."
|
|
117
|
-
)
|
|
118
|
-
}
|
|
119
70
|
}
|
|
120
71
|
|
|
121
|
-
def kotlin_version = getExtOrDefault(
|
|
72
|
+
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
122
73
|
|
|
123
74
|
dependencies {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22"
|
|
75
|
+
implementation "com.facebook.react:react-android"
|
|
76
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
77
|
+
api "app.screeb.sdk:survey:2.2.7"
|
|
128
78
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
ScreebReactNative_kotlinVersion=2.0.21
|
|
2
|
+
ScreebReactNative_minSdkVersion=21
|
|
3
|
+
ScreebReactNative_targetSdkVersion=34
|
|
4
|
+
ScreebReactNative_compileSdkVersion=35
|
|
5
|
+
ScreebReactNative_ndkVersion=27.1.12297006
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
package app.screeb.reactnative
|
|
2
|
+
import com.facebook.react.bridge.Arguments
|
|
3
|
+
import com.facebook.react.bridge.Promise
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.bridge.ReadableMap
|
|
6
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
7
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
8
|
+
import java.util.HashMap
|
|
9
|
+
import app.screeb.sdk.Screeb
|
|
10
|
+
import app.screeb.sdk.InitOptions
|
|
11
|
+
import android.os.Handler
|
|
12
|
+
import android.os.Looper
|
|
13
|
+
|
|
14
|
+
@ReactModule(name = ScreebReactNativeModule.NAME)
|
|
15
|
+
class ScreebReactNativeModule(reactContext: ReactApplicationContext) :
|
|
16
|
+
NativeScreebReactNativeSpec(reactContext) {
|
|
17
|
+
|
|
18
|
+
override fun getName(): String = NAME
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
override fun initSdk(
|
|
22
|
+
channelId: String,
|
|
23
|
+
userId: String?,
|
|
24
|
+
properties: ReadableMap?,
|
|
25
|
+
hooks: ReadableMap?,
|
|
26
|
+
initOptions: ReadableMap?,
|
|
27
|
+
language: String?,
|
|
28
|
+
promise: Promise
|
|
29
|
+
) {
|
|
30
|
+
Screeb.setSecondarySDK("react-native", "2.2.0")
|
|
31
|
+
|
|
32
|
+
val mapHooks: HashMap<String, Any>? = hooks?.let { readable ->
|
|
33
|
+
hashMapOf<String, Any>().apply {
|
|
34
|
+
val itKeys = readable.keySetIterator()
|
|
35
|
+
while (itKeys.hasNextKey()) {
|
|
36
|
+
val key = itKeys.nextKey()
|
|
37
|
+
if (key == "version") {
|
|
38
|
+
put(key, readable.getString(key)!!)
|
|
39
|
+
} else {
|
|
40
|
+
val value = readable.getString(key)
|
|
41
|
+
put(key) { payload: Any ->
|
|
42
|
+
reactApplicationContext
|
|
43
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
44
|
+
.emit(
|
|
45
|
+
"ScreebEvent",
|
|
46
|
+
Arguments.createMap().apply {
|
|
47
|
+
putString("hookId", value!!)
|
|
48
|
+
putString("payload", payload.toString())
|
|
49
|
+
}
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
Handler(Looper.getMainLooper()).post {
|
|
58
|
+
Screeb.pluginInit(channelId, userId, fromReadableMap(properties), fromReadableMap(initOptions), mapHooks, language)
|
|
59
|
+
promise.resolve(null)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
override fun setIdentity(userId: String, properties: ReadableMap?, promise: Promise) {
|
|
64
|
+
Handler(Looper.getMainLooper()).post {
|
|
65
|
+
Screeb.setIdentity(userId, fromReadableMap(properties))
|
|
66
|
+
promise.resolve(null)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
override fun setProperties(properties: ReadableMap?, promise: Promise) {
|
|
71
|
+
Handler(Looper.getMainLooper()).post {
|
|
72
|
+
fromReadableMap(properties)?.let { Screeb.setVisitorProperties(it) }
|
|
73
|
+
promise.resolve(null)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
override fun assignGroup(type: String?, name: String, properties: ReadableMap?, promise: Promise) {
|
|
78
|
+
Handler(Looper.getMainLooper()).post {
|
|
79
|
+
Screeb.assignGroup(type, name, fromReadableMap(properties))
|
|
80
|
+
promise.resolve(null)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
override fun unassignGroup(type: String?, name: String, properties: ReadableMap?, promise: Promise) {
|
|
85
|
+
Handler(Looper.getMainLooper()).post {
|
|
86
|
+
Screeb.unassignGroup(type, name, fromReadableMap(properties))
|
|
87
|
+
promise.resolve(null)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
override fun trackEvent(name: String, properties: ReadableMap?, promise: Promise) {
|
|
92
|
+
Handler(Looper.getMainLooper()).post {
|
|
93
|
+
Screeb.trackEvent(name, fromReadableMap(properties))
|
|
94
|
+
promise.resolve(null)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
override fun trackScreen(name: String, properties: ReadableMap?, promise: Promise) {
|
|
99
|
+
Handler(Looper.getMainLooper()).post {
|
|
100
|
+
Screeb.trackScreen(name, fromReadableMap(properties))
|
|
101
|
+
promise.resolve(null)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
override fun startSurvey(
|
|
106
|
+
surveyId: String,
|
|
107
|
+
allowMultipleResponses: Boolean?,
|
|
108
|
+
hiddenFields: ReadableMap?,
|
|
109
|
+
ignoreSurveyStatus: Boolean?,
|
|
110
|
+
hooks: ReadableMap?,
|
|
111
|
+
language: String?,
|
|
112
|
+
distributionId: String?,
|
|
113
|
+
promise: Promise
|
|
114
|
+
) {
|
|
115
|
+
val mapHooks: HashMap<String, Any>? = hooks?.let { readable ->
|
|
116
|
+
hashMapOf<String, Any>().apply {
|
|
117
|
+
val itKeys = readable.keySetIterator()
|
|
118
|
+
while (itKeys.hasNextKey()) {
|
|
119
|
+
val key = itKeys.nextKey()
|
|
120
|
+
if (key == "version") {
|
|
121
|
+
put(key, readable.getString(key)!!)
|
|
122
|
+
} else {
|
|
123
|
+
val value = readable.getString(key)
|
|
124
|
+
put(key) { payload: Any ->
|
|
125
|
+
reactApplicationContext
|
|
126
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
127
|
+
.emit(
|
|
128
|
+
"ScreebEvent",
|
|
129
|
+
Arguments.createMap().apply {
|
|
130
|
+
putString("hookId", value!!)
|
|
131
|
+
putString("payload", payload.toString())
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
Handler(Looper.getMainLooper()).post {
|
|
141
|
+
Screeb.startSurvey(
|
|
142
|
+
surveyId,
|
|
143
|
+
allowMultipleResponses ?: true,
|
|
144
|
+
fromReadableMap(hiddenFields),
|
|
145
|
+
ignoreSurveyStatus ?: true,
|
|
146
|
+
mapHooks,
|
|
147
|
+
language,
|
|
148
|
+
distributionId
|
|
149
|
+
)
|
|
150
|
+
promise.resolve(null)
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
override fun startMessage(
|
|
155
|
+
messageId: String,
|
|
156
|
+
allowMultipleResponses: Boolean?,
|
|
157
|
+
hiddenFields: ReadableMap?,
|
|
158
|
+
ignoreMessageStatus: Boolean?,
|
|
159
|
+
hooks: ReadableMap?,
|
|
160
|
+
language: String?,
|
|
161
|
+
distributionId: String?,
|
|
162
|
+
promise: Promise
|
|
163
|
+
) {
|
|
164
|
+
val mapHooks: HashMap<String, Any>? = hooks?.let { readable ->
|
|
165
|
+
hashMapOf<String, Any>().apply {
|
|
166
|
+
val itKeys = readable.keySetIterator()
|
|
167
|
+
while (itKeys.hasNextKey()) {
|
|
168
|
+
val key = itKeys.nextKey()
|
|
169
|
+
if (key == "version") {
|
|
170
|
+
put(key, readable.getString(key)!!)
|
|
171
|
+
} else {
|
|
172
|
+
val value = readable.getString(key)
|
|
173
|
+
put(key) { payload: Any ->
|
|
174
|
+
reactApplicationContext
|
|
175
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
176
|
+
.emit(
|
|
177
|
+
"ScreebEvent",
|
|
178
|
+
Arguments.createMap().apply {
|
|
179
|
+
putString("hookId", value!!)
|
|
180
|
+
putString("payload", payload.toString())
|
|
181
|
+
}
|
|
182
|
+
)
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
Handler(Looper.getMainLooper()).post {
|
|
190
|
+
Screeb.startMessage(
|
|
191
|
+
messageId,
|
|
192
|
+
allowMultipleResponses ?: true,
|
|
193
|
+
fromReadableMap(hiddenFields),
|
|
194
|
+
ignoreMessageStatus ?: true,
|
|
195
|
+
mapHooks,
|
|
196
|
+
language,
|
|
197
|
+
distributionId
|
|
198
|
+
)
|
|
199
|
+
promise.resolve(null)
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
override fun debug(promise: Promise) {
|
|
204
|
+
Handler(Looper.getMainLooper()).post {
|
|
205
|
+
Screeb.debug()
|
|
206
|
+
promise.resolve(null)
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
override fun debugTargeting(promise: Promise) {
|
|
211
|
+
Handler(Looper.getMainLooper()).post {
|
|
212
|
+
Screeb.debugTargeting()
|
|
213
|
+
promise.resolve(null)
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
override fun resetIdentity(promise: Promise) {
|
|
218
|
+
Handler(Looper.getMainLooper()).post {
|
|
219
|
+
Screeb.resetIdentity()
|
|
220
|
+
promise.resolve(null)
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
override fun closeSdk(promise: Promise) {
|
|
225
|
+
Handler(Looper.getMainLooper()).post {
|
|
226
|
+
Screeb.closeSdk()
|
|
227
|
+
promise.resolve(null)
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
override fun closeSurvey(surveyId: String?, promise: Promise) {
|
|
232
|
+
Handler(Looper.getMainLooper()).post {
|
|
233
|
+
Screeb.closeSurvey(surveyId)
|
|
234
|
+
promise.resolve(null)
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
override fun closeMessage(messageId: String?, promise: Promise) {
|
|
239
|
+
Handler(Looper.getMainLooper()).post {
|
|
240
|
+
Screeb.closeMessage(messageId)
|
|
241
|
+
promise.resolve(null)
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
override fun onHookResult(hookId: String, result: ReadableMap, promise: Promise) {
|
|
246
|
+
Handler(Looper.getMainLooper()).post {
|
|
247
|
+
Screeb.onHookResult(hookId, result.toHashMap())
|
|
248
|
+
promise.resolve(null)
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
private fun fromReadableMap(readableMap: ReadableMap?): HashMap<String, Any?>? =
|
|
253
|
+
readableMap?.toHashMap() as? HashMap<String, Any?>
|
|
254
|
+
|
|
255
|
+
companion object {
|
|
256
|
+
const val NAME = "ScreebReactNative"
|
|
257
|
+
}
|
|
258
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
package app.screeb.reactnative
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.BaseReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
8
|
+
import java.util.HashMap
|
|
9
|
+
|
|
10
|
+
class ScreebReactNativePackage : BaseReactPackage() {
|
|
11
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
12
|
+
return if (name == ScreebReactNativeModule.NAME) {
|
|
13
|
+
ScreebReactNativeModule(reactContext)
|
|
14
|
+
} else {
|
|
15
|
+
null
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
20
|
+
return ReactModuleInfoProvider {
|
|
21
|
+
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
|
|
22
|
+
moduleInfos[ScreebReactNativeModule.NAME] = ReactModuleInfo(
|
|
23
|
+
ScreebReactNativeModule.NAME,
|
|
24
|
+
ScreebReactNativeModule.NAME,
|
|
25
|
+
false, // canOverrideExistingModule
|
|
26
|
+
false, // needsEagerInit
|
|
27
|
+
false, // isCxxModule
|
|
28
|
+
true // isTurboModule
|
|
29
|
+
)
|
|
30
|
+
moduleInfos
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#import <React/RCTBridgeModule.h>
|
|
2
|
+
#import <React/RCTEventEmitter.h>
|
|
3
|
+
|
|
4
|
+
@interface RCT_EXTERN_MODULE(ScreebReactNative, RCTEventEmitter)
|
|
5
|
+
|
|
6
|
+
RCT_EXTERN_METHOD(initSdk:(NSString *)channelId
|
|
7
|
+
userId:(nullable NSString *)userId
|
|
8
|
+
properties:(nullable NSDictionary *)properties
|
|
9
|
+
hooks:(nullable NSDictionary *)hooks
|
|
10
|
+
initOptions:(nullable NSDictionary *)initOptions
|
|
11
|
+
language:(nullable NSString *)language)
|
|
12
|
+
|
|
13
|
+
RCT_EXTERN_METHOD(setIdentity:(NSString *)userId
|
|
14
|
+
properties:(nullable NSDictionary *)properties)
|
|
15
|
+
|
|
16
|
+
RCT_EXTERN_METHOD(setProperties:(nullable NSDictionary *)properties)
|
|
17
|
+
|
|
18
|
+
RCT_EXTERN_METHOD(assignGroup:(nullable NSString *)type
|
|
19
|
+
name:(NSString *)name
|
|
20
|
+
properties:(nullable NSDictionary *)properties)
|
|
21
|
+
|
|
22
|
+
RCT_EXTERN_METHOD(unassignGroup:(nullable NSString *)type
|
|
23
|
+
name:(NSString *)name
|
|
24
|
+
properties:(nullable NSDictionary *)properties)
|
|
25
|
+
|
|
26
|
+
RCT_EXTERN_METHOD(trackEvent:(NSString *)name
|
|
27
|
+
properties:(nullable NSDictionary *)properties)
|
|
28
|
+
|
|
29
|
+
RCT_EXTERN_METHOD(trackScreen:(NSString *)name
|
|
30
|
+
properties:(nullable NSDictionary *)properties)
|
|
31
|
+
|
|
32
|
+
RCT_EXTERN_METHOD(startSurvey:(NSString *)surveyId
|
|
33
|
+
allowMultipleResponses:(BOOL)allowMultipleResponses
|
|
34
|
+
hiddenFields:(nullable NSDictionary *)hiddenFields
|
|
35
|
+
ignoreSurveyStatus:(BOOL)ignoreSurveyStatus
|
|
36
|
+
hooks:(nullable NSDictionary *)hooks
|
|
37
|
+
language:(nullable NSString *)language
|
|
38
|
+
distributionId:(nullable NSString *)distributionId)
|
|
39
|
+
|
|
40
|
+
RCT_EXTERN_METHOD(startMessage:(NSString *)messageId
|
|
41
|
+
allowMultipleResponses:(BOOL)allowMultipleResponses
|
|
42
|
+
hiddenFields:(nullable NSDictionary *)hiddenFields
|
|
43
|
+
ignoreMessageStatus:(BOOL)ignoreMessageStatus
|
|
44
|
+
hooks:(nullable NSDictionary *)hooks
|
|
45
|
+
language:(nullable NSString *)language
|
|
46
|
+
distributionId:(nullable NSString *)distributionId)
|
|
47
|
+
|
|
48
|
+
RCT_EXTERN_METHOD(debug)
|
|
49
|
+
|
|
50
|
+
RCT_EXTERN_METHOD(debugTargeting)
|
|
51
|
+
|
|
52
|
+
RCT_EXTERN_METHOD(resetIdentity)
|
|
53
|
+
|
|
54
|
+
RCT_EXTERN_METHOD(closeSdk)
|
|
55
|
+
|
|
56
|
+
RCT_EXTERN_METHOD(closeSurvey:(nullable NSString *)surveyId)
|
|
57
|
+
|
|
58
|
+
RCT_EXTERN_METHOD(closeMessage:(nullable NSString *)messageId)
|
|
59
|
+
|
|
60
|
+
RCT_EXTERN_METHOD(onHookResult:(NSString *)hookId
|
|
61
|
+
payload:(nullable NSDictionary *)payload)
|
|
62
|
+
|
|
63
|
+
@end
|