@survicate/react-native-survicate 3.0.3 → 3.1.1

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.
@@ -19,6 +19,10 @@ def safeExtGet(prop, fallback) {
19
19
  rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
20
20
  }
21
21
 
22
+ def isNewArchitectureEnabled() {
23
+ return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
24
+ }
25
+
22
26
  buildscript {
23
27
  // The Android Gradle plugin is only required when opening the android folder stand-alone.
24
28
  // This avoids unnecessary downloads and potential conflicts when the library is included as a
@@ -27,16 +31,20 @@ buildscript {
27
31
  if (project == rootProject) {
28
32
  repositories {
29
33
  google()
34
+ gradlePluginPortal()
30
35
  jcenter()
31
36
  }
32
37
  dependencies {
33
- classpath 'com.android.tools.build:gradle:4.2.2'
38
+ classpath 'com.android.tools.build:gradle:7.0.4'
34
39
  }
35
40
  }
36
41
  }
37
42
 
38
43
  apply plugin: 'com.android.library'
39
44
  apply plugin: "maven-publish"
45
+ if (isNewArchitectureEnabled()) {
46
+ apply plugin: 'com.facebook.react'
47
+ }
40
48
 
41
49
  android {
42
50
  compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
@@ -46,10 +54,22 @@ android {
46
54
  targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
47
55
  versionCode 1
48
56
  versionName "1.0"
57
+ buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
49
58
  }
50
59
  lintOptions {
51
60
  abortOnError false
52
61
  }
62
+ sourceSets {
63
+ main {
64
+ if (isNewArchitectureEnabled()) {
65
+ java.srcDirs += ['src/newarch',
66
+ // This is needed to build Kotlin project with NewArch enabled
67
+ "${project.buildDir}/generated/source/codegen/java"]
68
+ } else {
69
+ java.srcDirs += ['src/oldarch']
70
+ }
71
+ }
72
+ }
53
73
  }
54
74
 
55
75
  repositories {
@@ -67,6 +87,7 @@ repositories {
67
87
  // Android JSC is installed from npm
68
88
  url "$rootDir/../node_modules/jsc-android/dist"
69
89
  }
90
+ mavenCentral()
70
91
  google()
71
92
  jcenter()
72
93
  }
@@ -74,5 +95,13 @@ repositories {
74
95
  dependencies {
75
96
  //noinspection GradleDynamicVersion
76
97
  implementation 'com.facebook.react:react-native:+' // From node_modules
77
- implementation 'com.survicate:survicate-sdk:3.0.2'
98
+ implementation 'com.survicate:survicate-sdk:3.0.6'
99
+ }
100
+
101
+ if (isNewArchitectureEnabled()) {
102
+ react {
103
+ jsRootDir = file("../")
104
+ libraryName = "Survicate"
105
+ codegenJavaPackageName = "com.survicate.react"
106
+ }
78
107
  }
@@ -0,0 +1,5 @@
1
+ distributionBase=GRADLE_USER_HOME
2
+ distributionPath=wrapper/dists
3
+ distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
4
+ zipStoreBase=GRADLE_USER_HOME
5
+ zipStorePath=wrapper/dists
@@ -0,0 +1,240 @@
1
+ #!/bin/sh
2
+
3
+ #
4
+ # Copyright © 2015-2021 the original authors.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ ##############################################################################
20
+ #
21
+ # Gradle start up script for POSIX generated by Gradle.
22
+ #
23
+ # Important for running:
24
+ #
25
+ # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
26
+ # noncompliant, but you have some other compliant shell such as ksh or
27
+ # bash, then to run this script, type that shell name before the whole
28
+ # command line, like:
29
+ #
30
+ # ksh Gradle
31
+ #
32
+ # Busybox and similar reduced shells will NOT work, because this script
33
+ # requires all of these POSIX shell features:
34
+ # * functions;
35
+ # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
36
+ # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
37
+ # * compound commands having a testable exit status, especially «case»;
38
+ # * various built-in commands including «command», «set», and «ulimit».
39
+ #
40
+ # Important for patching:
41
+ #
42
+ # (2) This script targets any POSIX shell, so it avoids extensions provided
43
+ # by Bash, Ksh, etc; in particular arrays are avoided.
44
+ #
45
+ # The "traditional" practice of packing multiple parameters into a
46
+ # space-separated string is a well documented source of bugs and security
47
+ # problems, so this is (mostly) avoided, by progressively accumulating
48
+ # options in "$@", and eventually passing that to Java.
49
+ #
50
+ # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
51
+ # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
52
+ # see the in-line comments for details.
53
+ #
54
+ # There are tweaks for specific operating systems such as AIX, CygWin,
55
+ # Darwin, MinGW, and NonStop.
56
+ #
57
+ # (3) This script is generated from the Groovy template
58
+ # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59
+ # within the Gradle project.
60
+ #
61
+ # You can find Gradle at https://github.com/gradle/gradle/.
62
+ #
63
+ ##############################################################################
64
+
65
+ # Attempt to set APP_HOME
66
+
67
+ # Resolve links: $0 may be a link
68
+ app_path=$0
69
+
70
+ # Need this for daisy-chained symlinks.
71
+ while
72
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
73
+ [ -h "$app_path" ]
74
+ do
75
+ ls=$( ls -ld "$app_path" )
76
+ link=${ls#*' -> '}
77
+ case $link in #(
78
+ /*) app_path=$link ;; #(
79
+ *) app_path=$APP_HOME$link ;;
80
+ esac
81
+ done
82
+
83
+ APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84
+
85
+ APP_NAME="Gradle"
86
+ APP_BASE_NAME=${0##*/}
87
+
88
+ # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89
+ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
90
+
91
+ # Use the maximum available, or set MAX_FD != -1 to use that value.
92
+ MAX_FD=maximum
93
+
94
+ warn () {
95
+ echo "$*"
96
+ } >&2
97
+
98
+ die () {
99
+ echo
100
+ echo "$*"
101
+ echo
102
+ exit 1
103
+ } >&2
104
+
105
+ # OS specific support (must be 'true' or 'false').
106
+ cygwin=false
107
+ msys=false
108
+ darwin=false
109
+ nonstop=false
110
+ case "$( uname )" in #(
111
+ CYGWIN* ) cygwin=true ;; #(
112
+ Darwin* ) darwin=true ;; #(
113
+ MSYS* | MINGW* ) msys=true ;; #(
114
+ NONSTOP* ) nonstop=true ;;
115
+ esac
116
+
117
+ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
118
+
119
+
120
+ # Determine the Java command to use to start the JVM.
121
+ if [ -n "$JAVA_HOME" ] ; then
122
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123
+ # IBM's JDK on AIX uses strange locations for the executables
124
+ JAVACMD=$JAVA_HOME/jre/sh/java
125
+ else
126
+ JAVACMD=$JAVA_HOME/bin/java
127
+ fi
128
+ if [ ! -x "$JAVACMD" ] ; then
129
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130
+
131
+ Please set the JAVA_HOME variable in your environment to match the
132
+ location of your Java installation."
133
+ fi
134
+ else
135
+ JAVACMD=java
136
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137
+
138
+ Please set the JAVA_HOME variable in your environment to match the
139
+ location of your Java installation."
140
+ fi
141
+
142
+ # Increase the maximum file descriptors if we can.
143
+ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144
+ case $MAX_FD in #(
145
+ max*)
146
+ MAX_FD=$( ulimit -H -n ) ||
147
+ warn "Could not query maximum file descriptor limit"
148
+ esac
149
+ case $MAX_FD in #(
150
+ '' | soft) :;; #(
151
+ *)
152
+ ulimit -n "$MAX_FD" ||
153
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
154
+ esac
155
+ fi
156
+
157
+ # Collect all arguments for the java command, stacking in reverse order:
158
+ # * args from the command line
159
+ # * the main class name
160
+ # * -classpath
161
+ # * -D...appname settings
162
+ # * --module-path (only if needed)
163
+ # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
164
+
165
+ # For Cygwin or MSYS, switch paths to Windows format before running java
166
+ if "$cygwin" || "$msys" ; then
167
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
168
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
169
+
170
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
171
+
172
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
173
+ for arg do
174
+ if
175
+ case $arg in #(
176
+ -*) false ;; # don't mess with options #(
177
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
178
+ [ -e "$t" ] ;; #(
179
+ *) false ;;
180
+ esac
181
+ then
182
+ arg=$( cygpath --path --ignore --mixed "$arg" )
183
+ fi
184
+ # Roll the args list around exactly as many times as the number of
185
+ # args, so each arg winds up back in the position where it started, but
186
+ # possibly modified.
187
+ #
188
+ # NB: a `for` loop captures its iteration list before it begins, so
189
+ # changing the positional parameters here affects neither the number of
190
+ # iterations, nor the values presented in `arg`.
191
+ shift # remove old arg
192
+ set -- "$@" "$arg" # push replacement arg
193
+ done
194
+ fi
195
+
196
+ # Collect all arguments for the java command;
197
+ # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198
+ # shell script including quotes and variable substitutions, so put them in
199
+ # double quotes to make sure that they get re-expanded; and
200
+ # * put everything else in single quotes, so that it's not re-expanded.
201
+
202
+ set -- \
203
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
204
+ -classpath "$CLASSPATH" \
205
+ org.gradle.wrapper.GradleWrapperMain \
206
+ "$@"
207
+
208
+ # Stop when "xargs" is not available.
209
+ if ! command -v xargs >/dev/null 2>&1
210
+ then
211
+ die "xargs is not available"
212
+ fi
213
+
214
+ # Use "xargs" to parse quoted args.
215
+ #
216
+ # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
217
+ #
218
+ # In Bash we could simply go:
219
+ #
220
+ # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
221
+ # set -- "${ARGS[@]}" "$@"
222
+ #
223
+ # but POSIX shell has neither arrays nor command substitution, so instead we
224
+ # post-process each arg (as a line of input to sed) to backslash-escape any
225
+ # character that might be a shell metacharacter, then use eval to reverse
226
+ # that process (while maintaining the separation between arguments), and wrap
227
+ # the whole thing up as a single "set" statement.
228
+ #
229
+ # This will of course break if any of these variables contains a newline or
230
+ # an unmatched quote.
231
+ #
232
+
233
+ eval "set -- $(
234
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
235
+ xargs -n1 |
236
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
237
+ tr '\n' ' '
238
+ )" '"$@"'
239
+
240
+ exec "$JAVACMD" "$@"
@@ -0,0 +1,91 @@
1
+ @rem
2
+ @rem Copyright 2015 the original author or authors.
3
+ @rem
4
+ @rem Licensed under the Apache License, Version 2.0 (the "License");
5
+ @rem you may not use this file except in compliance with the License.
6
+ @rem You may obtain a copy of the License at
7
+ @rem
8
+ @rem https://www.apache.org/licenses/LICENSE-2.0
9
+ @rem
10
+ @rem Unless required by applicable law or agreed to in writing, software
11
+ @rem distributed under the License is distributed on an "AS IS" BASIS,
12
+ @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ @rem See the License for the specific language governing permissions and
14
+ @rem limitations under the License.
15
+ @rem
16
+
17
+ @if "%DEBUG%"=="" @echo off
18
+ @rem ##########################################################################
19
+ @rem
20
+ @rem Gradle startup script for Windows
21
+ @rem
22
+ @rem ##########################################################################
23
+
24
+ @rem Set local scope for the variables with windows NT shell
25
+ if "%OS%"=="Windows_NT" setlocal
26
+
27
+ set DIRNAME=%~dp0
28
+ if "%DIRNAME%"=="" set DIRNAME=.
29
+ set APP_BASE_NAME=%~n0
30
+ set APP_HOME=%DIRNAME%
31
+
32
+ @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33
+ for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34
+
35
+ @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36
+ set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37
+
38
+ @rem Find java.exe
39
+ if defined JAVA_HOME goto findJavaFromJavaHome
40
+
41
+ set JAVA_EXE=java.exe
42
+ %JAVA_EXE% -version >NUL 2>&1
43
+ if %ERRORLEVEL% equ 0 goto execute
44
+
45
+ echo.
46
+ echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47
+ echo.
48
+ echo Please set the JAVA_HOME variable in your environment to match the
49
+ echo location of your Java installation.
50
+
51
+ goto fail
52
+
53
+ :findJavaFromJavaHome
54
+ set JAVA_HOME=%JAVA_HOME:"=%
55
+ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56
+
57
+ if exist "%JAVA_EXE%" goto execute
58
+
59
+ echo.
60
+ echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61
+ echo.
62
+ echo Please set the JAVA_HOME variable in your environment to match the
63
+ echo location of your Java installation.
64
+
65
+ goto fail
66
+
67
+ :execute
68
+ @rem Setup the command line
69
+
70
+ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71
+
72
+
73
+ @rem Execute Gradle
74
+ "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75
+
76
+ :end
77
+ @rem End local scope for the variables with windows NT shell
78
+ if %ERRORLEVEL% equ 0 goto mainEnd
79
+
80
+ :fail
81
+ rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82
+ rem the _cmd.exe /c_ return code!
83
+ set EXIT_CODE=%ERRORLEVEL%
84
+ if %EXIT_CODE% equ 0 set EXIT_CODE=1
85
+ if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
86
+ exit /b %EXIT_CODE%
87
+
88
+ :mainEnd
89
+ if "%OS%"=="Windows_NT" endlocal
90
+
91
+ :omega
@@ -1,24 +1,26 @@
1
1
  package com.survicate.react;
2
2
 
3
3
  import com.facebook.react.bridge.ReactApplicationContext;
4
- import com.facebook.react.bridge.ReactContextBaseJavaModule;
5
4
  import com.facebook.react.bridge.ReactMethod;
6
- import com.facebook.react.bridge.Callback;
7
5
  import com.survicate.surveys.Survicate;
8
6
  import com.survicate.surveys.traits.UserTrait;
9
7
 
10
- public class SurvicateBindingsModule extends ReactContextBaseJavaModule {
8
+ import com.survicate.react.SurvicateModule;
9
+
10
+ public class SurvicateModuleImpl extends SurvicateModule {
11
+
12
+ public static final String NAME = "SurvicateBindings";
11
13
 
12
14
  private final ReactApplicationContext reactContext;
13
15
 
14
- public SurvicateBindingsModule(ReactApplicationContext reactContext) {
16
+ public SurvicateModuleImpl(ReactApplicationContext reactContext) {
15
17
  super(reactContext);
16
18
  this.reactContext = reactContext;
17
19
  }
18
20
 
19
21
  @Override
20
22
  public String getName() {
21
- return "SurvicateBindings";
23
+ return NAME;
22
24
  }
23
25
 
24
26
  @ReactMethod
@@ -29,9 +31,9 @@ public class SurvicateBindingsModule extends ReactContextBaseJavaModule {
29
31
  @ReactMethod
30
32
  public void leaveScreen(String screenName) {
31
33
  Survicate.leaveScreen(screenName);
32
- }
34
+ }
33
35
 
34
- @ReactMethod
36
+ @ReactMethod
35
37
  public void invokeEvent(String eventName) {
36
38
  Survicate.invokeEvent(eventName);
37
39
  }
@@ -0,0 +1,46 @@
1
+ package com.survicate.react;
2
+
3
+ import androidx.annotation.Nullable;
4
+
5
+ import com.facebook.react.TurboReactPackage;
6
+ import com.facebook.react.bridge.NativeModule;
7
+ import com.facebook.react.bridge.ReactApplicationContext;
8
+ import com.facebook.react.module.model.ReactModuleInfo;
9
+ import com.facebook.react.module.model.ReactModuleInfoProvider;
10
+
11
+ import com.survicate.react.SurvicateModule;
12
+ import java.util.HashMap;
13
+ import java.util.Map;
14
+
15
+ public class SurvicatePackage extends TurboReactPackage {
16
+
17
+ @Nullable
18
+ @Override
19
+ public NativeModule getModule(String name, ReactApplicationContext reactApplicationContext) {
20
+ if (SurvicateModuleImpl.NAME.equals(name)) {
21
+ return new SurvicateModuleImpl(reactApplicationContext);
22
+ } else {
23
+ return null;
24
+ }
25
+ }
26
+
27
+ @Override
28
+ public ReactModuleInfoProvider getReactModuleInfoProvider() {
29
+ return () -> {
30
+ final Map<String, ReactModuleInfo> moduleInfos = new HashMap<>();
31
+ boolean isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
32
+ moduleInfos.put(
33
+ SurvicateModuleImpl.NAME,
34
+ new ReactModuleInfo(
35
+ SurvicateModuleImpl.NAME,
36
+ SurvicateModuleImpl.NAME,
37
+ false, // canOverrideExistingModule
38
+ false, // needsEagerInit
39
+ true, // hasConstants
40
+ false, // isCxxModule
41
+ isTurboModule // isTurboModule
42
+ ));
43
+ return moduleInfos;
44
+ };
45
+ }
46
+ }
@@ -0,0 +1,11 @@
1
+ package com.survicate.react;
2
+
3
+ import androidx.annotation.NonNull;
4
+
5
+ import com.facebook.react.bridge.ReactApplicationContext;
6
+
7
+ public abstract class SurvicateModule extends NativeSurvicateModuleSpec {
8
+ public SurvicateModule(@NonNull ReactApplicationContext reactContext) {
9
+ super(reactContext);
10
+ }
11
+ }
@@ -0,0 +1,23 @@
1
+ package com.survicate.react;
2
+
3
+ import androidx.annotation.NonNull;
4
+
5
+ import com.facebook.react.bridge.ReactApplicationContext;
6
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
7
+
8
+ public abstract class SurvicateModule extends ReactContextBaseJavaModule {
9
+
10
+ public SurvicateModule(@NonNull ReactApplicationContext reactContext) {
11
+ super(reactContext);
12
+ }
13
+
14
+ public abstract void enterScreen(String screenName);
15
+ public abstract void leaveScreen(String screenName);
16
+ public abstract void invokeEvent(String eventName);
17
+ public abstract void setUserId(String userId);
18
+ public abstract void setUserTrait(String userTrait, String value);
19
+ public abstract void initialize();
20
+ public abstract void initializeSdk();
21
+ public abstract void reset();
22
+ public abstract void setWorkspaceKey(String workspaceKey);
23
+ }
@@ -1,9 +1,11 @@
1
- #if __has_include("RCTBridgeModule.h")
2
- #import "RCTBridgeModule.h"
1
+ #ifdef RCT_NEW_ARCH_ENABLED
2
+ #import "RNSurvicateSpec.h"
3
+
4
+ @interface SurvicateBindings : NSObject <NativeSurvicateModuleSpec>
3
5
  #else
4
6
  #import <React/RCTBridgeModule.h>
5
- #endif
6
7
 
7
8
  @interface SurvicateBindings : NSObject <RCTBridgeModule>
9
+ #endif
8
10
 
9
11
  @end
@@ -1,5 +1,5 @@
1
1
  #import "SurvicateBindings.h"
2
- @import Survicate;
2
+ #import <Survicate/Survicate-Swift.h>
3
3
 
4
4
  @implementation SurvicateBindings
5
5
 
@@ -30,9 +30,9 @@ RCT_EXPORT_METHOD(setUserId:(NSString *)userId)
30
30
  [[SurvicateSdk shared] setUserTraitWithName:@"user_id" value:userId];
31
31
  }
32
32
 
33
- RCT_EXPORT_METHOD(setUserTrait:(NSString *)traitName value:(NSString *)value)
33
+ RCT_EXPORT_METHOD(setUserTrait:(NSString *)traitName traitValue:(NSString *)traitValue)
34
34
  {
35
- [[SurvicateSdk shared] setUserTraitWithName:traitName value:value];
35
+ [[SurvicateSdk shared] setUserTraitWithName:traitName value:traitValue];
36
36
  }
37
37
 
38
38
  RCT_EXPORT_METHOD(initialize)
@@ -56,4 +56,13 @@ RCT_EXPORT_METHOD(setWorkspaceKey:(NSString *)workspaceKey)
56
56
  [[SurvicateSdk shared] setWorkspaceKey:workspaceKey error: &error];
57
57
  }
58
58
 
59
+ // Don't compile this code when we build for the old architecture.
60
+ #ifdef RCT_NEW_ARCH_ENABLED
61
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
62
+ (const facebook::react::ObjCTurboModule::InitParams &)params
63
+ {
64
+ return std::make_shared<facebook::react::NativeSurvicateModuleSpecJSI>(params);
65
+ }
66
+ #endif
67
+
59
68
  @end
@@ -7,7 +7,7 @@
7
7
  objects = {
8
8
 
9
9
  /* Begin PBXBuildFile section */
10
- B3E7B58A1CC2AC0600A0062D /* SurvicateBindings.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* SurvicateBindings.m */; };
10
+ B3E7B58A1CC2AC0600A0062D /* SurvicateBindings.mm in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* SurvicateBindings.mm */; };
11
11
  /* End PBXBuildFile section */
12
12
 
13
13
  /* Begin PBXCopyFilesBuildPhase section */
@@ -25,7 +25,7 @@
25
25
  /* Begin PBXFileReference section */
26
26
  134814201AA4EA6300B7C361 /* libSurvicateBindings.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libSurvicateBindings.a; sourceTree = BUILT_PRODUCTS_DIR; };
27
27
  B3E7B5881CC2AC0600A0062D /* SurvicateBindings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SurvicateBindings.h; sourceTree = "<group>"; };
28
- B3E7B5891CC2AC0600A0062D /* SurvicateBindings.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SurvicateBindings.m; sourceTree = "<group>"; };
28
+ B3E7B5891CC2AC0600A0062D /* SurvicateBindings.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SurvicateBindings.mm; sourceTree = "<group>"; };
29
29
  /* End PBXFileReference section */
30
30
 
31
31
  /* Begin PBXFrameworksBuildPhase section */
@@ -51,7 +51,7 @@
51
51
  isa = PBXGroup;
52
52
  children = (
53
53
  B3E7B5881CC2AC0600A0062D /* SurvicateBindings.h */,
54
- B3E7B5891CC2AC0600A0062D /* SurvicateBindings.m */,
54
+ B3E7B5891CC2AC0600A0062D /* SurvicateBindings.mm */,
55
55
  134814211AA4EA7D00B7C361 /* Products */,
56
56
  );
57
57
  sourceTree = "<group>";
@@ -113,7 +113,7 @@
113
113
  isa = PBXSourcesBuildPhase;
114
114
  buildActionMask = 2147483647;
115
115
  files = (
116
- B3E7B58A1CC2AC0600A0062D /* SurvicateBindings.m in Sources */,
116
+ B3E7B58A1CC2AC0600A0062D /* SurvicateBindings.mm in Sources */,
117
117
  );
118
118
  runOnlyForDeploymentPostprocessing = 0;
119
119
  };
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@survicate/react-native-survicate",
3
3
  "title": "React Native Survicate Bindings",
4
- "version": "3.0.3",
4
+ "version": "3.1.1",
5
5
  "description": "React Native bindings for Survicate Mobile SDK",
6
- "main": "index.js",
6
+ "main": "src/index.js",
7
7
  "scripts": {
8
8
  "test": "echo \"Error: no test specified\" && exit 1"
9
9
  },
@@ -27,7 +27,20 @@
27
27
  "react-native": ">=0.60.0"
28
28
  },
29
29
  "devDependencies": {
30
+ "@tsconfig/react-native": "^3.0.2",
31
+ "@types/jest": "^29.5.4",
32
+ "@types/react": "^18.2.21",
33
+ "@types/react-test-renderer": "^18.0.1",
30
34
  "react": "18.2.0",
31
- "react-native": "0.72.4"
35
+ "react-native": "0.72.6",
36
+ "typescript": "5.2.2"
37
+ },
38
+ "codegenConfig": {
39
+ "name": "RNSurvicateSpec",
40
+ "type": "modules",
41
+ "jsSrcsDir": "src",
42
+ "android": {
43
+ "javaPackageName": "com.survicate.react"
44
+ }
32
45
  }
33
46
  }
@@ -1,6 +1,7 @@
1
1
  require "json"
2
2
 
3
3
  package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
4
5
 
5
6
  Pod::Spec.new do |s|
6
7
  s.name = "react-native-survicate"
@@ -16,12 +17,35 @@ Pod::Spec.new do |s|
16
17
  s.platforms = { :ios => "10.0" }
17
18
  s.source = { :git => "https://github.com/Survicate/survicate-react-native-sdk.git", :tag => "#{s.version}" }
18
19
 
19
- s.source_files = "ios/**/*.{h,m,swift}"
20
+ s.source_files = "ios/**/*.{h,mm,swift}"
20
21
  s.requires_arc = true
21
22
 
22
23
  s.dependency "React"
23
- s.dependency "Survicate", "3.0.2"
24
+ s.dependency "Survicate", "3.0.4"
24
25
  # ...
25
26
  # s.dependency "..."
27
+
28
+ # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
29
+ # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
30
+ if respond_to?(:install_modules_dependencies, true)
31
+ install_modules_dependencies(s)
32
+ else
33
+ s.dependency "React-Core"
34
+
35
+ # Don't install the dependencies when we run `pod install` in the old architecture.
36
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
37
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
38
+ s.pod_target_xcconfig = {
39
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
40
+ "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
41
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
42
+ }
43
+ s.dependency "React-Codegen"
44
+ s.dependency "RCT-Folly"
45
+ s.dependency "RCTRequired"
46
+ s.dependency "RCTTypeSafety"
47
+ s.dependency "ReactCommon/turbomodule/core"
48
+ end
49
+ end
26
50
  end
27
51
 
@@ -0,0 +1,16 @@
1
+ import type { TurboModule } from "react-native";
2
+ import { TurboModuleRegistry } from "react-native";
3
+
4
+ export interface Spec extends TurboModule {
5
+ initialize(): void;
6
+ initializeSdk(): void;
7
+ invokeEvent(eventName: string): void;
8
+ enterScreen(screenName: string): void;
9
+ leaveScreen(screenName: string): void;
10
+ setUserId(userId: string): void;
11
+ setUserTrait(traitName: string, traitValue: string): void;
12
+ setWorkspaceKey(workspaceKey: string): void;
13
+ reset(): void;
14
+ }
15
+
16
+ export default TurboModuleRegistry.get<Spec>("SurvicateBindings");
package/src/index.js ADDED
@@ -0,0 +1,10 @@
1
+ import { NativeModules } from 'react-native';
2
+
3
+ const { SurvicateBindings } = NativeModules;
4
+ const isTurboModuleEnabled = global.__turboModuleProxy != null;
5
+
6
+ const survicate = isTurboModuleEnabled ?
7
+ require("./NativeSurvicateModule").default :
8
+ SurvicateBindings;
9
+
10
+ export default survicate;
package/tsconfig.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "@tsconfig/react-native/tsconfig.json"
3
+ }
@@ -1,23 +0,0 @@
1
- package com.survicate.react;
2
-
3
- import java.util.Arrays;
4
- import java.util.Collections;
5
- import java.util.List;
6
-
7
- import com.facebook.react.ReactPackage;
8
- import com.facebook.react.bridge.NativeModule;
9
- import com.facebook.react.bridge.ReactApplicationContext;
10
- import com.facebook.react.uimanager.ViewManager;
11
- import com.facebook.react.bridge.JavaScriptModule;
12
-
13
- public class SurvicateBindingsPackage implements ReactPackage {
14
- @Override
15
- public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
16
- return Arrays.<NativeModule>asList(new SurvicateBindingsModule(reactContext));
17
- }
18
-
19
- @Override
20
- public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
21
- return Collections.emptyList();
22
- }
23
- }
package/index.js DELETED
@@ -1,5 +0,0 @@
1
- import { NativeModules } from 'react-native';
2
-
3
- const { SurvicateBindings } = NativeModules;
4
-
5
- export default SurvicateBindings;