├── .gitattributes
├── .github
└── workflows
│ └── test-android.yaml
├── .gitignore
├── .maestro
└── test-show-survey.yaml
├── README.md
├── android
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── src
│ ├── main
│ ├── AndroidManifest.xml
│ ├── AndroidManifestNew.xml
│ └── java
│ │ └── com
│ │ └── survicate
│ │ └── react
│ │ ├── SurvicateModuleImpl.java
│ │ ├── SurvicatePackage.java
│ │ └── SurvicateRNEventListener.java
│ ├── newarch
│ └── java
│ │ └── com
│ │ └── survicate
│ │ └── react
│ │ └── SurvicateModule.java
│ └── oldarch
│ └── java
│ └── com
│ └── survicate
│ └── react
│ └── SurvicateModule.java
├── app.plugin.js
├── example
└── react_native
│ ├── .gitignore
│ ├── App.tsx
│ ├── Gemfile
│ ├── README.md
│ ├── android
│ ├── app
│ │ ├── build.gradle
│ │ ├── debug.keystore
│ │ ├── proguard-rules.pro
│ │ └── src
│ │ │ ├── debug
│ │ │ └── AndroidManifest.xml
│ │ │ └── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── react_native
│ │ │ │ ├── MainActivity.kt
│ │ │ │ └── MainApplication.kt
│ │ │ └── res
│ │ │ ├── drawable
│ │ │ └── rn_edit_text_material.xml
│ │ │ ├── mipmap-hdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ └── values
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ └── settings.gradle
│ ├── app.json
│ ├── babel.config.js
│ ├── index.js
│ ├── ios
│ ├── .xcode.env
│ ├── Podfile
│ ├── Podfile.lock
│ ├── react_native.xcodeproj
│ │ ├── project.pbxproj
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ └── react_native.xcscheme
│ ├── react_native.xcworkspace
│ │ └── contents.xcworkspacedata
│ ├── react_native
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.mm
│ │ ├── Images.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ │ └── Contents.json
│ │ ├── Info.plist
│ │ ├── LaunchScreen.storyboard
│ │ ├── PrivacyInfo.xcprivacy
│ │ └── main.m
│ └── react_nativeTests
│ │ ├── Info.plist
│ │ └── react_nativeTests.m
│ ├── metro.config.js
│ ├── package.json
│ ├── react-native.config.js
│ └── yarn.lock
├── ios
├── SurvicateBindings.h
├── SurvicateBindings.mm
├── SurvicateBindings.xcodeproj
│ └── project.pbxproj
└── SurvicateBindings.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ └── IDEWorkspaceChecks.plist
├── package.json
├── react-native-survicate.podspec
├── src
├── NativeSurvicateModule.ts
├── expo
│ ├── types.ts
│ ├── withSurvicate.ts
│ ├── withSurvicateAndroid.ts
│ └── withSurvicateiOS.ts
└── index.ts
├── test
└── react_native
│ ├── .gitignore
│ ├── App.tsx
│ ├── Gemfile
│ ├── Gemfile.lock
│ ├── README.md
│ ├── android
│ ├── app
│ │ ├── build.gradle
│ │ ├── debug.keystore
│ │ ├── proguard-rules.pro
│ │ └── src
│ │ │ ├── debug
│ │ │ └── AndroidManifest.xml
│ │ │ └── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── react_native
│ │ │ │ ├── MainActivity.kt
│ │ │ │ └── MainApplication.kt
│ │ │ └── res
│ │ │ ├── drawable
│ │ │ └── rn_edit_text_material.xml
│ │ │ ├── mipmap-hdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ └── values
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ └── settings.gradle
│ ├── app.json
│ ├── babel.config.js
│ ├── env.d.ts
│ ├── index.js
│ ├── ios
│ ├── .xcode.env
│ ├── Podfile
│ ├── Podfile.lock
│ ├── react_native.xcodeproj
│ │ ├── project.pbxproj
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ └── react_native.xcscheme
│ ├── react_native.xcworkspace
│ │ └── contents.xcworkspacedata
│ ├── react_native
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.mm
│ │ ├── Images.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ │ └── Contents.json
│ │ ├── Info.plist
│ │ ├── LaunchScreen.storyboard
│ │ ├── PrivacyInfo.xcprivacy
│ │ └── main.m
│ └── react_nativeTests
│ │ ├── Info.plist
│ │ └── react_nativeTests.m
│ ├── metro.config.js
│ ├── package.json
│ ├── react-native.config.js
│ └── yarn.lock
├── tsconfig.build.json
├── tsconfig.json
└── yarn.lock
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.pbxproj -text
2 |
--------------------------------------------------------------------------------
/.github/workflows/test-android.yaml:
--------------------------------------------------------------------------------
1 | name: Test Android App
2 |
3 | on: [push]
4 |
5 | env :
6 | SURVICATE_SDK: survicate_sdk.tgz
7 | SURVICATE: survicate
8 | ANDROID_APK: app-release.apk
9 | ANDROID: android-apk
10 |
11 | jobs:
12 | build-react-native-sdk:
13 | runs-on: ubuntu-latest
14 | steps:
15 | - name: Checkout Repository
16 | uses: actions/checkout@v4
17 |
18 | - name: Set up Node.js
19 | uses: actions/setup-node@v4
20 | with:
21 | node-version: '20'
22 |
23 | - name: Install Dependencies
24 | run: |
25 | yarn
26 |
27 | - name: Generate Tarball
28 | run: |
29 | npm pack
30 | TARBALL_NAME=$(ls *.tgz)
31 | mv $TARBALL_NAME test/react_native/${{ env.SURVICATE_SDK }}
32 |
33 | - name: Upload Survicate SDK Tarball
34 | uses: actions/upload-artifact@v4
35 | with:
36 | name: ${{ env.SURVICATE }}
37 | path: test/react_native/${{ env.SURVICATE_SDK }}
38 |
39 | build-android-app:
40 | runs-on: ubuntu-latest
41 | needs: build-react-native-sdk
42 | steps:
43 | - name: Checkout Repository
44 | uses: actions/checkout@v4
45 |
46 | - name: Set up Node.js
47 | uses: actions/setup-node@v4
48 | with:
49 | node-version: '20'
50 |
51 | - name: Download Survicate SDK Tarball
52 | uses: actions/download-artifact@v4
53 | with:
54 | name: ${{ env.SURVICATE }}
55 | path: test/react_native
56 |
57 | - name: Install Test App Dependencies
58 | working-directory: test/react_native
59 | run: |
60 | yarn
61 | yarn add ./${{ env.SURVICATE_SDK }}
62 |
63 | - name: Setup Workspace Key
64 | working-directory: test/react_native
65 | run: |
66 | echo "WORKSPACE_KEY=${{ secrets.WORKSPACE_KEY }}" > .env
67 |
68 | - name: Setup Java
69 | uses: actions/setup-java@v4
70 | with:
71 | distribution: 'temurin'
72 | java-version: '17'
73 |
74 | - name: Validate Gradle wrapper
75 | uses: gradle/actions/wrapper-validation@v3
76 |
77 | - name: Setup Gradle
78 | uses: gradle/actions/setup-gradle@v3
79 |
80 | - name: Setup Android
81 | working-directory: test/react_native/android
82 | run: chmod +x gradlew
83 |
84 | - name: Build APK
85 | working-directory: test/react_native/android
86 | run: |
87 | ./gradlew app:assembleRelease
88 |
89 | - name: Upload Android APK
90 | uses: actions/upload-artifact@v4
91 | with:
92 | name: ${{ env.ANDROID }}
93 | path: test/react_native/android/app/build/outputs/apk/release/${{ env.ANDROID_APK }}
94 |
95 |
96 | run-android-tests:
97 | runs-on: ubuntu-latest
98 | needs: build-android-app
99 | steps:
100 | - name: Checkout Repository
101 | uses: actions/checkout@v4
102 |
103 | - name: Install Maestro
104 | run: |
105 | curl -Ls --retry 3 --retry-all-errors "https://get.maestro.mobile.dev" | bash
106 | echo "${HOME}/.maestro/bin" >> $GITHUB_PATH
107 |
108 | - name: Enable KVM
109 | run: |
110 | echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
111 | sudo udevadm control --reload-rules
112 | sudo udevadm trigger --name-match=kvm
113 |
114 | - name: Download Android APK
115 | uses: actions/download-artifact@v4
116 | with:
117 | name: ${{ env.ANDROID }}
118 |
119 | - name: Run tests on emulator
120 | uses: reactivecircus/android-emulator-runner@v2
121 | with:
122 | api-level: 34
123 | target: google_apis
124 | arch: x86_64
125 | emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -no-metrics
126 | script: |
127 | adb install -r ${{ env.ANDROID_APK }}
128 | maestro test .maestro/test-show-survey.yaml --format junit
129 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # OSX
2 | #
3 | .DS_Store
4 |
5 | # node.js
6 | #
7 | node_modules/
8 | npm-debug.log
9 | yarn-error.log
10 |
11 | # Xcode
12 | #
13 | build/
14 | *.pbxuser
15 | !default.pbxuser
16 | *.mode1v3
17 | !default.mode1v3
18 | *.mode2v3
19 | !default.mode2v3
20 | *.perspectivev3
21 | !default.perspectivev3
22 | xcuserdata
23 | *.xccheckout
24 | *.moved-aside
25 | DerivedData
26 | *.hmap
27 | *.ipa
28 | *.xcuserstate
29 | project.xcworkspace
30 |
31 | # Android/IntelliJ
32 | #
33 | build/
34 | .idea
35 | .gradle
36 | local.properties
37 | *.iml
38 |
39 | # BUCK
40 | buck-out/
41 | \.buckd/
42 | *.keystore
43 |
44 | # generated files by bob
45 | lib/
46 |
--------------------------------------------------------------------------------
/.maestro/test-show-survey.yaml:
--------------------------------------------------------------------------------
1 | appId: com.react_native
2 | ---
3 | - launchApp
4 | - assertVisible: "Test App"
5 | - tapOn: "Invoke Event: Event"
6 | - assertVisible: "Welcome to our Survey!"
7 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # @survicate/react-native-survicate 
2 |
3 | Integrate Survicate into your React Native application to collect user feedback seamlessly.
4 |
5 | ## Requirements:
6 | - iOS at least on version 14.0
7 | - Android at least on version 5
8 | - React Native at least on version 0.60.0
9 |
10 | ## Installation
11 | This package can be installed using npm or yarn. If you're using Expo, follow the Expo-specific instructions.
12 |
13 | ### Using npm
14 | ```sh
15 | npm install @survicate/react-native-survicate --save
16 | ```
17 |
18 | ### Using yarn
19 | ```sh
20 | yarn add @survicate/react-native-survicate
21 | ```
22 |
23 | ### Using expo
24 | > Please note that due to custom native code in this package "Expo Go" is not available.
25 |
26 | To use @survicate/react-native-survicate in an Expo managed project use npm, yarn or expo-cli.
27 | ```sh
28 | expo install @survicate/react-native-survicate
29 | ```
30 |
31 | ## Configuration
32 |
33 | ### Configuring Survicate Bindings for iOS
34 | - Add your Survicate workspace key to `Info.plist`
35 | ```
36 | Survicate
37 |
38 | WorkspaceKey
39 | YOUR_WORKSPACE_KEY
40 |
41 | ```
42 | - run command `pod install` in your `ios` directory
43 |
44 | ### Configuring Survicate Bindings for Android
45 |
46 | - Add maven repository to your project `build.gradle` located under `android` directory
47 | ```
48 | allprojects {
49 | repositories {
50 | // ...
51 | maven { url 'https://repo.survicate.com' }
52 | }
53 | }
54 | ```
55 | - Add your Survicate workspace key to `AndroidManifest.xml`
56 | ```java
57 |
60 |
61 |
62 |
63 | ```
64 |
65 | ### Configuring Survicate Bindings for Expo
66 | - Add [config plugin](https://docs.expo.dev/config-plugins/introduction/) to `plugins` array of your `app.json` or `app.config.js`
67 | ```json
68 | {
69 | "expo": {
70 | "plugins": [
71 | [
72 | "@survicate/react-native-survicate",
73 | {
74 | "workspaceKey": "YOUR_WORKSPACE_KEY"
75 | }
76 | ]
77 | ]
78 | }
79 | }
80 | ```
81 | > Please note that every time you change the props or plugins, you'll need to [rebuild](https://docs.expo.dev/workflow/customizing/) the native app.
82 |
83 |
84 | ## Usage
85 | ```javascript
86 | import Survicate, {UserTrait} from '@survicate/react-native-survicate';
87 |
88 | Survicate.initializeSdk();
89 | Survicate.setWorkspaceKey('WORKSPACE_KEY');
90 | Survicate.invokeEvent("eventName");
91 | const properties = {
92 | "property1": "value1",
93 | "property2": "value2"
94 | };
95 | Survicate.invokeEvent("eventName", properties);
96 | Survicate.enterScreen("screenName");
97 | Survicate.leaveScreen("screenName");
98 | const userIdTrait = new UserTrait('user_id', 'id');
99 | Survicate.setUserTrait(userIdTrait);
100 | const textTrait = new UserTrait('name', 'John');
101 | const numberTrait = new UserTrait('age', 25);
102 | const booleanTrait = new UserTrait('isPremium', true);
103 | const dateTrait = new UserTrait('lastLogin', new Date());
104 | const timeIntervalTrait = new UserTrait('timeOfPurchase', new Date());
105 | Survicate.setLocale('en-US');
106 | const listener: SurvicateEventListener = {
107 | onSurveyDisplayed(event: SurveyDisplayedEvent) {},
108 | onQuestionAnswered(event: QuestionAnsweredEvent) {},
109 | onSurveyClosed(event: SurveyClosedEvent) {},
110 | onSurveyCompleted(event: SurveyCompletedEvent) {},
111 | }
112 | const subscription = Survicate.addSurvicateEventListener(listener);
113 | Survicate.reset();
114 | ```
115 |
116 | ## Issues
117 |
118 | Got an Issue?
119 |
120 | To make things more streamlined, we’ve transitioned our issue reporting to our customer support platform. If you encounter any bugs or have feedback, please reach out to our customer support team. Your insights are invaluable to us, and we’re here to help ensure your experience is top-notch!
121 |
122 | Contact us via Intercom in the application, or drop us an email at: [hello@survicate.com]
123 |
124 | Thank you for your support and understanding!
125 |
126 | ## Changelog
127 |
128 | The Survicate Mobile SDK change log can be found [here](https://developers.survicate.com/mobile-sdk/react-native/#changelog)
129 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | // android/build.gradle
2 |
3 | // based on:
4 | //
5 | // * https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle
6 | // original location:
7 | // - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/build.gradle
8 | //
9 | // * https://github.com/facebook/react-native/blob/0.60-stable/template/android/app/build.gradle
10 | // original location:
11 | // - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle
12 |
13 | def DEFAULT_COMPILE_SDK_VERSION = 31
14 | def DEFAULT_BUILD_TOOLS_VERSION = '31.0.0'
15 | def DEFAULT_MIN_SDK_VERSION = 21
16 | def DEFAULT_TARGET_SDK_VERSION = 31
17 |
18 | def safeExtGet(prop, fallback) {
19 | rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
20 | }
21 |
22 | def isNewArchitectureEnabled() {
23 | return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
24 | }
25 |
26 | buildscript {
27 | // The Android Gradle plugin is only required when opening the android folder stand-alone.
28 | // This avoids unnecessary downloads and potential conflicts when the library is included as a
29 | // module dependency in an application project.
30 | // ref: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies
31 | if (project == rootProject) {
32 | repositories {
33 | google()
34 | gradlePluginPortal()
35 | jcenter()
36 | }
37 | dependencies {
38 | classpath 'com.android.tools.build:gradle:7.0.4'
39 | }
40 | }
41 | }
42 |
43 | apply plugin: 'com.android.library'
44 | apply plugin: "maven-publish"
45 | if (isNewArchitectureEnabled()) {
46 | apply plugin: 'com.facebook.react'
47 | }
48 |
49 | def supportsNamespace() {
50 | def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
51 | def major = parsed[0].toInteger()
52 | def minor = parsed[1].toInteger()
53 |
54 | // Namespace support was added in 7.3.0
55 | if (major == 7 && minor >= 3) {
56 | return true
57 | }
58 |
59 | return major >= 8
60 | }
61 |
62 | android {
63 | if (supportsNamespace()) {
64 | namespace "com.survicate.react"
65 |
66 | sourceSets {
67 | main {
68 | manifest.srcFile "src/main/AndroidManifestNew.xml"
69 | }
70 | }
71 | }
72 | compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
73 | buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
74 | defaultConfig {
75 | minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
76 | targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
77 | versionCode 1
78 | versionName "1.0"
79 | buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
80 | }
81 | buildFeatures {
82 | buildConfig true
83 | }
84 | lintOptions {
85 | abortOnError false
86 | }
87 | sourceSets {
88 | main {
89 | if (isNewArchitectureEnabled()) {
90 | java.srcDirs += ['src/newarch',
91 | // This is needed to build Kotlin project with NewArch enabled
92 | "${project.buildDir}/generated/source/codegen/java"]
93 | } else {
94 | java.srcDirs += ['src/oldarch']
95 | }
96 | }
97 | }
98 | }
99 |
100 | repositories {
101 | maven {
102 | // custom Survicate maven
103 | url "https://repo.survicate.com"
104 | }
105 | // ref: https://www.baeldung.com/maven-local-repository
106 | mavenLocal()
107 | maven {
108 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
109 | url "$rootDir/../node_modules/react-native/android"
110 | }
111 | maven {
112 | // Android JSC is installed from npm
113 | url "$rootDir/../node_modules/jsc-android/dist"
114 | }
115 | mavenCentral()
116 | google()
117 | jcenter()
118 | }
119 |
120 | dependencies {
121 | //noinspection GradleDynamicVersion
122 | implementation 'com.facebook.react:react-native:+' // From node_modules
123 | implementation ('com.survicate:survicate-sdk:6.3.0')
124 | }
125 |
126 | if (isNewArchitectureEnabled()) {
127 | react {
128 | jsRootDir = file("../")
129 | libraryName = "Survicate"
130 | codegenJavaPackageName = "com.survicate.react"
131 | }
132 | }
133 |
--------------------------------------------------------------------------------
/android/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 |
20 | android.useAndroidX=true
21 | android.enableJetifier=true
22 |
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Survicate/survicate-react-native-sdk/a1c216139fbf88cbf4b2bb3d2006593485cad484/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
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
6 |
--------------------------------------------------------------------------------
/android/gradlew:
--------------------------------------------------------------------------------
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" "$@"
241 |
--------------------------------------------------------------------------------
/android/gradlew.bat:
--------------------------------------------------------------------------------
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
92 |
--------------------------------------------------------------------------------
/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/android/src/main/AndroidManifestNew.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/android/src/main/java/com/survicate/react/SurvicateModuleImpl.java:
--------------------------------------------------------------------------------
1 | package com.survicate.react;
2 |
3 | import com.facebook.react.bridge.ReactApplicationContext;
4 | import com.facebook.react.bridge.ReactMethod;
5 | import com.facebook.react.bridge.ReadableMap;
6 | import com.survicate.surveys.Survicate;
7 | import com.survicate.surveys.traits.UserTrait;
8 |
9 | import com.survicate.react.SurvicateModule;
10 |
11 | import java.util.Map;
12 | import java.util.HashMap;
13 |
14 | public class SurvicateModuleImpl extends SurvicateModule {
15 |
16 | public static final String NAME = "SurvicateBindings";
17 |
18 | private final ReactApplicationContext reactContext;
19 | private final SurvicateRNEventListener eventListener;
20 |
21 | private int listenerCount = 0;
22 | private boolean isInitialized = false;
23 |
24 | public SurvicateModuleImpl(ReactApplicationContext reactContext) {
25 | super(reactContext);
26 | this.reactContext = reactContext;
27 | this.eventListener = new SurvicateRNEventListener(reactContext);
28 | }
29 |
30 | @Override
31 | public String getName() {
32 | return NAME;
33 | }
34 |
35 | @ReactMethod
36 | public void enterScreen(String screenName) {
37 | if (!isInitialized) {
38 | return;
39 | }
40 | Survicate.enterScreen(screenName);
41 | }
42 |
43 | @ReactMethod
44 | public void leaveScreen(String screenName) {
45 | if (!isInitialized) {
46 | return;
47 | }
48 | Survicate.leaveScreen(screenName);
49 | }
50 |
51 | @ReactMethod
52 | public void invokeEvent(String eventName, ReadableMap eventProperties) {
53 | if (!isInitialized) {
54 | return;
55 | }
56 | Map properties = new HashMap<>();
57 | for (Map.Entry entry : eventProperties.toHashMap().entrySet()) {
58 | String key = entry.getKey();
59 | String value = entry.getValue().toString();
60 | properties.put(key, value);
61 | }
62 |
63 | Survicate.invokeEvent(eventName, properties);
64 | }
65 |
66 | @ReactMethod
67 | public void setUserId(String userId) {
68 | if (!isInitialized) {
69 | return;
70 | }
71 |
72 | Survicate.setUserTrait(new UserTrait("user_id", userId));
73 | }
74 |
75 | @ReactMethod
76 | public void setUserTrait(String userTrait, String value) {
77 | if (!isInitialized) {
78 | return;
79 | }
80 | Survicate.setUserTrait(new UserTrait(userTrait, value));
81 | }
82 |
83 | @ReactMethod
84 | public void initializeSdk() {
85 | Survicate.init(reactContext);
86 | isInitialized = true;
87 | }
88 |
89 | @ReactMethod
90 | public void reset() {
91 | if (!isInitialized) {
92 | return;
93 | }
94 | Survicate.reset();
95 | }
96 |
97 | @ReactMethod
98 | public void setWorkspaceKey(String workspaceKey) {
99 | Survicate.setWorkspaceKey(workspaceKey);
100 | }
101 |
102 | @ReactMethod
103 | public void addListener(String eventName) {
104 | if (!isInitialized) {
105 | return;
106 | }
107 | if (listenerCount == 0) {
108 | Survicate.addEventListener(eventListener);
109 | }
110 |
111 | listenerCount++;
112 | }
113 |
114 | @ReactMethod
115 | public void removeListeners(int count) {
116 | if (!isInitialized) {
117 | return;
118 | }
119 | listenerCount -= count;
120 |
121 | if (listenerCount == 0) {
122 | Survicate.removeEventListener(eventListener);
123 | }
124 | }
125 |
126 | @ReactMethod
127 | public void removeListeners(double count) {
128 | removeListeners((int) count);
129 | }
130 |
131 | @ReactMethod
132 | public void setLocale(String locale) {
133 | if (!isInitialized) {
134 | return;
135 | }
136 | Survicate.setLocale(locale);
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/android/src/main/java/com/survicate/react/SurvicatePackage.java:
--------------------------------------------------------------------------------
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 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 | }
47 |
--------------------------------------------------------------------------------
/android/src/main/java/com/survicate/react/SurvicateRNEventListener.java:
--------------------------------------------------------------------------------
1 | package com.survicate.react;
2 |
3 | import androidx.annotation.NonNull;
4 |
5 | import com.facebook.react.bridge.Arguments;
6 | import com.facebook.react.bridge.ReactApplicationContext;
7 | import com.facebook.react.bridge.ReactContext;
8 | import com.facebook.react.bridge.WritableMap;
9 | import com.facebook.react.bridge.WritableArray;
10 | import com.facebook.react.modules.core.DeviceEventManagerModule;
11 | import com.survicate.surveys.SurvicateAnswer;
12 | import com.survicate.surveys.SurvicateEventListener;
13 | import com.survicate.surveys.SurveyDisplayedEvent;
14 | import com.survicate.surveys.QuestionAnsweredEvent;
15 | import com.survicate.surveys.SurveyClosedEvent;
16 | import com.survicate.surveys.SurveyCompletedEvent;
17 |
18 | import javax.annotation.Nullable;
19 |
20 | class SurvicateRNEventListener extends SurvicateEventListener {
21 |
22 | private static final String SURVEY_ID = "surveyId";
23 | private static final String SURVEY_NAME = "surveyName";
24 | private static final String RESPONSE_UUID = "responseUuid";
25 | private static final String VISITOR_UUID = "visitorUuid";
26 | private static final String QUESTION_ID = "questionId";
27 | private static final String QUESTION = "question";
28 | private static final String ANSWER_TYPE = "answerType";
29 | private static final String ANSWER_ID = "answerId";
30 | private static final String ANSWER_IDS = "answerIds";
31 | private static final String ANSWER_VALUE = "answerValue";
32 | private static final String PANEL_ANSWER_URL = "panelAnswerUrl";
33 |
34 | private ReactApplicationContext reactContext;
35 |
36 | public SurvicateRNEventListener(ReactApplicationContext reactContext) {
37 | this.reactContext = reactContext;
38 | }
39 |
40 | @Override
41 | public void onSurveyDisplayed(@NonNull SurveyDisplayedEvent event) {
42 | WritableMap params = Arguments.createMap();
43 | params.putString(SURVEY_ID, event.getSurveyId());
44 | sendEvent(reactContext, "onSurveyDisplayed", params);
45 | }
46 |
47 | @Override
48 | public void onQuestionAnswered(@NonNull QuestionAnsweredEvent event) {
49 | WritableMap params = Arguments.createMap();
50 | params.putString(SURVEY_ID, event.getSurveyId());
51 | params.putString(SURVEY_NAME, event.getSurveyName());
52 | params.putString(RESPONSE_UUID, event.getResponseUuid());
53 | params.putString(VISITOR_UUID, event.getVisitorUuid());
54 | params.putString(PANEL_ANSWER_URL, event.getPanelAnswerUrl());
55 | params.putDouble(QUESTION_ID, event.getQuestionId());
56 | params.putString(QUESTION, event.getQuestionText());
57 |
58 | if (event.getAnswer().getType() != null) {
59 | params.putString(ANSWER_TYPE, event.getAnswer().getType());
60 | } else {
61 | params.putNull(ANSWER_TYPE);
62 | }
63 |
64 | if (event.getAnswer().getId() != null) {
65 | params.putDouble(ANSWER_ID, event.getAnswer().getId());
66 | } else {
67 | params.putNull(ANSWER_ID);
68 | }
69 |
70 | if (event.getAnswer().getIds() != null) {
71 | WritableArray ids = Arguments.createArray();
72 | for (long id : event.getAnswer().getIds()) {
73 | ids.pushDouble(id);
74 | }
75 | params.putArray(ANSWER_IDS, ids);
76 | } else {
77 | params.putArray(ANSWER_IDS, Arguments.createArray());
78 | }
79 |
80 | if (event.getAnswer().getValue() != null) {
81 | params.putString(ANSWER_VALUE, event.getAnswer().getValue());
82 | } else {
83 | params.putNull(ANSWER_VALUE);
84 | }
85 |
86 | sendEvent(reactContext, "onQuestionAnswered", params);
87 | }
88 |
89 | @Override
90 | public void onSurveyClosed(@NonNull SurveyClosedEvent event) {
91 | WritableMap params = Arguments.createMap();
92 | params.putString(SURVEY_ID, event.getSurveyId());
93 | sendEvent(reactContext, "onSurveyClosed", params);
94 | }
95 |
96 | @Override
97 | public void onSurveyCompleted(@NonNull SurveyCompletedEvent event) {
98 | WritableMap params = Arguments.createMap();
99 | params.putString(SURVEY_ID, event.getSurveyId());
100 | sendEvent(reactContext, "onSurveyCompleted", params);
101 | }
102 |
103 | private void sendEvent(ReactContext reactContext, String eventName, @Nullable WritableMap params) {
104 | reactContext
105 | .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
106 | .emit(eventName, params);
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/android/src/newarch/java/com/survicate/react/SurvicateModule.java:
--------------------------------------------------------------------------------
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 | }
12 |
--------------------------------------------------------------------------------
/android/src/oldarch/java/com/survicate/react/SurvicateModule.java:
--------------------------------------------------------------------------------
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 | import com.facebook.react.bridge.ReadableMap;
8 |
9 | public abstract class SurvicateModule extends ReactContextBaseJavaModule {
10 |
11 | public SurvicateModule(@NonNull ReactApplicationContext reactContext) {
12 | super(reactContext);
13 | }
14 |
15 | public abstract void enterScreen(String screenName);
16 | public abstract void leaveScreen(String screenName);
17 | public abstract void invokeEvent(String eventName, ReadableMap eventProperties);
18 | public abstract void setUserId(String userId);
19 | public abstract void setUserTrait(String userTrait, String value);
20 | public abstract void initializeSdk();
21 | public abstract void reset();
22 | public abstract void setWorkspaceKey(String workspaceKey);
23 | public abstract void setLocale(String locale);
24 | }
25 |
--------------------------------------------------------------------------------
/app.plugin.js:
--------------------------------------------------------------------------------
1 | const packageJson = require('./package.json');
2 |
3 | const pkg = {
4 | name: packageJson.name,
5 | version: packageJson.version,
6 | };
7 |
8 | const plugin = require('./lib/commonjs/expo/withSurvicate');
9 |
10 | module.exports = plugin.default(pkg);
11 |
--------------------------------------------------------------------------------
/example/react_native/.gitignore:
--------------------------------------------------------------------------------
1 | # OSX
2 | #
3 | .DS_Store
4 |
5 | # Xcode
6 | #
7 | build/
8 | *.pbxuser
9 | !default.pbxuser
10 | *.mode1v3
11 | !default.mode1v3
12 | *.mode2v3
13 | !default.mode2v3
14 | *.perspectivev3
15 | !default.perspectivev3
16 | xcuserdata
17 | *.xccheckout
18 | *.moved-aside
19 | DerivedData
20 | *.hmap
21 | *.ipa
22 | *.xcuserstate
23 | *.xcode.env.local
24 |
25 | # Android/IntelliJ
26 | #
27 | build/
28 | .idea
29 | .gradle
30 | local.properties
31 | *.iml
32 | *.hprof
33 | .cxx/
34 | *.keystore
35 | !debug.keystore
36 |
37 | # node.js
38 | #
39 | node_modules/
40 | npm-debug.log
41 | yarn-error.log
42 |
43 | # Bundle artifact
44 | *.jsbundle
45 |
46 | # Ruby / CocoaPods
47 | /ios/Pods/
48 | /vendor/bundle/
49 |
50 | # Temporary files created by Metro to check the health of the file watcher
51 | .metro-health-check*
52 |
53 | *.xcarchive
--------------------------------------------------------------------------------
/example/react_native/App.tsx:
--------------------------------------------------------------------------------
1 | import React, { useEffect } from "react";
2 | import { Button, Text, SafeAreaView, ScrollView, StyleSheet, View } from "react-native";
3 | import Survicate, {SurveyDisplayedEvent, QuestionAnsweredEvent, SurveyClosedEvent, SurveyCompletedEvent, UserTrait} from "@survicate/react-native-survicate";
4 |
5 | const App = () => {
6 | useEffect(() => {
7 | // Initialize the SDK
8 | Survicate.initializeSdk();
9 |
10 | const listener = {
11 | onSurveyDisplayed: (event: SurveyDisplayedEvent) => {
12 | // onSurveyDisplayed
13 | },
14 | onQuestionAnswered: (event: QuestionAnsweredEvent) => {
15 | // onQuestionAnswered
16 | },
17 | onSurveyClosed: (event: SurveyClosedEvent) => {
18 | // onSurveyClosed
19 | },
20 | onSurveyCompleted: (event: SurveyCompletedEvent) => {
21 | // onSurveyCompleted
22 | },
23 | };
24 |
25 | const subscription = Survicate.addSurvicateEventListener(listener);
26 | return subscription;
27 | }, []);
28 |
29 | return (
30 |
31 |
32 |
33 | Example App
34 |
35 |
36 |
37 |
44 |
45 |
46 |
53 |
54 |
55 |
62 |
63 |
64 |
75 |
76 |
77 |
85 |
86 |
87 |
94 |
95 |
96 | );
97 | };
98 |
99 | const styles = StyleSheet.create({
100 | safeArea: {
101 | flex: 1,
102 | },
103 | scrollView: {
104 | padding: 20,
105 | },
106 | title: {
107 | fontSize: 20,
108 | marginBottom: 20,
109 | },
110 | buttonContainer: {
111 | marginBottom: 10,
112 | },
113 | });
114 |
115 | export default App;
116 |
--------------------------------------------------------------------------------
/example/react_native/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 |
3 | # You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4 | ruby ">= 2.6.10"
5 |
6 | # Exclude problematic versions of cocoapods and activesupport that causes build failures.
7 | gem 'cocoapods', '>= 1.13', '!= 1.15.0', '!= 1.15.1'
8 | gem 'activesupport', '>= 6.1.7.5', '!= 7.1.0'
9 |
--------------------------------------------------------------------------------
/example/react_native/README.md:
--------------------------------------------------------------------------------
1 | This is a new [**React Native**](https://reactnative.dev) project, bootstrapped using [`@react-native-community/cli`](https://github.com/react-native-community/cli).
2 |
3 | # Getting Started
4 |
5 | >**Note**: Make sure you have completed the [React Native - Environment Setup](https://reactnative.dev/docs/environment-setup) instructions till "Creating a new application" step, before proceeding.
6 |
7 | ## Step 1: Start the Metro Server
8 |
9 | First, you will need to start **Metro**, the JavaScript _bundler_ that ships _with_ React Native.
10 |
11 | To start Metro, run the following command from the _root_ of your React Native project:
12 |
13 | ```bash
14 | # using npm
15 | npm start
16 |
17 | # OR using Yarn
18 | yarn start
19 | ```
20 |
21 | ## Step 2: Start your Application
22 |
23 | Let Metro Bundler run in its _own_ terminal. Open a _new_ terminal from the _root_ of your React Native project. Run the following command to start your _Android_ or _iOS_ app:
24 |
25 | ### For Android
26 |
27 | ```bash
28 | # using npm
29 | npm run android
30 |
31 | # OR using Yarn
32 | yarn android
33 | ```
34 |
35 | ### For iOS
36 |
37 | ```bash
38 | # using npm
39 | npm run ios
40 |
41 | # OR using Yarn
42 | yarn ios
43 | ```
44 |
45 | If everything is set up _correctly_, you should see your new app running in your _Android Emulator_ or _iOS Simulator_ shortly provided you have set up your emulator/simulator correctly.
46 |
47 | This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively.
48 |
49 | ## Step 3: Modifying your App
50 |
51 | Now that you have successfully run the app, let's modify it.
52 |
53 | 1. Open `App.tsx` in your text editor of choice and edit some lines.
54 | 2. For **Android**: Press the R key twice or select **"Reload"** from the **Developer Menu** (Ctrl + M (on Window and Linux) or Cmd ⌘ + M (on macOS)) to see your changes!
55 |
56 | For **iOS**: Hit Cmd ⌘ + R in your iOS Simulator to reload the app and see your changes!
57 |
58 | ## Congratulations! :tada:
59 |
60 | You've successfully run and modified your React Native App. :partying_face:
61 |
62 | ### Now what?
63 |
64 | - If you want to add this new React Native code to an existing application, check out the [Integration guide](https://reactnative.dev/docs/integration-with-existing-apps).
65 | - If you're curious to learn more about React Native, check out the [Introduction to React Native](https://reactnative.dev/docs/getting-started).
66 |
67 | # Troubleshooting
68 |
69 | If you can't get this to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page.
70 |
71 | # Learn More
72 |
73 | To learn more about React Native, take a look at the following resources:
74 |
75 | - [React Native Website](https://reactnative.dev) - learn more about React Native.
76 | - [Getting Started](https://reactnative.dev/docs/environment-setup) - an **overview** of React Native and how setup your environment.
77 | - [Learn the Basics](https://reactnative.dev/docs/getting-started) - a **guided tour** of the React Native **basics**.
78 | - [Blog](https://reactnative.dev/blog) - read the latest official React Native **Blog** posts.
79 | - [`@facebook/react-native`](https://github.com/facebook/react-native) - the Open Source; GitHub **repository** for React Native.
80 |
--------------------------------------------------------------------------------
/example/react_native/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: "com.android.application"
2 | apply plugin: "org.jetbrains.kotlin.android"
3 | apply plugin: "com.facebook.react"
4 |
5 | /**
6 | * This is the configuration block to customize your React Native Android app.
7 | * By default you don't need to apply any configuration, just uncomment the lines you need.
8 | */
9 | react {
10 | /* Folders */
11 | // The root of your project, i.e. where "package.json" lives. Default is '../..'
12 | // root = file("../../")
13 | // The folder where the react-native NPM package is. Default is ../../node_modules/react-native
14 | // reactNativeDir = file("../../node_modules/react-native")
15 | // The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen
16 | // codegenDir = file("../../node_modules/@react-native/codegen")
17 | // The cli.js file which is the React Native CLI entrypoint. Default is ../../node_modules/react-native/cli.js
18 | // cliFile = file("../../node_modules/react-native/cli.js")
19 |
20 | /* Variants */
21 | // The list of variants to that are debuggable. For those we're going to
22 | // skip the bundling of the JS bundle and the assets. By default is just 'debug'.
23 | // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
24 | // debuggableVariants = ["liteDebug", "prodDebug"]
25 |
26 | /* Bundling */
27 | // A list containing the node command and its flags. Default is just 'node'.
28 | // nodeExecutableAndArgs = ["node"]
29 | //
30 | // The command to run when bundling. By default is 'bundle'
31 | // bundleCommand = "ram-bundle"
32 | //
33 | // The path to the CLI configuration file. Default is empty.
34 | // bundleConfig = file(../rn-cli.config.js)
35 | //
36 | // The name of the generated asset file containing your JS bundle
37 | // bundleAssetName = "MyApplication.android.bundle"
38 | //
39 | // The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
40 | // entryFile = file("../js/MyApplication.android.js")
41 | //
42 | // A list of extra flags to pass to the 'bundle' commands.
43 | // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
44 | // extraPackagerArgs = []
45 |
46 | /* Hermes Commands */
47 | // The hermes compiler command to run. By default it is 'hermesc'
48 | // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
49 | //
50 | // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
51 | // hermesFlags = ["-O", "-output-source-map"]
52 |
53 | /* Autolinking */
54 | autolinkLibrariesWithApp()
55 | }
56 |
57 | /**
58 | * Set this to true to Run Proguard on Release builds to minify the Java bytecode.
59 | */
60 | def enableProguardInReleaseBuilds = false
61 |
62 | /**
63 | * The preferred build flavor of JavaScriptCore (JSC)
64 | *
65 | * For example, to use the international variant, you can use:
66 | * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
67 | *
68 | * The international variant includes ICU i18n library and necessary data
69 | * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
70 | * give correct results when using with locales other than en-US. Note that
71 | * this variant is about 6MiB larger per architecture than default.
72 | */
73 | def jscFlavor = 'org.webkit:android-jsc:+'
74 |
75 | android {
76 | ndkVersion rootProject.ext.ndkVersion
77 | buildToolsVersion rootProject.ext.buildToolsVersion
78 | compileSdk rootProject.ext.compileSdkVersion
79 |
80 | namespace "com.react_native"
81 | defaultConfig {
82 | applicationId "com.react_native"
83 | minSdkVersion rootProject.ext.minSdkVersion
84 | targetSdkVersion rootProject.ext.targetSdkVersion
85 | versionCode 1
86 | versionName "1.0"
87 | }
88 | signingConfigs {
89 | debug {
90 | storeFile file('debug.keystore')
91 | storePassword 'android'
92 | keyAlias 'androiddebugkey'
93 | keyPassword 'android'
94 | }
95 | }
96 | buildTypes {
97 | debug {
98 | signingConfig signingConfigs.debug
99 | }
100 | release {
101 | // Caution! In production, you need to generate your own keystore file.
102 | // see https://reactnative.dev/docs/signed-apk-android.
103 | signingConfig signingConfigs.debug
104 | minifyEnabled enableProguardInReleaseBuilds
105 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
106 | }
107 | }
108 | }
109 |
110 | dependencies {
111 | // The version of react-native is set by the React Native Gradle Plugin
112 | implementation("com.facebook.react:react-android")
113 |
114 | if (hermesEnabled.toBoolean()) {
115 | implementation("com.facebook.react:hermes-android")
116 | } else {
117 | implementation jscFlavor
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/example/react_native/android/app/debug.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Survicate/survicate-react-native-sdk/a1c216139fbf88cbf4b2bb3d2006593485cad484/example/react_native/android/app/debug.keystore
--------------------------------------------------------------------------------
/example/react_native/android/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
--------------------------------------------------------------------------------
/example/react_native/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
9 |
10 |
--------------------------------------------------------------------------------
/example/react_native/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
13 |
20 |
21 |
22 |
23 |
24 |
25 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/example/react_native/android/app/src/main/java/com/react_native/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.react_native
2 |
3 | import com.facebook.react.ReactActivity
4 | import com.facebook.react.ReactActivityDelegate
5 | import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
6 | import com.facebook.react.defaults.DefaultReactActivityDelegate
7 |
8 | class MainActivity : ReactActivity() {
9 |
10 | /**
11 | * Returns the name of the main component registered from JavaScript. This is used to schedule
12 | * rendering of the component.
13 | */
14 | override fun getMainComponentName(): String = "react_native"
15 |
16 | /**
17 | * Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
18 | * which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
19 | */
20 | override fun createReactActivityDelegate(): ReactActivityDelegate =
21 | DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
22 | }
23 |
--------------------------------------------------------------------------------
/example/react_native/android/app/src/main/java/com/react_native/MainApplication.kt:
--------------------------------------------------------------------------------
1 | package com.react_native
2 |
3 | import android.app.Application
4 | import com.facebook.react.PackageList
5 | import com.facebook.react.ReactApplication
6 | import com.facebook.react.ReactHost
7 | import com.facebook.react.ReactNativeHost
8 | import com.facebook.react.ReactPackage
9 | import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
10 | import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
11 | import com.facebook.react.defaults.DefaultReactNativeHost
12 | import com.facebook.soloader.SoLoader
13 |
14 | class MainApplication : Application(), ReactApplication {
15 |
16 | override val reactNativeHost: ReactNativeHost =
17 | object : DefaultReactNativeHost(this) {
18 | override fun getPackages(): List =
19 | PackageList(this).packages.apply {
20 | // Packages that cannot be autolinked yet can be added manually here, for example:
21 | // add(MyReactNativePackage())
22 | }
23 |
24 | override fun getJSMainModuleName(): String = "index"
25 |
26 | override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
27 |
28 | override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
29 | override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
30 | }
31 |
32 | override val reactHost: ReactHost
33 | get() = getDefaultReactHost(applicationContext, reactNativeHost)
34 |
35 | override fun onCreate() {
36 | super.onCreate()
37 | SoLoader.init(this, false)
38 | if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
39 | // If you opted-in for the New Architecture, we load the native entry point for this app.
40 | load()
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/example/react_native/android/app/src/main/res/drawable/rn_edit_text_material.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
22 |
23 |
24 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/example/react_native/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Survicate/survicate-react-native-sdk/a1c216139fbf88cbf4b2bb3d2006593485cad484/example/react_native/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/react_native/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Survicate/survicate-react-native-sdk/a1c216139fbf88cbf4b2bb3d2006593485cad484/example/react_native/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/react_native/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Survicate/survicate-react-native-sdk/a1c216139fbf88cbf4b2bb3d2006593485cad484/example/react_native/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/react_native/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Survicate/survicate-react-native-sdk/a1c216139fbf88cbf4b2bb3d2006593485cad484/example/react_native/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/react_native/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Survicate/survicate-react-native-sdk/a1c216139fbf88cbf4b2bb3d2006593485cad484/example/react_native/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/react_native/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Survicate/survicate-react-native-sdk/a1c216139fbf88cbf4b2bb3d2006593485cad484/example/react_native/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/react_native/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Survicate/survicate-react-native-sdk/a1c216139fbf88cbf4b2bb3d2006593485cad484/example/react_native/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/react_native/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Survicate/survicate-react-native-sdk/a1c216139fbf88cbf4b2bb3d2006593485cad484/example/react_native/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/react_native/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Survicate/survicate-react-native-sdk/a1c216139fbf88cbf4b2bb3d2006593485cad484/example/react_native/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/react_native/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Survicate/survicate-react-native-sdk/a1c216139fbf88cbf4b2bb3d2006593485cad484/example/react_native/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/react_native/android/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | react_native
3 |
4 |
--------------------------------------------------------------------------------
/example/react_native/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/example/react_native/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext {
3 | buildToolsVersion = "34.0.0"
4 | minSdkVersion = 23
5 | compileSdkVersion = 34
6 | targetSdkVersion = 34
7 | ndkVersion = "26.1.10909125"
8 | kotlinVersion = "1.9.24"
9 | }
10 | repositories {
11 | google()
12 | mavenCentral()
13 | }
14 | dependencies {
15 | classpath("com.android.tools.build:gradle")
16 | classpath("com.facebook.react:react-native-gradle-plugin")
17 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
18 | }
19 | }
20 |
21 | allprojects {
22 | repositories {
23 | maven {url "https://repo.survicate.com"}
24 | }
25 | }
26 |
27 | apply plugin: "com.facebook.react.rootproject"
28 |
--------------------------------------------------------------------------------
/example/react_native/android/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx512m -XX:MaxMetaspaceSize=256m
13 | org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 |
20 | # AndroidX package structure to make it clearer which packages are bundled with the
21 | # Android operating system, and which are packaged with your app's APK
22 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
23 | android.useAndroidX=true
24 |
25 | # Use this property to specify which architecture you want to build.
26 | # You can also override it from the CLI using
27 | # ./gradlew -PreactNativeArchitectures=x86_64
28 | reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
29 |
30 | # Use this property to enable support to the new architecture.
31 | # This will allow you to use TurboModules and the Fabric render in
32 | # your application. You should enable this flag either if you want
33 | # to write custom TurboModules/Fabric components OR use libraries that
34 | # are providing them.
35 | newArchEnabled=false
36 |
37 | # Use this property to enable or disable the Hermes JS engine.
38 | # If set to false, you will be using JSC instead.
39 | hermesEnabled=true
40 |
--------------------------------------------------------------------------------
/example/react_native/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Survicate/survicate-react-native-sdk/a1c216139fbf88cbf4b2bb3d2006593485cad484/example/react_native/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/example/react_native/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/example/react_native/android/gradlew:
--------------------------------------------------------------------------------
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/HEAD/platforms/jvm/plugins-application/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 | # This is normally unused
84 | # shellcheck disable=SC2034
85 | APP_BASE_NAME=${0##*/}
86 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87 | APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
88 |
89 | # Use the maximum available, or set MAX_FD != -1 to use that value.
90 | MAX_FD=maximum
91 |
92 | warn () {
93 | echo "$*"
94 | } >&2
95 |
96 | die () {
97 | echo
98 | echo "$*"
99 | echo
100 | exit 1
101 | } >&2
102 |
103 | # OS specific support (must be 'true' or 'false').
104 | cygwin=false
105 | msys=false
106 | darwin=false
107 | nonstop=false
108 | case "$( uname )" in #(
109 | CYGWIN* ) cygwin=true ;; #(
110 | Darwin* ) darwin=true ;; #(
111 | MSYS* | MINGW* ) msys=true ;; #(
112 | NONSTOP* ) nonstop=true ;;
113 | esac
114 |
115 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
116 |
117 |
118 | # Determine the Java command to use to start the JVM.
119 | if [ -n "$JAVA_HOME" ] ; then
120 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
121 | # IBM's JDK on AIX uses strange locations for the executables
122 | JAVACMD=$JAVA_HOME/jre/sh/java
123 | else
124 | JAVACMD=$JAVA_HOME/bin/java
125 | fi
126 | if [ ! -x "$JAVACMD" ] ; then
127 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
128 |
129 | Please set the JAVA_HOME variable in your environment to match the
130 | location of your Java installation."
131 | fi
132 | else
133 | JAVACMD=java
134 | if ! command -v java >/dev/null 2>&1
135 | then
136 | 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 | fi
142 |
143 | # Increase the maximum file descriptors if we can.
144 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
145 | case $MAX_FD in #(
146 | max*)
147 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
148 | # shellcheck disable=SC2039,SC3045
149 | MAX_FD=$( ulimit -H -n ) ||
150 | warn "Could not query maximum file descriptor limit"
151 | esac
152 | case $MAX_FD in #(
153 | '' | soft) :;; #(
154 | *)
155 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
156 | # shellcheck disable=SC2039,SC3045
157 | ulimit -n "$MAX_FD" ||
158 | warn "Could not set maximum file descriptor limit to $MAX_FD"
159 | esac
160 | fi
161 |
162 | # Collect all arguments for the java command, stacking in reverse order:
163 | # * args from the command line
164 | # * the main class name
165 | # * -classpath
166 | # * -D...appname settings
167 | # * --module-path (only if needed)
168 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
169 |
170 | # For Cygwin or MSYS, switch paths to Windows format before running java
171 | if "$cygwin" || "$msys" ; then
172 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
173 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
174 |
175 | JAVACMD=$( cygpath --unix "$JAVACMD" )
176 |
177 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
178 | for arg do
179 | if
180 | case $arg in #(
181 | -*) false ;; # don't mess with options #(
182 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
183 | [ -e "$t" ] ;; #(
184 | *) false ;;
185 | esac
186 | then
187 | arg=$( cygpath --path --ignore --mixed "$arg" )
188 | fi
189 | # Roll the args list around exactly as many times as the number of
190 | # args, so each arg winds up back in the position where it started, but
191 | # possibly modified.
192 | #
193 | # NB: a `for` loop captures its iteration list before it begins, so
194 | # changing the positional parameters here affects neither the number of
195 | # iterations, nor the values presented in `arg`.
196 | shift # remove old arg
197 | set -- "$@" "$arg" # push replacement arg
198 | done
199 | fi
200 |
201 |
202 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
203 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204 |
205 | # Collect all arguments for the java command:
206 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
207 | # and any embedded shellness will be escaped.
208 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209 | # treated as '${Hostname}' itself on the command line.
210 |
211 | set -- \
212 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
213 | -classpath "$CLASSPATH" \
214 | org.gradle.wrapper.GradleWrapperMain \
215 | "$@"
216 |
217 | # Stop when "xargs" is not available.
218 | if ! command -v xargs >/dev/null 2>&1
219 | then
220 | die "xargs is not available"
221 | fi
222 |
223 | # Use "xargs" to parse quoted args.
224 | #
225 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
226 | #
227 | # In Bash we could simply go:
228 | #
229 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
230 | # set -- "${ARGS[@]}" "$@"
231 | #
232 | # but POSIX shell has neither arrays nor command substitution, so instead we
233 | # post-process each arg (as a line of input to sed) to backslash-escape any
234 | # character that might be a shell metacharacter, then use eval to reverse
235 | # that process (while maintaining the separation between arguments), and wrap
236 | # the whole thing up as a single "set" statement.
237 | #
238 | # This will of course break if any of these variables contains a newline or
239 | # an unmatched quote.
240 | #
241 |
242 | eval "set -- $(
243 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
244 | xargs -n1 |
245 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
246 | tr '\n' ' '
247 | )" '"$@"'
248 |
249 | exec "$JAVACMD" "$@"
250 |
--------------------------------------------------------------------------------
/example/react_native/android/gradlew.bat:
--------------------------------------------------------------------------------
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 | @rem This is normally unused
30 | set APP_BASE_NAME=%~n0
31 | set APP_HOME=%DIRNAME%
32 |
33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
35 |
36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
38 |
39 | @rem Find java.exe
40 | if defined JAVA_HOME goto findJavaFromJavaHome
41 |
42 | set JAVA_EXE=java.exe
43 | %JAVA_EXE% -version >NUL 2>&1
44 | if %ERRORLEVEL% equ 0 goto execute
45 |
46 | echo. 1>&2
47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
48 | echo. 1>&2
49 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
50 | echo location of your Java installation. 1>&2
51 |
52 | goto fail
53 |
54 | :findJavaFromJavaHome
55 | set JAVA_HOME=%JAVA_HOME:"=%
56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
57 |
58 | if exist "%JAVA_EXE%" goto execute
59 |
60 | echo. 1>&2
61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
62 | echo. 1>&2
63 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
64 | echo location of your Java installation. 1>&2
65 |
66 | goto fail
67 |
68 | :execute
69 | @rem Setup the command line
70 |
71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
72 |
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if %ERRORLEVEL% equ 0 goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | set EXIT_CODE=%ERRORLEVEL%
85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
87 | exit /b %EXIT_CODE%
88 |
89 | :mainEnd
90 | if "%OS%"=="Windows_NT" endlocal
91 |
92 | :omega
93 |
--------------------------------------------------------------------------------
/example/react_native/android/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement { includeBuild("../node_modules/@react-native/gradle-plugin") }
2 | plugins { id("com.facebook.react.settings") }
3 | extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() }
4 | rootProject.name = 'react_native'
5 | include ':app'
6 | includeBuild('../node_modules/@react-native/gradle-plugin')
7 |
--------------------------------------------------------------------------------
/example/react_native/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react_native",
3 | "displayName": "react_native"
4 | }
5 |
--------------------------------------------------------------------------------
/example/react_native/babel.config.js:
--------------------------------------------------------------------------------
1 | const path = require("path");
2 | const { getConfig } = require("react-native-builder-bob/babel-config");
3 | const pkg = require("../../package.json");
4 |
5 | const root = path.resolve(__dirname, "../..");
6 |
7 | module.exports = getConfig(
8 | {
9 | presets: ["module:@react-native/babel-preset"]
10 | },
11 | { root, pkg }
12 | );
13 |
--------------------------------------------------------------------------------
/example/react_native/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @format
3 | */
4 |
5 | import {AppRegistry} from 'react-native';
6 | import App from './App';
7 | import {name as appName} from './app.json';
8 |
9 | AppRegistry.registerComponent(appName, () => App);
10 |
--------------------------------------------------------------------------------
/example/react_native/ios/.xcode.env:
--------------------------------------------------------------------------------
1 | # This `.xcode.env` file is versioned and is used to source the environment
2 | # used when running script phases inside Xcode.
3 | # To customize your local environment, you can create an `.xcode.env.local`
4 | # file that is not versioned.
5 |
6 | # NODE_BINARY variable contains the PATH to the node executable.
7 | #
8 | # Customize the NODE_BINARY variable here.
9 | # For example, to use nvm with brew, add the following line
10 | # . "$(brew --prefix nvm)/nvm.sh" --no-use
11 | export NODE_BINARY=$(command -v node)
12 |
--------------------------------------------------------------------------------
/example/react_native/ios/Podfile:
--------------------------------------------------------------------------------
1 | # Resolve react_native_pods.rb with node to allow for hoisting
2 | require Pod::Executable.execute_command('node', ['-p',
3 | 'require.resolve(
4 | "react-native/scripts/react_native_pods.rb",
5 | {paths: [process.argv[1]]},
6 | )', __dir__]).strip
7 |
8 | platform :ios, min_ios_version_supported
9 | prepare_react_native_project!
10 |
11 | linkage = ENV['USE_FRAMEWORKS']
12 | if linkage != nil
13 | Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
14 | use_frameworks! :linkage => linkage.to_sym
15 | end
16 |
17 | target 'react_native' do
18 | config = use_native_modules!
19 |
20 | use_react_native!(
21 | :path => config[:reactNativePath],
22 | # An absolute path to your application root.
23 | :app_path => "#{Pod::Config.instance.installation_root}/.."
24 | )
25 |
26 | target 'react_nativeTests' do
27 | inherit! :complete
28 | # Pods for testing
29 | end
30 |
31 | post_install do |installer|
32 | # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
33 | react_native_post_install(
34 | installer,
35 | config[:reactNativePath],
36 | :mac_catalyst_enabled => false,
37 | # :ccache_enabled => true
38 | )
39 | end
40 | end
41 |
--------------------------------------------------------------------------------
/example/react_native/ios/react_native.xcodeproj/xcshareddata/xcschemes/react_native.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
53 |
55 |
61 |
62 |
63 |
64 |
70 |
72 |
78 |
79 |
80 |
81 |
83 |
84 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/example/react_native/ios/react_native.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/example/react_native/ios/react_native/AppDelegate.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | @interface AppDelegate : RCTAppDelegate
5 |
6 | @end
7 |
--------------------------------------------------------------------------------
/example/react_native/ios/react_native/AppDelegate.mm:
--------------------------------------------------------------------------------
1 | #import "AppDelegate.h"
2 |
3 | #import
4 |
5 | @implementation AppDelegate
6 |
7 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
8 | {
9 | self.moduleName = @"react_native";
10 | // You can add your custom initial props in the dictionary below.
11 | // They will be passed down to the ViewController used by React Native.
12 | self.initialProps = @{};
13 |
14 | return [super application:application didFinishLaunchingWithOptions:launchOptions];
15 | }
16 |
17 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
18 | {
19 | return [self bundleURL];
20 | }
21 |
22 | - (NSURL *)bundleURL
23 | {
24 | #if DEBUG
25 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
26 | #else
27 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
28 | #endif
29 | }
30 |
31 | @end
32 |
--------------------------------------------------------------------------------
/example/react_native/ios/react_native/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "scale" : "2x",
6 | "size" : "20x20"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "scale" : "3x",
11 | "size" : "20x20"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "scale" : "2x",
16 | "size" : "29x29"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "scale" : "3x",
21 | "size" : "29x29"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "scale" : "2x",
26 | "size" : "40x40"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "scale" : "3x",
31 | "size" : "40x40"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "scale" : "2x",
36 | "size" : "60x60"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "scale" : "3x",
41 | "size" : "60x60"
42 | },
43 | {
44 | "idiom" : "ios-marketing",
45 | "scale" : "1x",
46 | "size" : "1024x1024"
47 | }
48 | ],
49 | "info" : {
50 | "author" : "xcode",
51 | "version" : 1
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/example/react_native/ios/react_native/Images.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/example/react_native/ios/react_native/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | react_native
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | $(MARKETING_VERSION)
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | $(CURRENT_PROJECT_VERSION)
25 | LSRequiresIPhoneOS
26 |
27 | NSAppTransportSecurity
28 |
29 |
30 | NSAllowsArbitraryLoads
31 |
32 | NSAllowsLocalNetworking
33 |
34 |
35 | NSLocationWhenInUseUsageDescription
36 |
37 | UILaunchStoryboardName
38 | LaunchScreen
39 | UIRequiredDeviceCapabilities
40 |
41 | arm64
42 |
43 | UISupportedInterfaceOrientations
44 |
45 | UIInterfaceOrientationPortrait
46 | UIInterfaceOrientationLandscapeLeft
47 | UIInterfaceOrientationLandscapeRight
48 |
49 | UIViewControllerBasedStatusBarAppearance
50 |
51 | Survicate
52 |
53 | WorkspaceKey
54 | YOUR_WORKSPACE_KEY
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/example/react_native/ios/react_native/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
24 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/example/react_native/ios/react_native/PrivacyInfo.xcprivacy:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NSPrivacyAccessedAPITypes
6 |
7 |
8 | NSPrivacyAccessedAPIType
9 | NSPrivacyAccessedAPICategoryFileTimestamp
10 | NSPrivacyAccessedAPITypeReasons
11 |
12 | C617.1
13 |
14 |
15 |
16 | NSPrivacyAccessedAPIType
17 | NSPrivacyAccessedAPICategoryUserDefaults
18 | NSPrivacyAccessedAPITypeReasons
19 |
20 | CA92.1
21 |
22 |
23 |
24 | NSPrivacyAccessedAPIType
25 | NSPrivacyAccessedAPICategorySystemBootTime
26 | NSPrivacyAccessedAPITypeReasons
27 |
28 | 35F9.1
29 |
30 |
31 |
32 | NSPrivacyCollectedDataTypes
33 |
34 | NSPrivacyTracking
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/example/react_native/ios/react_native/main.m:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | #import "AppDelegate.h"
4 |
5 | int main(int argc, char *argv[])
6 | {
7 | @autoreleasepool {
8 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/example/react_native/ios/react_nativeTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/example/react_native/ios/react_nativeTests/react_nativeTests.m:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | #import
5 | #import
6 |
7 | #define TIMEOUT_SECONDS 600
8 | #define TEXT_TO_LOOK_FOR @"Welcome to React"
9 |
10 | @interface react_nativeTests : XCTestCase
11 |
12 | @end
13 |
14 | @implementation react_nativeTests
15 |
16 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL (^)(UIView *view))test
17 | {
18 | if (test(view)) {
19 | return YES;
20 | }
21 | for (UIView *subview in [view subviews]) {
22 | if ([self findSubviewInView:subview matching:test]) {
23 | return YES;
24 | }
25 | }
26 | return NO;
27 | }
28 |
29 | - (void)testRendersWelcomeScreen
30 | {
31 | UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController];
32 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS];
33 | BOOL foundElement = NO;
34 |
35 | __block NSString *redboxError = nil;
36 | #ifdef DEBUG
37 | RCTSetLogFunction(
38 | ^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) {
39 | if (level >= RCTLogLevelError) {
40 | redboxError = message;
41 | }
42 | });
43 | #endif
44 |
45 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) {
46 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
47 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
48 |
49 | foundElement = [self findSubviewInView:vc.view
50 | matching:^BOOL(UIView *view) {
51 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) {
52 | return YES;
53 | }
54 | return NO;
55 | }];
56 | }
57 |
58 | #ifdef DEBUG
59 | RCTSetLogFunction(RCTDefaultLogFunction);
60 | #endif
61 |
62 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError);
63 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS);
64 | }
65 |
66 | @end
67 |
--------------------------------------------------------------------------------
/example/react_native/metro.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const { getDefaultConfig } = require('@react-native/metro-config');
3 | const { getConfig } = require('react-native-builder-bob/metro-config');
4 | const pkg = require('../../package.json');
5 |
6 | const root = path.resolve(__dirname, '../..');
7 |
8 | /**
9 | * Metro configuration
10 | * https://facebook.github.io/metro/docs/configuration
11 | *
12 | * @type {import('metro-config').MetroConfig}
13 | */
14 | module.exports = getConfig(getDefaultConfig(__dirname), {
15 | root,
16 | pkg,
17 | project: __dirname,
18 | });
19 |
--------------------------------------------------------------------------------
/example/react_native/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react_native",
3 | "version": "0.0.1",
4 | "private": true,
5 | "scripts": {
6 | "android": "react-native run-android",
7 | "ios": "react-native run-ios",
8 | "lint": "eslint .",
9 | "start": "react-native start",
10 | "test": "jest"
11 | },
12 | "dependencies": {
13 | "react": "18.3.1",
14 | "react-native": "0.75.2"
15 | },
16 | "devDependencies": {
17 | "@babel/core": "^7.20.0",
18 | "@babel/preset-env": "^7.20.0",
19 | "@babel/runtime": "^7.20.0",
20 | "@react-native/babel-preset": "0.75.2",
21 | "@react-native/metro-config": "0.75.2",
22 | "@react-native/typescript-config": "0.75.2",
23 | "react-native-builder-bob": "^0.30.0"
24 | },
25 | "engines": {
26 | "node": ">=18"
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/example/react_native/react-native.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const pkg = require('../../package.json');
3 |
4 | module.exports = {
5 | project: {
6 | ios: {
7 | automaticPodsInstallation: true,
8 | },
9 | },
10 | dependencies: {
11 | [pkg.name]: {
12 | root: path.join(__dirname, '../..'),
13 | },
14 | },
15 | };
16 |
--------------------------------------------------------------------------------
/ios/SurvicateBindings.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | #ifdef RCT_NEW_ARCH_ENABLED
5 | #import "RNSurvicateSpec.h"
6 |
7 | @interface SurvicateBindings : RCTEventEmitter
8 | #else
9 | #import
10 |
11 | @interface SurvicateBindings : RCTEventEmitter
12 | #endif
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/ios/SurvicateBindings.mm:
--------------------------------------------------------------------------------
1 | #import "SurvicateBindings.h"
2 | #import
3 |
4 | @implementation SurvicateBindings
5 | {
6 | bool hasListeners;
7 | }
8 |
9 | - (dispatch_queue_t)methodQueue
10 | {
11 | return dispatch_get_main_queue();
12 | }
13 |
14 | RCT_EXPORT_MODULE()
15 |
16 | RCT_EXPORT_METHOD(enterScreen:(NSString *)screenName)
17 | {
18 | [[SurvicateSdk shared] enterScreenWithValue:screenName];
19 | }
20 |
21 | RCT_EXPORT_METHOD(leaveScreen:(NSString *)screenName)
22 | {
23 | [[SurvicateSdk shared] leaveScreenWithValue:screenName];
24 | }
25 |
26 | RCT_EXPORT_METHOD(invokeEvent:(NSString *)eventName eventProperties:(NSDictionary *) eventProperties)
27 | {
28 | [[SurvicateSdk shared] invokeEventWithName:eventName with:eventProperties];
29 | }
30 |
31 | RCT_EXPORT_METHOD(setUserId:(NSString *)userId)
32 | {
33 | [[SurvicateSdk shared] setUserTraitWithName:@"user_id" value:userId];
34 | }
35 |
36 | RCT_EXPORT_METHOD(setUserTrait:(NSString *)traitName traitValue:(NSString *)traitValue)
37 | {
38 | [[SurvicateSdk shared] setUserTraitWithName:traitName value:traitValue];
39 | }
40 |
41 | RCT_EXPORT_METHOD(initializeSdk)
42 | {
43 | [[SurvicateSdk shared] initialize];
44 | }
45 |
46 | RCT_EXPORT_METHOD(reset)
47 | {
48 | [[SurvicateSdk shared] reset];
49 | }
50 |
51 | RCT_EXPORT_METHOD(setWorkspaceKey:(NSString *)workspaceKey)
52 | {
53 | NSError *error;
54 | [[SurvicateSdk shared] setWorkspaceKey:workspaceKey error: &error];
55 | }
56 |
57 | RCT_EXPORT_METHOD(setLocale:(NSString *)locale)
58 | {
59 | [[SurvicateSdk shared] setLocale:locale];
60 | }
61 |
62 | - (NSArray *)supportedEvents {
63 | return @[@"onQuestionAnswered", @"onSurveyClosed", @"onSurveyCompleted", @"onSurveyDisplayed"];
64 | }
65 |
66 | - (void)startObserving {
67 | hasListeners = YES;
68 | [[SurvicateSdk shared] addListener:self];
69 | }
70 |
71 | - (void)stopObserving {
72 | hasListeners = NO;
73 | [[SurvicateSdk shared] removeListener:self];
74 | }
75 |
76 | - (void)surveyDisplayedWithEvent:(SurveyDisplayedEvent * _Nonnull)event {
77 | if (!hasListeners) return;
78 | [self sendEventWithName:@"onSurveyDisplayed" body:@{@"surveyId": event.surveyId}];
79 | }
80 |
81 | - (void)questionAnswered:(QuestionAnsweredEvent * _Nonnull)event {
82 | if (!hasListeners) return;
83 | [self sendEventWithName:@"onQuestionAnswered" body:
84 | @{@"surveyId": event.surveyId,
85 | @"surveyName": event.surveyName,
86 | @"visitorUuid": event.visitorUUID,
87 | @"responseUuid": event.responseUUID,
88 | @"questionId": @(event.questionID),
89 | @"question": event.question,
90 | @"answerValue": event.answer.value ?: [NSNull null],
91 | @"answerId": event.answer.id ?: [NSNull null],
92 | @"answerType": event.answer.type ?: [NSNull null],
93 | @"answerIds": event.answer.ids ?: @[],
94 | @"panelAnswerUrl": event.panelAnswerUrl,
95 | }
96 | ];
97 | }
98 |
99 | - (void)surveyCompletedWithEvent:(SurveyCompletedEvent * _Nonnull)event {
100 | if (!hasListeners) return;
101 | [self sendEventWithName:@"onSurveyCompleted" body:@{@"surveyId": event.surveyId}];
102 | }
103 |
104 | - (void)surveyClosedWithEvent:(SurveyClosedEvent * _Nonnull)event {
105 | if (!hasListeners) return;
106 | [self sendEventWithName:@"onSurveyClosed" body:@{@"surveyId": event.surveyId}];
107 | }
108 |
109 | // Don't compile this code when we build for the old architecture.
110 | #ifdef RCT_NEW_ARCH_ENABLED
111 | - (std::shared_ptr)getTurboModule:
112 | (const facebook::react::ObjCTurboModule::InitParams &)params
113 | {
114 | return std::make_shared(params);
115 | }
116 | #endif
117 |
118 | @end
119 |
--------------------------------------------------------------------------------
/ios/SurvicateBindings.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | B3E7B58A1CC2AC0600A0062D /* SurvicateBindings.mm in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* SurvicateBindings.mm */; };
11 | /* End PBXBuildFile section */
12 |
13 | /* Begin PBXCopyFilesBuildPhase section */
14 | 58B511D91A9E6C8500147676 /* CopyFiles */ = {
15 | isa = PBXCopyFilesBuildPhase;
16 | buildActionMask = 2147483647;
17 | dstPath = "include/$(PRODUCT_NAME)";
18 | dstSubfolderSpec = 16;
19 | files = (
20 | );
21 | runOnlyForDeploymentPostprocessing = 0;
22 | };
23 | /* End PBXCopyFilesBuildPhase section */
24 |
25 | /* Begin PBXFileReference section */
26 | 134814201AA4EA6300B7C361 /* libSurvicateBindings.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libSurvicateBindings.a; sourceTree = BUILT_PRODUCTS_DIR; };
27 | B3E7B5881CC2AC0600A0062D /* SurvicateBindings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SurvicateBindings.h; sourceTree = ""; };
28 | B3E7B5891CC2AC0600A0062D /* SurvicateBindings.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SurvicateBindings.mm; sourceTree = ""; };
29 | /* End PBXFileReference section */
30 |
31 | /* Begin PBXFrameworksBuildPhase section */
32 | 58B511D81A9E6C8500147676 /* Frameworks */ = {
33 | isa = PBXFrameworksBuildPhase;
34 | buildActionMask = 2147483647;
35 | files = (
36 | );
37 | runOnlyForDeploymentPostprocessing = 0;
38 | };
39 | /* End PBXFrameworksBuildPhase section */
40 |
41 | /* Begin PBXGroup section */
42 | 134814211AA4EA7D00B7C361 /* Products */ = {
43 | isa = PBXGroup;
44 | children = (
45 | 134814201AA4EA6300B7C361 /* libSurvicateBindings.a */,
46 | );
47 | name = Products;
48 | sourceTree = "";
49 | };
50 | 58B511D21A9E6C8500147676 = {
51 | isa = PBXGroup;
52 | children = (
53 | B3E7B5881CC2AC0600A0062D /* SurvicateBindings.h */,
54 | B3E7B5891CC2AC0600A0062D /* SurvicateBindings.mm */,
55 | 134814211AA4EA7D00B7C361 /* Products */,
56 | );
57 | sourceTree = "";
58 | };
59 | /* End PBXGroup section */
60 |
61 | /* Begin PBXNativeTarget section */
62 | 58B511DA1A9E6C8500147676 /* SurvicateBindings */ = {
63 | isa = PBXNativeTarget;
64 | buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "SurvicateBindings" */;
65 | buildPhases = (
66 | 58B511D71A9E6C8500147676 /* Sources */,
67 | 58B511D81A9E6C8500147676 /* Frameworks */,
68 | 58B511D91A9E6C8500147676 /* CopyFiles */,
69 | );
70 | buildRules = (
71 | );
72 | dependencies = (
73 | );
74 | name = SurvicateBindings;
75 | productName = RCTDataManager;
76 | productReference = 134814201AA4EA6300B7C361 /* libSurvicateBindings.a */;
77 | productType = "com.apple.product-type.library.static";
78 | };
79 | /* End PBXNativeTarget section */
80 |
81 | /* Begin PBXProject section */
82 | 58B511D31A9E6C8500147676 /* Project object */ = {
83 | isa = PBXProject;
84 | attributes = {
85 | LastUpgradeCheck = 0920;
86 | ORGANIZATIONNAME = Facebook;
87 | TargetAttributes = {
88 | 58B511DA1A9E6C8500147676 = {
89 | CreatedOnToolsVersion = 6.1.1;
90 | };
91 | };
92 | };
93 | buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "SurvicateBindings" */;
94 | compatibilityVersion = "Xcode 3.2";
95 | developmentRegion = English;
96 | hasScannedForEncodings = 0;
97 | knownRegions = (
98 | English,
99 | en,
100 | );
101 | mainGroup = 58B511D21A9E6C8500147676;
102 | productRefGroup = 58B511D21A9E6C8500147676;
103 | projectDirPath = "";
104 | projectRoot = "";
105 | targets = (
106 | 58B511DA1A9E6C8500147676 /* SurvicateBindings */,
107 | );
108 | };
109 | /* End PBXProject section */
110 |
111 | /* Begin PBXSourcesBuildPhase section */
112 | 58B511D71A9E6C8500147676 /* Sources */ = {
113 | isa = PBXSourcesBuildPhase;
114 | buildActionMask = 2147483647;
115 | files = (
116 | B3E7B58A1CC2AC0600A0062D /* SurvicateBindings.mm in Sources */,
117 | );
118 | runOnlyForDeploymentPostprocessing = 0;
119 | };
120 | /* End PBXSourcesBuildPhase section */
121 |
122 | /* Begin XCBuildConfiguration section */
123 | 58B511ED1A9E6C8500147676 /* Debug */ = {
124 | isa = XCBuildConfiguration;
125 | buildSettings = {
126 | ALWAYS_SEARCH_USER_PATHS = NO;
127 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
128 | CLANG_CXX_LIBRARY = "libc++";
129 | CLANG_ENABLE_MODULES = YES;
130 | CLANG_ENABLE_OBJC_ARC = YES;
131 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
132 | CLANG_WARN_BOOL_CONVERSION = YES;
133 | CLANG_WARN_COMMA = YES;
134 | CLANG_WARN_CONSTANT_CONVERSION = YES;
135 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
136 | CLANG_WARN_EMPTY_BODY = YES;
137 | CLANG_WARN_ENUM_CONVERSION = YES;
138 | CLANG_WARN_INFINITE_RECURSION = YES;
139 | CLANG_WARN_INT_CONVERSION = YES;
140 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
141 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
142 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
143 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
144 | CLANG_WARN_STRICT_PROTOTYPES = YES;
145 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
146 | CLANG_WARN_UNREACHABLE_CODE = YES;
147 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
148 | COPY_PHASE_STRIP = NO;
149 | ENABLE_STRICT_OBJC_MSGSEND = YES;
150 | ENABLE_TESTABILITY = YES;
151 | GCC_C_LANGUAGE_STANDARD = gnu99;
152 | GCC_DYNAMIC_NO_PIC = NO;
153 | GCC_NO_COMMON_BLOCKS = YES;
154 | GCC_OPTIMIZATION_LEVEL = 0;
155 | GCC_PREPROCESSOR_DEFINITIONS = (
156 | "DEBUG=1",
157 | "$(inherited)",
158 | );
159 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
160 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
161 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
162 | GCC_WARN_UNDECLARED_SELECTOR = YES;
163 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
164 | GCC_WARN_UNUSED_FUNCTION = YES;
165 | GCC_WARN_UNUSED_VARIABLE = YES;
166 | IPHONEOS_DEPLOYMENT_TARGET = 10.0;
167 | MTL_ENABLE_DEBUG_INFO = YES;
168 | ONLY_ACTIVE_ARCH = YES;
169 | SDKROOT = iphoneos;
170 | };
171 | name = Debug;
172 | };
173 | 58B511EE1A9E6C8500147676 /* Release */ = {
174 | isa = XCBuildConfiguration;
175 | buildSettings = {
176 | ALWAYS_SEARCH_USER_PATHS = NO;
177 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
178 | CLANG_CXX_LIBRARY = "libc++";
179 | CLANG_ENABLE_MODULES = YES;
180 | CLANG_ENABLE_OBJC_ARC = YES;
181 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
182 | CLANG_WARN_BOOL_CONVERSION = YES;
183 | CLANG_WARN_COMMA = YES;
184 | CLANG_WARN_CONSTANT_CONVERSION = YES;
185 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
186 | CLANG_WARN_EMPTY_BODY = YES;
187 | CLANG_WARN_ENUM_CONVERSION = YES;
188 | CLANG_WARN_INFINITE_RECURSION = YES;
189 | CLANG_WARN_INT_CONVERSION = YES;
190 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
191 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
192 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
193 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
194 | CLANG_WARN_STRICT_PROTOTYPES = YES;
195 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
196 | CLANG_WARN_UNREACHABLE_CODE = YES;
197 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
198 | COPY_PHASE_STRIP = YES;
199 | ENABLE_NS_ASSERTIONS = NO;
200 | ENABLE_STRICT_OBJC_MSGSEND = YES;
201 | GCC_C_LANGUAGE_STANDARD = gnu99;
202 | GCC_NO_COMMON_BLOCKS = YES;
203 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
204 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
205 | GCC_WARN_UNDECLARED_SELECTOR = YES;
206 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
207 | GCC_WARN_UNUSED_FUNCTION = YES;
208 | GCC_WARN_UNUSED_VARIABLE = YES;
209 | IPHONEOS_DEPLOYMENT_TARGET = 10.0;
210 | MTL_ENABLE_DEBUG_INFO = NO;
211 | SDKROOT = iphoneos;
212 | VALIDATE_PRODUCT = YES;
213 | };
214 | name = Release;
215 | };
216 | 58B511F01A9E6C8500147676 /* Debug */ = {
217 | isa = XCBuildConfiguration;
218 | buildSettings = {
219 | FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../../../../ios/Pods/**";
220 | HEADER_SEARCH_PATHS = (
221 | "$(inherited)",
222 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
223 | "$(SRCROOT)/../../../../React/**",
224 | "$(SRCROOT)/../../../react-native/React/**",
225 | "$(SRCROOT)/../../../../ios/Pods/**",
226 | );
227 | LIBRARY_SEARCH_PATHS = "$(inherited)";
228 | OTHER_LDFLAGS = "-ObjC";
229 | PRODUCT_NAME = SurvicateBindings;
230 | SKIP_INSTALL = YES;
231 | };
232 | name = Debug;
233 | };
234 | 58B511F11A9E6C8500147676 /* Release */ = {
235 | isa = XCBuildConfiguration;
236 | buildSettings = {
237 | FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../../../../ios/Pods/**";
238 | HEADER_SEARCH_PATHS = (
239 | "$(inherited)",
240 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
241 | "$(SRCROOT)/../../../../React/**",
242 | "$(SRCROOT)/../../../react-native/React/**",
243 | "$(SRCROOT)/../../../../ios/Pods/**",
244 | );
245 | LIBRARY_SEARCH_PATHS = "$(inherited)";
246 | OTHER_LDFLAGS = "-ObjC";
247 | PRODUCT_NAME = SurvicateBindings;
248 | SKIP_INSTALL = YES;
249 | };
250 | name = Release;
251 | };
252 | /* End XCBuildConfiguration section */
253 |
254 | /* Begin XCConfigurationList section */
255 | 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "SurvicateBindings" */ = {
256 | isa = XCConfigurationList;
257 | buildConfigurations = (
258 | 58B511ED1A9E6C8500147676 /* Debug */,
259 | 58B511EE1A9E6C8500147676 /* Release */,
260 | );
261 | defaultConfigurationIsVisible = 0;
262 | defaultConfigurationName = Release;
263 | };
264 | 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "SurvicateBindings" */ = {
265 | isa = XCConfigurationList;
266 | buildConfigurations = (
267 | 58B511F01A9E6C8500147676 /* Debug */,
268 | 58B511F11A9E6C8500147676 /* Release */,
269 | );
270 | defaultConfigurationIsVisible = 0;
271 | defaultConfigurationName = Release;
272 | };
273 | /* End XCConfigurationList section */
274 | };
275 | rootObject = 58B511D31A9E6C8500147676 /* Project object */;
276 | }
277 |
--------------------------------------------------------------------------------
/ios/SurvicateBindings.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ios/SurvicateBindings.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@survicate/react-native-survicate",
3 | "title": "React Native Survicate Bindings",
4 | "version": "6.3.1",
5 | "description": "React Native bindings for Survicate Mobile SDK",
6 | "main": "lib/commonjs/index.js",
7 | "module": "lib/module/index.js",
8 | "react-native": "src/index.ts",
9 | "types": "lib/typescript/index.d.ts",
10 | "source": "src/index.ts",
11 | "files": [
12 | "src",
13 | "lib",
14 | "android",
15 | "ios",
16 | "cpp",
17 | "app.plugin.js",
18 | "react-native-survicate.podspec",
19 | "!android/build",
20 | "!ios/build",
21 | "!android/gradle",
22 | "!android/gradlew",
23 | "!android/gradlew.bat",
24 | "!android/local.properties",
25 | "!**/__tests__",
26 | "!**/__fixtures__",
27 | "!**/__mocks__",
28 | "!**/.*"
29 | ],
30 | "scripts": {
31 | "test": "echo \"Error: no test specified\" && exit 1",
32 | "build": "bob build",
33 | "prepare": "bob build"
34 | },
35 | "repository": {
36 | "type": "git",
37 | "url": "git+https://github.com/Survicate/survicate-react-native-sdk.git",
38 | "baseUrl": "https://github.com/Survicate/survicate-react-native-sdk"
39 | },
40 | "keywords": [
41 | "react-native",
42 | "expo"
43 | ],
44 | "author": "Survicate (https://survicate.com/)",
45 | "license": "MIT",
46 | "licenseFilename": "LICENSE",
47 | "readmeFilename": "README.md",
48 | "bugs": {
49 | "url": "https://survicate.com"
50 | },
51 | "peerDependencies": {
52 | "expo": ">=49",
53 | "react": ">=16.8.6",
54 | "react-native": ">=0.60.0"
55 | },
56 | "peerDependenciesMeta": {
57 | "expo": {
58 | "optional": true
59 | }
60 | },
61 | "devDependencies": {
62 | "@tsconfig/react-native": "^3.0.2",
63 | "@types/jest": "^29.5.4",
64 | "@types/react": "^18.2.21",
65 | "@types/react-test-renderer": "^18.0.1",
66 | "expo": "^52.0.15",
67 | "react": "18.2.0",
68 | "react-native": "0.72.6",
69 | "react-native-builder-bob": "^0.23.1",
70 | "typescript": "5.2.2"
71 | },
72 | "react-native-builder-bob": {
73 | "exclude": "**/NativeSurvicateModule.ts",
74 | "source": "src",
75 | "output": "lib",
76 | "targets": [
77 | "commonjs",
78 | "module",
79 | [
80 | "typescript",
81 | {
82 | "project": "tsconfig.build.json"
83 | }
84 | ]
85 | ]
86 | },
87 | "codegenConfig": {
88 | "name": "RNSurvicateSpec",
89 | "type": "modules",
90 | "jsSrcsDir": "src",
91 | "android": {
92 | "javaPackageName": "com.survicate.react"
93 | }
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/react-native-survicate.podspec:
--------------------------------------------------------------------------------
1 | require "json"
2 |
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'
5 |
6 | Pod::Spec.new do |s|
7 | s.name = "react-native-survicate"
8 | s.version = package["version"]
9 | s.summary = package["description"]
10 | s.description = <<-DESC
11 | React Native bindings for Survicate Mobile SDK
12 | DESC
13 | s.homepage = "https://github.com/Survicate/survicate-react-native-sdk"
14 | s.license = "MIT"
15 | # s.license = { :type => "MIT", :file => "FILE_LICENSE" }
16 | s.authors = { "Survicate" => "help@survicate.com" }
17 | s.platforms = { :ios => "14.0" }
18 | s.source = { :git => "https://github.com/Survicate/survicate-react-native-sdk.git", :tag => "#{s.version}" }
19 |
20 | s.source_files = "ios/**/*.{h,mm,swift}"
21 | s.requires_arc = true
22 |
23 | s.dependency "React"
24 | s.dependency "Survicate", "6.3.1"
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
50 | end
51 |
52 |
--------------------------------------------------------------------------------
/src/NativeSurvicateModule.ts:
--------------------------------------------------------------------------------
1 | import type { TurboModule } from "react-native";
2 | import { TurboModuleRegistry } from "react-native";
3 |
4 | export interface Spec extends TurboModule {
5 | initializeSdk(): void;
6 | invokeEvent(eventName: string, eventProperties: Object): void;
7 | enterScreen(screenName: string): void;
8 | leaveScreen(screenName: string): void;
9 | setUserId(userId: string): void;
10 | setUserTrait(traitName: string, traitValue: string): void;
11 | setWorkspaceKey(workspaceKey: string): void;
12 | reset(): void;
13 | addListener(eventName: string): void;
14 | removeListeners(count: number): void;
15 | setLocale(locale: string): void;
16 | }
17 |
18 | export default TurboModuleRegistry.get("SurvicateBindings");
19 |
--------------------------------------------------------------------------------
/src/expo/types.ts:
--------------------------------------------------------------------------------
1 | export type SurvicatePluginProps = {
2 | workspaceKey: string
3 | }
4 |
--------------------------------------------------------------------------------
/src/expo/withSurvicate.ts:
--------------------------------------------------------------------------------
1 | import { ConfigPlugin, createRunOncePlugin } from "@expo/config-plugins";
2 | import { SurvicatePluginProps } from "./types";
3 | import { withSurvicateAndroidManifest, withSurvicateAndroidMavenRepository } from "./withSurvicateAndroid";
4 | import { withSurvicateIosInfoPlist } from "./withSurvicateiOS";
5 |
6 | const withSurvicateReactNative: ConfigPlugin = (
7 | config,
8 | props
9 | ) => {
10 | let newConfig = config;
11 | newConfig = withSurvicateAndroidManifest(newConfig, props);
12 | newConfig = withSurvicateAndroidMavenRepository(newConfig);
13 | newConfig = withSurvicateIosInfoPlist(newConfig, props);
14 | return newConfig;
15 | };
16 |
17 | const configPlugin = (pkg: { name: string; version: string }) =>
18 | createRunOncePlugin(withSurvicateReactNative, pkg.name, pkg.version);
19 |
20 | export default configPlugin;
21 |
--------------------------------------------------------------------------------
/src/expo/withSurvicateAndroid.ts:
--------------------------------------------------------------------------------
1 | import {
2 | AndroidConfig,
3 | ConfigPlugin,
4 | withAndroidManifest,
5 | withProjectBuildGradle,
6 | } from "expo/config-plugins";
7 | import { ExpoConfig } from "expo/config";
8 | import { SurvicatePluginProps } from "./types";
9 | import {
10 | MergeResults,
11 | createGeneratedHeaderComment,
12 | removeGeneratedContents,
13 | } from "@expo/config-plugins/build/utils/generateCode";
14 |
15 | // Using helpers keeps error messages unified and helps cut down on XML format changes.
16 | const { addMetaDataItemToMainApplication, getMainApplicationOrThrow } =
17 | AndroidConfig.Manifest;
18 |
19 | export const withSurvicateAndroidManifest: ConfigPlugin<
20 | SurvicatePluginProps
21 | > = (config: ExpoConfig, props: SurvicatePluginProps) => {
22 | return withAndroidManifest(config, async (config) => {
23 | // Modifiers can be async, but try to keep them fast.
24 | config.modResults = await setCustomConfigAsync(
25 | config.modResults,
26 | props.workspaceKey
27 | );
28 | return config;
29 | });
30 | };
31 |
32 | async function setCustomConfigAsync(
33 | androidManifest: AndroidConfig.Manifest.AndroidManifest,
34 | workspaceKey: string
35 | ): Promise {
36 | // Get the tag and assert if it doesn't exist.
37 | const mainApplication = getMainApplicationOrThrow(androidManifest);
38 |
39 | addMetaDataItemToMainApplication(
40 | mainApplication,
41 | // value for `android:name`
42 | "com.survicate.surveys.workspaceKey",
43 | // value for `android:value`
44 | workspaceKey
45 | );
46 |
47 | return androidManifest;
48 | }
49 |
50 | export const withSurvicateAndroidMavenRepository: ConfigPlugin = (config) => {
51 | return withProjectBuildGradle(config, async (config) => {
52 | if (config.modResults.language !== "groovy") {
53 | console.warn(
54 | "Unsupported language for build.gradle. Only 'groovy' is supported."
55 | );
56 | return config;
57 | }
58 |
59 | config.modResults.contents = await appendContents({
60 | src: config.modResults.contents,
61 | newSrc: `allprojects { repositories { maven { url 'https://repo.survicate.com' } } }`,
62 | tag: "@survicate/react-native-survicate",
63 | comment: "//",
64 | }).contents;
65 | return config;
66 | });
67 | };
68 |
69 | // Fork of config-plugins mergeContents, but appends the contents to the end of the file.
70 | function appendContents({
71 | src,
72 | newSrc,
73 | tag,
74 | comment,
75 | }: {
76 | src: string;
77 | newSrc: string;
78 | tag: string;
79 | comment: string;
80 | }): MergeResults {
81 | const header = createGeneratedHeaderComment(newSrc, tag, comment);
82 | if (!src.includes(header)) {
83 | // Ensure the old generated contents are removed.
84 | const sanitizedTarget = removeGeneratedContents(src, tag);
85 | const contentsToAdd = [
86 | // @something
87 | header,
88 | // contents
89 | newSrc,
90 | // @end
91 | `${comment} @generated end ${tag}`,
92 | ].join("\n");
93 | return {
94 | contents: sanitizedTarget ?? src + contentsToAdd,
95 | didMerge: true,
96 | didClear: !!sanitizedTarget,
97 | };
98 | }
99 | return { contents: src, didClear: false, didMerge: false };
100 | }
101 |
--------------------------------------------------------------------------------
/src/expo/withSurvicateiOS.ts:
--------------------------------------------------------------------------------
1 | import { ConfigPlugin, withInfoPlist } from 'expo/config-plugins';
2 | import {SurvicatePluginProps} from './types';
3 |
4 | export const withSurvicateIosInfoPlist: ConfigPlugin = (config, props: SurvicatePluginProps) => {
5 | return withInfoPlist(config, (config) => {
6 | config.modResults.Survicate = {
7 | WorkspaceKey: props.workspaceKey,
8 | };
9 | return config;
10 | });
11 | };
12 |
--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------
1 | import { NativeModules, NativeEventEmitter } from "react-native";
2 |
3 | const { SurvicateBindings } = NativeModules;
4 |
5 | // @ts-expect-error
6 | const isTurboModuleEnabled: boolean = global.__turboModuleProxy != null;
7 |
8 | const survicate: any = isTurboModuleEnabled
9 | ? require("./NativeSurvicateModule").default
10 | : SurvicateBindings;
11 |
12 | export class SurvicateIntegrations {}
13 |
14 | class Survicate {
15 | static integrations = new SurvicateIntegrations();
16 |
17 | static setWorkspaceKey(workspaceKey: string): void {
18 | survicate.setWorkspaceKey(workspaceKey);
19 | }
20 |
21 | static initializeSdk(): void {
22 | survicate.initializeSdk();
23 | }
24 |
25 | static invokeEvent(
26 | eventName: string,
27 | eventProperties?: Record
28 | ): void {
29 | survicate.invokeEvent(eventName, eventProperties || {});
30 | }
31 |
32 | static enterScreen(screenName: string): void {
33 | survicate.enterScreen(screenName);
34 | }
35 |
36 | static leaveScreen(screenName: string): void {
37 | survicate.leaveScreen(screenName);
38 | }
39 |
40 | /**
41 | * @deprecated Use setUserTrait(userTrait: UserTrait) method with `user_id' UserTrait instead.
42 | */
43 | static setUserId(userId: string): void {
44 | survicate.setUserId(userId);
45 | }
46 |
47 | /**
48 | * @deprecated Use setUserTrait(userTrait: UserTrait) method instead.
49 | */
50 | static setUserTrait(traitName: string, traitValue: string): void;
51 | static setUserTrait(userTrait: UserTrait): void;
52 | static setUserTrait(
53 | traitNameOrUserTrait: string | UserTrait,
54 | traitValue?: string
55 | ): void {
56 | if (typeof traitNameOrUserTrait === "string" && traitValue !== undefined) {
57 | survicate.setUserTrait(traitNameOrUserTrait, traitValue);
58 | } else if (traitNameOrUserTrait instanceof UserTrait) {
59 | survicate.setUserTrait(
60 | traitNameOrUserTrait.key,
61 | traitNameOrUserTrait.value
62 | );
63 | }
64 | }
65 |
66 | static reset(): void {
67 | survicate.reset();
68 | }
69 |
70 | static addSurvicateEventListener(
71 | listener: SurvicateEventListener
72 | ): () => void {
73 | const eventEmitter = new NativeEventEmitter(survicate);
74 |
75 | const onSurveyDisplayedCallback = (nativeEvent: any) => {
76 | let event: SurveyDisplayedEvent = { surveyId: nativeEvent.surveyId };
77 | if (listener.onSurveyDisplayed !== undefined) {
78 | listener.onSurveyDisplayed!(event);
79 | }
80 | };
81 | const onSurveyDisplayedListener = eventEmitter.addListener(
82 | "onSurveyDisplayed",
83 | (event) => onSurveyDisplayedCallback(event)
84 | );
85 |
86 | const onQuestionAnsweredCallback = (nativeEvent: any) => {
87 | let answer: SurvicateAnswer = {
88 | type: nativeEvent.answerType,
89 | id: nativeEvent.answerId,
90 | ids: nativeEvent.answerIds,
91 | value: nativeEvent.answerValue,
92 | };
93 | let event: QuestionAnsweredEvent = {
94 | surveyId: nativeEvent.surveyId,
95 | surveyName: nativeEvent.surveyName,
96 | visitorUuid: nativeEvent.visitorUuid,
97 | responseUuid: nativeEvent.responseUuid,
98 | questionId: nativeEvent.questionId,
99 | question: nativeEvent.question,
100 | answer: answer,
101 | panelAnswerUrl: nativeEvent.panelAnswerUrl,
102 | };
103 | if (listener.onQuestionAnswered !== undefined) {
104 | listener.onQuestionAnswered!(event);
105 | }
106 | };
107 | const onQuestionAnsweredListener = eventEmitter.addListener(
108 | "onQuestionAnswered",
109 | onQuestionAnsweredCallback
110 | );
111 |
112 | const onSurveyCompletedCallback = (nativeEvent: any) => {
113 | let event: SurveyCompletedEvent = { surveyId: nativeEvent.surveyId };
114 | if (listener.onSurveyCompleted !== undefined) {
115 | listener.onSurveyCompleted!(event);
116 | }
117 | };
118 |
119 | const onSurveyCompletedListener = eventEmitter.addListener(
120 | "onSurveyCompleted",
121 | onSurveyCompletedCallback
122 | );
123 |
124 | const onSurveyClosedCallback = (nativeEvent: any) => {
125 | let event: SurveyClosedEvent = { surveyId: nativeEvent.surveyId };
126 | if (listener.onSurveyClosed !== undefined) {
127 | listener.onSurveyClosed!(event);
128 | }
129 | };
130 |
131 | const onSurveyClosedListener = eventEmitter.addListener(
132 | "onSurveyClosed",
133 | onSurveyClosedCallback
134 | );
135 |
136 | return () => {
137 | onSurveyDisplayedListener.remove();
138 | onQuestionAnsweredListener.remove();
139 | onSurveyCompletedListener.remove();
140 | onSurveyClosedListener.remove();
141 | };
142 | }
143 |
144 | /**
145 | * Sets the preferred locale used for survey translations and targeting filters.
146 | * The specified locale takes priority over the device's default locale.
147 | *
148 | * This method affects only the Survicate SDK and does not change in any way the app locale settings.
149 | *
150 | * @param languageTag An IETF language tag such as:
151 | * - Two-letter ISO 639 language code (e.g., "en", "fr")
152 | * - Three-letter ISO 639 language code for languages without the two-letter code (e.g., "haw", "yue")
153 | * - Language with region (e.g., "en-US", "pt-BR")
154 | * - Language with script (e.g., "zh-Hans")
155 | */
156 | static setLocale(languageTag: string): void {
157 | survicate.setLocale(languageTag);
158 | }
159 | }
160 |
161 | export class UserTrait {
162 | key: string;
163 | value: string;
164 |
165 | constructor(key: string, value: string | number | boolean | Date) {
166 | if (key === null || value === null) {
167 | throw new Error("Key and value cannot be null");
168 | }
169 |
170 | this.key = key;
171 |
172 | if (value instanceof Date) {
173 | this.value = this.formatDateToTimeZoneIso(value);
174 | } else {
175 | this.value = value.toString();
176 | }
177 | }
178 |
179 | private formatDateToTimeZoneIso(date: Date): string {
180 | const offset = date.getTimezoneOffset();
181 | const offsetHours = Math.floor(Math.abs(offset) / 60);
182 | const offsetMinutes = Math.abs(offset) % 60;
183 | date = new Date(date.getTime() - offset * 60 * 1000);
184 | return (
185 | date.toISOString().slice(0, -5) +
186 | (offset > 0 ? "-" : "+") +
187 | offsetHours.toString().padStart(2, "0") +
188 | ":" +
189 | offsetMinutes.toString().padStart(2, "0")
190 | );
191 | }
192 | }
193 |
194 | export type SurveyDisplayedEvent = {
195 | surveyId: string;
196 | };
197 |
198 | export type QuestionAnsweredEvent = {
199 | surveyId: string;
200 | surveyName: string;
201 | visitorUuid: string;
202 | responseUuid: string;
203 | questionId: string;
204 | question: string | null;
205 | answer: SurvicateAnswer;
206 | panelAnswerUrl: string;
207 | };
208 |
209 | export type SurvicateAnswer = {
210 | type: string | null;
211 | id: number | null;
212 | ids: number[];
213 | value: string | null;
214 | };
215 |
216 | export type SurveyCompletedEvent = {
217 | surveyId: string;
218 | };
219 |
220 | export type SurveyClosedEvent = {
221 | surveyId: string;
222 | };
223 |
224 | export interface SurvicateEventListener {
225 | onSurveyDisplayed?: (event: SurveyDisplayedEvent) => void;
226 | onQuestionAnswered?: (event: QuestionAnsweredEvent) => void;
227 | onSurveyCompleted?: (event: SurveyCompletedEvent) => void;
228 | onSurveyClosed?: (event: SurveyClosedEvent) => void;
229 | }
230 |
231 | export default Survicate;
232 |
--------------------------------------------------------------------------------
/test/react_native/.gitignore:
--------------------------------------------------------------------------------
1 | # OSX
2 | #
3 | .DS_Store
4 |
5 | # Xcode
6 | #
7 | build/
8 | *.pbxuser
9 | !default.pbxuser
10 | *.mode1v3
11 | !default.mode1v3
12 | *.mode2v3
13 | !default.mode2v3
14 | *.perspectivev3
15 | !default.perspectivev3
16 | xcuserdata
17 | *.xccheckout
18 | *.moved-aside
19 | DerivedData
20 | *.hmap
21 | *.ipa
22 | *.xcuserstate
23 | *.xcode.env.local
24 |
25 | # Android/IntelliJ
26 | #
27 | build/
28 | .idea
29 | .gradle
30 | local.properties
31 | *.iml
32 | *.hprof
33 | .cxx/
34 | *.keystore
35 | !debug.keystore
36 |
37 | # node.js
38 | #
39 | node_modules/
40 | npm-debug.log
41 | yarn-error.log
42 |
43 | # Bundle artifact
44 | *.jsbundle
45 |
46 | # Ruby / CocoaPods
47 | /ios/Pods/
48 | /vendor/bundle/
49 |
50 | # Temporary files created by Metro to check the health of the file watcher
51 | .metro-health-check*
52 |
53 | *.xcarchive
54 |
55 | # Dotenv
56 | .env
57 |
--------------------------------------------------------------------------------
/test/react_native/App.tsx:
--------------------------------------------------------------------------------
1 | import React, { useEffect } from "react";
2 | import {
3 | Button,
4 | Text,
5 | SafeAreaView,
6 | ScrollView,
7 | StyleSheet,
8 | View,
9 | } from "react-native";
10 | import Survicate, { UserTrait } from "@survicate/react-native-survicate";
11 | import { WORKSPACE_KEY } from "@env";
12 |
13 | const App = () => {
14 | useEffect(() => {
15 | // Initialize the SDK
16 | Survicate.setWorkspaceKey(WORKSPACE_KEY);
17 | Survicate.initializeSdk();
18 | }, []);
19 |
20 | return (
21 |
22 |
23 | Test App
24 |
25 |
26 |
33 |
34 |
35 |
42 |
43 |
44 |
51 |
52 |
53 |
64 |
65 |
66 |
74 |
75 |
76 |
83 |
84 |
85 | );
86 | };
87 |
88 | const styles = StyleSheet.create({
89 | safeArea: {
90 | flex: 1,
91 | },
92 | scrollView: {
93 | padding: 20,
94 | },
95 | title: {
96 | fontSize: 20,
97 | marginBottom: 20,
98 | },
99 | buttonContainer: {
100 | marginBottom: 10,
101 | },
102 | });
103 |
104 | export default App;
105 |
--------------------------------------------------------------------------------
/test/react_native/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 |
3 | # You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4 | ruby ">= 2.6.10"
5 |
6 | # Exclude problematic versions of cocoapods and activesupport that causes build failures.
7 | gem 'cocoapods', '>= 1.13', '!= 1.15.0', '!= 1.15.1'
8 | gem 'activesupport', '>= 6.1.7.5', '!= 7.1.0'
9 |
--------------------------------------------------------------------------------
/test/react_native/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: https://rubygems.org/
3 | specs:
4 | CFPropertyList (3.0.7)
5 | base64
6 | nkf
7 | rexml
8 | activesupport (7.1.4)
9 | base64
10 | bigdecimal
11 | concurrent-ruby (~> 1.0, >= 1.0.2)
12 | connection_pool (>= 2.2.5)
13 | drb
14 | i18n (>= 1.6, < 2)
15 | minitest (>= 5.1)
16 | mutex_m
17 | tzinfo (~> 2.0)
18 | addressable (2.8.7)
19 | public_suffix (>= 2.0.2, < 7.0)
20 | algoliasearch (1.27.5)
21 | httpclient (~> 2.8, >= 2.8.3)
22 | json (>= 1.5.1)
23 | atomos (0.1.3)
24 | base64 (0.2.0)
25 | bigdecimal (3.1.8)
26 | claide (1.1.0)
27 | cocoapods (1.15.2)
28 | addressable (~> 2.8)
29 | claide (>= 1.0.2, < 2.0)
30 | cocoapods-core (= 1.15.2)
31 | cocoapods-deintegrate (>= 1.0.3, < 2.0)
32 | cocoapods-downloader (>= 2.1, < 3.0)
33 | cocoapods-plugins (>= 1.0.0, < 2.0)
34 | cocoapods-search (>= 1.0.0, < 2.0)
35 | cocoapods-trunk (>= 1.6.0, < 2.0)
36 | cocoapods-try (>= 1.1.0, < 2.0)
37 | colored2 (~> 3.1)
38 | escape (~> 0.0.4)
39 | fourflusher (>= 2.3.0, < 3.0)
40 | gh_inspector (~> 1.0)
41 | molinillo (~> 0.8.0)
42 | nap (~> 1.0)
43 | ruby-macho (>= 2.3.0, < 3.0)
44 | xcodeproj (>= 1.23.0, < 2.0)
45 | cocoapods-core (1.15.2)
46 | activesupport (>= 5.0, < 8)
47 | addressable (~> 2.8)
48 | algoliasearch (~> 1.0)
49 | concurrent-ruby (~> 1.1)
50 | fuzzy_match (~> 2.0.4)
51 | nap (~> 1.0)
52 | netrc (~> 0.11)
53 | public_suffix (~> 4.0)
54 | typhoeus (~> 1.0)
55 | cocoapods-deintegrate (1.0.5)
56 | cocoapods-downloader (2.1)
57 | cocoapods-plugins (1.0.0)
58 | nap
59 | cocoapods-search (1.0.1)
60 | cocoapods-trunk (1.6.0)
61 | nap (>= 0.8, < 2.0)
62 | netrc (~> 0.11)
63 | cocoapods-try (1.2.0)
64 | colored2 (3.1.2)
65 | concurrent-ruby (1.3.4)
66 | connection_pool (2.4.1)
67 | drb (2.2.1)
68 | escape (0.0.4)
69 | ethon (0.16.0)
70 | ffi (>= 1.15.0)
71 | ffi (1.17.0)
72 | fourflusher (2.3.1)
73 | fuzzy_match (2.0.4)
74 | gh_inspector (1.1.3)
75 | httpclient (2.8.3)
76 | i18n (1.14.6)
77 | concurrent-ruby (~> 1.0)
78 | json (2.7.2)
79 | minitest (5.25.1)
80 | molinillo (0.8.0)
81 | mutex_m (0.2.0)
82 | nanaimo (0.3.0)
83 | nap (1.1.0)
84 | netrc (0.11.0)
85 | nkf (0.2.0)
86 | public_suffix (4.0.7)
87 | rexml (3.3.7)
88 | ruby-macho (2.5.1)
89 | typhoeus (1.4.1)
90 | ethon (>= 0.9.0)
91 | tzinfo (2.0.6)
92 | concurrent-ruby (~> 1.0)
93 | xcodeproj (1.25.0)
94 | CFPropertyList (>= 2.3.3, < 4.0)
95 | atomos (~> 0.1.3)
96 | claide (>= 1.0.2, < 2.0)
97 | colored2 (~> 3.1)
98 | nanaimo (~> 0.3.0)
99 | rexml (>= 3.3.2, < 4.0)
100 |
101 | PLATFORMS
102 | ruby
103 |
104 | DEPENDENCIES
105 | activesupport (>= 6.1.7.5, != 7.1.0)
106 | cocoapods (>= 1.13, != 1.15.1, != 1.15.0)
107 |
108 | RUBY VERSION
109 | ruby 2.7.6p219
110 |
111 | BUNDLED WITH
112 | 2.1.4
113 |
--------------------------------------------------------------------------------
/test/react_native/README.md:
--------------------------------------------------------------------------------
1 | This is a new [**React Native**](https://reactnative.dev) project, bootstrapped using [`@react-native-community/cli`](https://github.com/react-native-community/cli).
2 |
3 | # Getting Started
4 |
5 | >**Note**: Make sure you have completed the [React Native - Environment Setup](https://reactnative.dev/docs/environment-setup) instructions till "Creating a new application" step, before proceeding.
6 |
7 | ## Step 1: Start the Metro Server
8 |
9 | First, you will need to start **Metro**, the JavaScript _bundler_ that ships _with_ React Native.
10 |
11 | To start Metro, run the following command from the _root_ of your React Native project:
12 |
13 | ```bash
14 | # using npm
15 | npm start
16 |
17 | # OR using Yarn
18 | yarn start
19 | ```
20 |
21 | ## Step 2: Start your Application
22 |
23 | Let Metro Bundler run in its _own_ terminal. Open a _new_ terminal from the _root_ of your React Native project. Run the following command to start your _Android_ or _iOS_ app:
24 |
25 | ### For Android
26 |
27 | ```bash
28 | # using npm
29 | npm run android
30 |
31 | # OR using Yarn
32 | yarn android
33 | ```
34 |
35 | ### For iOS
36 |
37 | ```bash
38 | # using npm
39 | npm run ios
40 |
41 | # OR using Yarn
42 | yarn ios
43 | ```
44 |
45 | If everything is set up _correctly_, you should see your new app running in your _Android Emulator_ or _iOS Simulator_ shortly provided you have set up your emulator/simulator correctly.
46 |
47 | This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively.
48 |
49 | ## Step 3: Modifying your App
50 |
51 | Now that you have successfully run the app, let's modify it.
52 |
53 | 1. Open `App.tsx` in your text editor of choice and edit some lines.
54 | 2. For **Android**: Press the R key twice or select **"Reload"** from the **Developer Menu** (Ctrl + M (on Window and Linux) or Cmd ⌘ + M (on macOS)) to see your changes!
55 |
56 | For **iOS**: Hit Cmd ⌘ + R in your iOS Simulator to reload the app and see your changes!
57 |
58 | ## Congratulations! :tada:
59 |
60 | You've successfully run and modified your React Native App. :partying_face:
61 |
62 | ### Now what?
63 |
64 | - If you want to add this new React Native code to an existing application, check out the [Integration guide](https://reactnative.dev/docs/integration-with-existing-apps).
65 | - If you're curious to learn more about React Native, check out the [Introduction to React Native](https://reactnative.dev/docs/getting-started).
66 |
67 | # Troubleshooting
68 |
69 | If you can't get this to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page.
70 |
71 | # Learn More
72 |
73 | To learn more about React Native, take a look at the following resources:
74 |
75 | - [React Native Website](https://reactnative.dev) - learn more about React Native.
76 | - [Getting Started](https://reactnative.dev/docs/environment-setup) - an **overview** of React Native and how setup your environment.
77 | - [Learn the Basics](https://reactnative.dev/docs/getting-started) - a **guided tour** of the React Native **basics**.
78 | - [Blog](https://reactnative.dev/blog) - read the latest official React Native **Blog** posts.
79 | - [`@facebook/react-native`](https://github.com/facebook/react-native) - the Open Source; GitHub **repository** for React Native.
80 |
--------------------------------------------------------------------------------
/test/react_native/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: "com.android.application"
2 | apply plugin: "org.jetbrains.kotlin.android"
3 | apply plugin: "com.facebook.react"
4 |
5 | /**
6 | * This is the configuration block to customize your React Native Android app.
7 | * By default you don't need to apply any configuration, just uncomment the lines you need.
8 | */
9 | react {
10 | /* Folders */
11 | // The root of your project, i.e. where "package.json" lives. Default is '../..'
12 | // root = file("../../")
13 | // The folder where the react-native NPM package is. Default is ../../node_modules/react-native
14 | // reactNativeDir = file("../../node_modules/react-native")
15 | // The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen
16 | // codegenDir = file("../../node_modules/@react-native/codegen")
17 | // The cli.js file which is the React Native CLI entrypoint. Default is ../../node_modules/react-native/cli.js
18 | // cliFile = file("../../node_modules/react-native/cli.js")
19 |
20 | /* Variants */
21 | // The list of variants to that are debuggable. For those we're going to
22 | // skip the bundling of the JS bundle and the assets. By default is just 'debug'.
23 | // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
24 | // debuggableVariants = ["liteDebug", "prodDebug"]
25 |
26 | /* Bundling */
27 | // A list containing the node command and its flags. Default is just 'node'.
28 | // nodeExecutableAndArgs = ["node"]
29 | //
30 | // The command to run when bundling. By default is 'bundle'
31 | // bundleCommand = "ram-bundle"
32 | //
33 | // The path to the CLI configuration file. Default is empty.
34 | // bundleConfig = file(../rn-cli.config.js)
35 | //
36 | // The name of the generated asset file containing your JS bundle
37 | // bundleAssetName = "MyApplication.android.bundle"
38 | //
39 | // The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
40 | // entryFile = file("../js/MyApplication.android.js")
41 | //
42 | // A list of extra flags to pass to the 'bundle' commands.
43 | // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
44 | // extraPackagerArgs = []
45 |
46 | /* Hermes Commands */
47 | // The hermes compiler command to run. By default it is 'hermesc'
48 | // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
49 | //
50 | // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
51 | // hermesFlags = ["-O", "-output-source-map"]
52 |
53 | /* Autolinking */
54 | autolinkLibrariesWithApp()
55 | }
56 |
57 | /**
58 | * Set this to true to Run Proguard on Release builds to minify the Java bytecode.
59 | */
60 | def enableProguardInReleaseBuilds = false
61 |
62 | /**
63 | * The preferred build flavor of JavaScriptCore (JSC)
64 | *
65 | * For example, to use the international variant, you can use:
66 | * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
67 | *
68 | * The international variant includes ICU i18n library and necessary data
69 | * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
70 | * give correct results when using with locales other than en-US. Note that
71 | * this variant is about 6MiB larger per architecture than default.
72 | */
73 | def jscFlavor = 'org.webkit:android-jsc:+'
74 |
75 | android {
76 | ndkVersion rootProject.ext.ndkVersion
77 | buildToolsVersion rootProject.ext.buildToolsVersion
78 | compileSdk rootProject.ext.compileSdkVersion
79 |
80 | namespace "com.react_native"
81 | defaultConfig {
82 | applicationId "com.react_native"
83 | minSdkVersion rootProject.ext.minSdkVersion
84 | targetSdkVersion rootProject.ext.targetSdkVersion
85 | versionCode 1
86 | versionName "1.0"
87 | }
88 | signingConfigs {
89 | debug {
90 | storeFile file('debug.keystore')
91 | storePassword 'android'
92 | keyAlias 'androiddebugkey'
93 | keyPassword 'android'
94 | }
95 | }
96 | buildTypes {
97 | debug {
98 | signingConfig signingConfigs.debug
99 | }
100 | release {
101 | // Caution! In production, you need to generate your own keystore file.
102 | // see https://reactnative.dev/docs/signed-apk-android.
103 | signingConfig signingConfigs.debug
104 | minifyEnabled enableProguardInReleaseBuilds
105 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
106 | }
107 | }
108 | }
109 |
110 | dependencies {
111 | // The version of react-native is set by the React Native Gradle Plugin
112 | implementation("com.facebook.react:react-android")
113 |
114 | if (hermesEnabled.toBoolean()) {
115 | implementation("com.facebook.react:hermes-android")
116 | } else {
117 | implementation jscFlavor
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/test/react_native/android/app/debug.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Survicate/survicate-react-native-sdk/a1c216139fbf88cbf4b2bb3d2006593485cad484/test/react_native/android/app/debug.keystore
--------------------------------------------------------------------------------
/test/react_native/android/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
--------------------------------------------------------------------------------
/test/react_native/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
9 |
10 |
--------------------------------------------------------------------------------
/test/react_native/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
13 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/test/react_native/android/app/src/main/java/com/react_native/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.react_native
2 |
3 | import com.facebook.react.ReactActivity
4 | import com.facebook.react.ReactActivityDelegate
5 | import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
6 | import com.facebook.react.defaults.DefaultReactActivityDelegate
7 |
8 | class MainActivity : ReactActivity() {
9 |
10 | /**
11 | * Returns the name of the main component registered from JavaScript. This is used to schedule
12 | * rendering of the component.
13 | */
14 | override fun getMainComponentName(): String = "react_native"
15 |
16 | /**
17 | * Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
18 | * which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
19 | */
20 | override fun createReactActivityDelegate(): ReactActivityDelegate =
21 | DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
22 | }
23 |
--------------------------------------------------------------------------------
/test/react_native/android/app/src/main/java/com/react_native/MainApplication.kt:
--------------------------------------------------------------------------------
1 | package com.react_native
2 |
3 | import android.app.Application
4 | import com.facebook.react.PackageList
5 | import com.facebook.react.ReactApplication
6 | import com.facebook.react.ReactHost
7 | import com.facebook.react.ReactNativeHost
8 | import com.facebook.react.ReactPackage
9 | import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
10 | import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
11 | import com.facebook.react.defaults.DefaultReactNativeHost
12 | import com.facebook.soloader.SoLoader
13 |
14 | class MainApplication : Application(), ReactApplication {
15 |
16 | override val reactNativeHost: ReactNativeHost =
17 | object : DefaultReactNativeHost(this) {
18 | override fun getPackages(): List =
19 | PackageList(this).packages.apply {
20 | // Packages that cannot be autolinked yet can be added manually here, for example:
21 | // add(MyReactNativePackage())
22 | }
23 |
24 | override fun getJSMainModuleName(): String = "index"
25 |
26 | override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
27 |
28 | override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
29 | override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
30 | }
31 |
32 | override val reactHost: ReactHost
33 | get() = getDefaultReactHost(applicationContext, reactNativeHost)
34 |
35 | override fun onCreate() {
36 | super.onCreate()
37 | SoLoader.init(this, false)
38 | if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
39 | // If you opted-in for the New Architecture, we load the native entry point for this app.
40 | load()
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/test/react_native/android/app/src/main/res/drawable/rn_edit_text_material.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
22 |
23 |
24 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/test/react_native/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Survicate/survicate-react-native-sdk/a1c216139fbf88cbf4b2bb3d2006593485cad484/test/react_native/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/test/react_native/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Survicate/survicate-react-native-sdk/a1c216139fbf88cbf4b2bb3d2006593485cad484/test/react_native/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/test/react_native/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Survicate/survicate-react-native-sdk/a1c216139fbf88cbf4b2bb3d2006593485cad484/test/react_native/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/test/react_native/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Survicate/survicate-react-native-sdk/a1c216139fbf88cbf4b2bb3d2006593485cad484/test/react_native/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/test/react_native/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Survicate/survicate-react-native-sdk/a1c216139fbf88cbf4b2bb3d2006593485cad484/test/react_native/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/test/react_native/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Survicate/survicate-react-native-sdk/a1c216139fbf88cbf4b2bb3d2006593485cad484/test/react_native/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/test/react_native/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Survicate/survicate-react-native-sdk/a1c216139fbf88cbf4b2bb3d2006593485cad484/test/react_native/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/test/react_native/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Survicate/survicate-react-native-sdk/a1c216139fbf88cbf4b2bb3d2006593485cad484/test/react_native/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/test/react_native/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Survicate/survicate-react-native-sdk/a1c216139fbf88cbf4b2bb3d2006593485cad484/test/react_native/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/test/react_native/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Survicate/survicate-react-native-sdk/a1c216139fbf88cbf4b2bb3d2006593485cad484/test/react_native/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/test/react_native/android/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | react_native
3 |
4 |
--------------------------------------------------------------------------------
/test/react_native/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/test/react_native/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext {
3 | buildToolsVersion = "34.0.0"
4 | minSdkVersion = 23
5 | compileSdkVersion = 34
6 | targetSdkVersion = 34
7 | ndkVersion = "26.1.10909125"
8 | kotlinVersion = "1.9.24"
9 | }
10 | repositories {
11 | google()
12 | mavenCentral()
13 | }
14 | dependencies {
15 | classpath("com.android.tools.build:gradle")
16 | classpath("com.facebook.react:react-native-gradle-plugin")
17 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
18 | }
19 | }
20 |
21 | allprojects {
22 | repositories {
23 | maven {url "https://repo.survicate.com"}
24 | }
25 | }
26 |
27 | apply plugin: "com.facebook.react.rootproject"
28 |
--------------------------------------------------------------------------------
/test/react_native/android/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx512m -XX:MaxMetaspaceSize=256m
13 | org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 |
20 | # AndroidX package structure to make it clearer which packages are bundled with the
21 | # Android operating system, and which are packaged with your app's APK
22 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
23 | android.useAndroidX=true
24 |
25 | # Use this property to specify which architecture you want to build.
26 | # You can also override it from the CLI using
27 | # ./gradlew -PreactNativeArchitectures=x86_64
28 | reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
29 |
30 | # Use this property to enable support to the new architecture.
31 | # This will allow you to use TurboModules and the Fabric render in
32 | # your application. You should enable this flag either if you want
33 | # to write custom TurboModules/Fabric components OR use libraries that
34 | # are providing them.
35 | newArchEnabled=false
36 |
37 | # Use this property to enable or disable the Hermes JS engine.
38 | # If set to false, you will be using JSC instead.
39 | hermesEnabled=true
40 |
--------------------------------------------------------------------------------
/test/react_native/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Survicate/survicate-react-native-sdk/a1c216139fbf88cbf4b2bb3d2006593485cad484/test/react_native/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/test/react_native/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/test/react_native/android/gradlew:
--------------------------------------------------------------------------------
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/HEAD/platforms/jvm/plugins-application/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 | # This is normally unused
84 | # shellcheck disable=SC2034
85 | APP_BASE_NAME=${0##*/}
86 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87 | APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
88 |
89 | # Use the maximum available, or set MAX_FD != -1 to use that value.
90 | MAX_FD=maximum
91 |
92 | warn () {
93 | echo "$*"
94 | } >&2
95 |
96 | die () {
97 | echo
98 | echo "$*"
99 | echo
100 | exit 1
101 | } >&2
102 |
103 | # OS specific support (must be 'true' or 'false').
104 | cygwin=false
105 | msys=false
106 | darwin=false
107 | nonstop=false
108 | case "$( uname )" in #(
109 | CYGWIN* ) cygwin=true ;; #(
110 | Darwin* ) darwin=true ;; #(
111 | MSYS* | MINGW* ) msys=true ;; #(
112 | NONSTOP* ) nonstop=true ;;
113 | esac
114 |
115 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
116 |
117 |
118 | # Determine the Java command to use to start the JVM.
119 | if [ -n "$JAVA_HOME" ] ; then
120 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
121 | # IBM's JDK on AIX uses strange locations for the executables
122 | JAVACMD=$JAVA_HOME/jre/sh/java
123 | else
124 | JAVACMD=$JAVA_HOME/bin/java
125 | fi
126 | if [ ! -x "$JAVACMD" ] ; then
127 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
128 |
129 | Please set the JAVA_HOME variable in your environment to match the
130 | location of your Java installation."
131 | fi
132 | else
133 | JAVACMD=java
134 | if ! command -v java >/dev/null 2>&1
135 | then
136 | 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 | fi
142 |
143 | # Increase the maximum file descriptors if we can.
144 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
145 | case $MAX_FD in #(
146 | max*)
147 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
148 | # shellcheck disable=SC2039,SC3045
149 | MAX_FD=$( ulimit -H -n ) ||
150 | warn "Could not query maximum file descriptor limit"
151 | esac
152 | case $MAX_FD in #(
153 | '' | soft) :;; #(
154 | *)
155 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
156 | # shellcheck disable=SC2039,SC3045
157 | ulimit -n "$MAX_FD" ||
158 | warn "Could not set maximum file descriptor limit to $MAX_FD"
159 | esac
160 | fi
161 |
162 | # Collect all arguments for the java command, stacking in reverse order:
163 | # * args from the command line
164 | # * the main class name
165 | # * -classpath
166 | # * -D...appname settings
167 | # * --module-path (only if needed)
168 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
169 |
170 | # For Cygwin or MSYS, switch paths to Windows format before running java
171 | if "$cygwin" || "$msys" ; then
172 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
173 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
174 |
175 | JAVACMD=$( cygpath --unix "$JAVACMD" )
176 |
177 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
178 | for arg do
179 | if
180 | case $arg in #(
181 | -*) false ;; # don't mess with options #(
182 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
183 | [ -e "$t" ] ;; #(
184 | *) false ;;
185 | esac
186 | then
187 | arg=$( cygpath --path --ignore --mixed "$arg" )
188 | fi
189 | # Roll the args list around exactly as many times as the number of
190 | # args, so each arg winds up back in the position where it started, but
191 | # possibly modified.
192 | #
193 | # NB: a `for` loop captures its iteration list before it begins, so
194 | # changing the positional parameters here affects neither the number of
195 | # iterations, nor the values presented in `arg`.
196 | shift # remove old arg
197 | set -- "$@" "$arg" # push replacement arg
198 | done
199 | fi
200 |
201 |
202 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
203 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204 |
205 | # Collect all arguments for the java command:
206 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
207 | # and any embedded shellness will be escaped.
208 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209 | # treated as '${Hostname}' itself on the command line.
210 |
211 | set -- \
212 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
213 | -classpath "$CLASSPATH" \
214 | org.gradle.wrapper.GradleWrapperMain \
215 | "$@"
216 |
217 | # Stop when "xargs" is not available.
218 | if ! command -v xargs >/dev/null 2>&1
219 | then
220 | die "xargs is not available"
221 | fi
222 |
223 | # Use "xargs" to parse quoted args.
224 | #
225 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
226 | #
227 | # In Bash we could simply go:
228 | #
229 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
230 | # set -- "${ARGS[@]}" "$@"
231 | #
232 | # but POSIX shell has neither arrays nor command substitution, so instead we
233 | # post-process each arg (as a line of input to sed) to backslash-escape any
234 | # character that might be a shell metacharacter, then use eval to reverse
235 | # that process (while maintaining the separation between arguments), and wrap
236 | # the whole thing up as a single "set" statement.
237 | #
238 | # This will of course break if any of these variables contains a newline or
239 | # an unmatched quote.
240 | #
241 |
242 | eval "set -- $(
243 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
244 | xargs -n1 |
245 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
246 | tr '\n' ' '
247 | )" '"$@"'
248 |
249 | exec "$JAVACMD" "$@"
250 |
--------------------------------------------------------------------------------
/test/react_native/android/gradlew.bat:
--------------------------------------------------------------------------------
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 | @rem This is normally unused
30 | set APP_BASE_NAME=%~n0
31 | set APP_HOME=%DIRNAME%
32 |
33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
35 |
36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
38 |
39 | @rem Find java.exe
40 | if defined JAVA_HOME goto findJavaFromJavaHome
41 |
42 | set JAVA_EXE=java.exe
43 | %JAVA_EXE% -version >NUL 2>&1
44 | if %ERRORLEVEL% equ 0 goto execute
45 |
46 | echo. 1>&2
47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
48 | echo. 1>&2
49 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
50 | echo location of your Java installation. 1>&2
51 |
52 | goto fail
53 |
54 | :findJavaFromJavaHome
55 | set JAVA_HOME=%JAVA_HOME:"=%
56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
57 |
58 | if exist "%JAVA_EXE%" goto execute
59 |
60 | echo. 1>&2
61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
62 | echo. 1>&2
63 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
64 | echo location of your Java installation. 1>&2
65 |
66 | goto fail
67 |
68 | :execute
69 | @rem Setup the command line
70 |
71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
72 |
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if %ERRORLEVEL% equ 0 goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | set EXIT_CODE=%ERRORLEVEL%
85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
87 | exit /b %EXIT_CODE%
88 |
89 | :mainEnd
90 | if "%OS%"=="Windows_NT" endlocal
91 |
92 | :omega
93 |
--------------------------------------------------------------------------------
/test/react_native/android/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement { includeBuild("../node_modules/@react-native/gradle-plugin") }
2 | plugins { id("com.facebook.react.settings") }
3 | extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() }
4 | rootProject.name = 'react_native'
5 | include ':app'
6 | includeBuild('../node_modules/@react-native/gradle-plugin')
7 |
--------------------------------------------------------------------------------
/test/react_native/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react_native",
3 | "displayName": "react_native"
4 | }
5 |
--------------------------------------------------------------------------------
/test/react_native/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: ['module:@react-native/babel-preset'],
3 | plugins: [
4 | [
5 | 'module:react-native-dotenv',
6 | {
7 | moduleName: '@env',
8 | path: '.env',
9 | blocklist: null, // or use "blacklist"
10 | allowlist: null, // or use "whitelist"
11 | safe: false,
12 | allowUndefined: true,
13 | },
14 | ],
15 | // Include other plugins if necessary
16 | ],
17 | };
18 |
--------------------------------------------------------------------------------
/test/react_native/env.d.ts:
--------------------------------------------------------------------------------
1 | declare module '@env' {
2 | export const WORKSPACE_KEY: string;
3 | }
4 |
--------------------------------------------------------------------------------
/test/react_native/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @format
3 | */
4 |
5 | import {AppRegistry} from 'react-native';
6 | import App from './App';
7 | import {name as appName} from './app.json';
8 |
9 | AppRegistry.registerComponent(appName, () => App);
10 |
--------------------------------------------------------------------------------
/test/react_native/ios/.xcode.env:
--------------------------------------------------------------------------------
1 | # This `.xcode.env` file is versioned and is used to source the environment
2 | # used when running script phases inside Xcode.
3 | # To customize your local environment, you can create an `.xcode.env.local`
4 | # file that is not versioned.
5 |
6 | # NODE_BINARY variable contains the PATH to the node executable.
7 | #
8 | # Customize the NODE_BINARY variable here.
9 | # For example, to use nvm with brew, add the following line
10 | # . "$(brew --prefix nvm)/nvm.sh" --no-use
11 | export NODE_BINARY=$(command -v node)
12 |
--------------------------------------------------------------------------------
/test/react_native/ios/Podfile:
--------------------------------------------------------------------------------
1 | # Resolve react_native_pods.rb with node to allow for hoisting
2 | require Pod::Executable.execute_command('node', ['-p',
3 | 'require.resolve(
4 | "react-native/scripts/react_native_pods.rb",
5 | {paths: [process.argv[1]]},
6 | )', __dir__]).strip
7 |
8 | platform :ios, min_ios_version_supported
9 | prepare_react_native_project!
10 |
11 | linkage = ENV['USE_FRAMEWORKS']
12 | if linkage != nil
13 | Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
14 | use_frameworks! :linkage => linkage.to_sym
15 | end
16 |
17 | target 'react_native' do
18 | config = use_native_modules!
19 |
20 | use_react_native!(
21 | :path => config[:reactNativePath],
22 | # An absolute path to your application root.
23 | :app_path => "#{Pod::Config.instance.installation_root}/.."
24 | )
25 |
26 | target 'react_nativeTests' do
27 | inherit! :complete
28 | # Pods for testing
29 | end
30 |
31 | post_install do |installer|
32 | # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
33 | react_native_post_install(
34 | installer,
35 | config[:reactNativePath],
36 | :mac_catalyst_enabled => false,
37 | # :ccache_enabled => true
38 | )
39 | end
40 | end
41 |
--------------------------------------------------------------------------------
/test/react_native/ios/react_native.xcodeproj/xcshareddata/xcschemes/react_native.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
53 |
55 |
61 |
62 |
63 |
64 |
70 |
72 |
78 |
79 |
80 |
81 |
83 |
84 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/test/react_native/ios/react_native.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/test/react_native/ios/react_native/AppDelegate.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | @interface AppDelegate : RCTAppDelegate
5 |
6 | @end
7 |
--------------------------------------------------------------------------------
/test/react_native/ios/react_native/AppDelegate.mm:
--------------------------------------------------------------------------------
1 | #import "AppDelegate.h"
2 |
3 | #import
4 |
5 | @implementation AppDelegate
6 |
7 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
8 | {
9 | self.moduleName = @"react_native";
10 | // You can add your custom initial props in the dictionary below.
11 | // They will be passed down to the ViewController used by React Native.
12 | self.initialProps = @{};
13 |
14 | return [super application:application didFinishLaunchingWithOptions:launchOptions];
15 | }
16 |
17 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
18 | {
19 | return [self bundleURL];
20 | }
21 |
22 | - (NSURL *)bundleURL
23 | {
24 | #if DEBUG
25 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
26 | #else
27 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
28 | #endif
29 | }
30 |
31 | @end
32 |
--------------------------------------------------------------------------------
/test/react_native/ios/react_native/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "scale" : "2x",
6 | "size" : "20x20"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "scale" : "3x",
11 | "size" : "20x20"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "scale" : "2x",
16 | "size" : "29x29"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "scale" : "3x",
21 | "size" : "29x29"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "scale" : "2x",
26 | "size" : "40x40"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "scale" : "3x",
31 | "size" : "40x40"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "scale" : "2x",
36 | "size" : "60x60"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "scale" : "3x",
41 | "size" : "60x60"
42 | },
43 | {
44 | "idiom" : "ios-marketing",
45 | "scale" : "1x",
46 | "size" : "1024x1024"
47 | }
48 | ],
49 | "info" : {
50 | "author" : "xcode",
51 | "version" : 1
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/test/react_native/ios/react_native/Images.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/test/react_native/ios/react_native/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | react_native
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | $(MARKETING_VERSION)
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | $(CURRENT_PROJECT_VERSION)
25 | LSRequiresIPhoneOS
26 |
27 | NSAppTransportSecurity
28 |
29 | NSAllowsArbitraryLoads
30 |
31 | NSAllowsLocalNetworking
32 |
33 |
34 | NSLocationWhenInUseUsageDescription
35 |
36 | UILaunchStoryboardName
37 | LaunchScreen
38 | UIRequiredDeviceCapabilities
39 |
40 | arm64
41 |
42 | UISupportedInterfaceOrientations
43 |
44 | UIInterfaceOrientationPortrait
45 | UIInterfaceOrientationLandscapeLeft
46 | UIInterfaceOrientationLandscapeRight
47 |
48 | UIViewControllerBasedStatusBarAppearance
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/test/react_native/ios/react_native/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
24 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/test/react_native/ios/react_native/PrivacyInfo.xcprivacy:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NSPrivacyAccessedAPITypes
6 |
7 |
8 | NSPrivacyAccessedAPIType
9 | NSPrivacyAccessedAPICategoryFileTimestamp
10 | NSPrivacyAccessedAPITypeReasons
11 |
12 | C617.1
13 |
14 |
15 |
16 | NSPrivacyAccessedAPIType
17 | NSPrivacyAccessedAPICategoryUserDefaults
18 | NSPrivacyAccessedAPITypeReasons
19 |
20 | CA92.1
21 |
22 |
23 |
24 | NSPrivacyAccessedAPIType
25 | NSPrivacyAccessedAPICategorySystemBootTime
26 | NSPrivacyAccessedAPITypeReasons
27 |
28 | 35F9.1
29 |
30 |
31 |
32 | NSPrivacyCollectedDataTypes
33 |
34 | NSPrivacyTracking
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/test/react_native/ios/react_native/main.m:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | #import "AppDelegate.h"
4 |
5 | int main(int argc, char *argv[])
6 | {
7 | @autoreleasepool {
8 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/test/react_native/ios/react_nativeTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/test/react_native/ios/react_nativeTests/react_nativeTests.m:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | #import
5 | #import
6 |
7 | #define TIMEOUT_SECONDS 600
8 | #define TEXT_TO_LOOK_FOR @"Welcome to React"
9 |
10 | @interface react_nativeTests : XCTestCase
11 |
12 | @end
13 |
14 | @implementation react_nativeTests
15 |
16 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL (^)(UIView *view))test
17 | {
18 | if (test(view)) {
19 | return YES;
20 | }
21 | for (UIView *subview in [view subviews]) {
22 | if ([self findSubviewInView:subview matching:test]) {
23 | return YES;
24 | }
25 | }
26 | return NO;
27 | }
28 |
29 | - (void)testRendersWelcomeScreen
30 | {
31 | UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController];
32 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS];
33 | BOOL foundElement = NO;
34 |
35 | __block NSString *redboxError = nil;
36 | #ifdef DEBUG
37 | RCTSetLogFunction(
38 | ^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) {
39 | if (level >= RCTLogLevelError) {
40 | redboxError = message;
41 | }
42 | });
43 | #endif
44 |
45 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) {
46 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
47 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
48 |
49 | foundElement = [self findSubviewInView:vc.view
50 | matching:^BOOL(UIView *view) {
51 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) {
52 | return YES;
53 | }
54 | return NO;
55 | }];
56 | }
57 |
58 | #ifdef DEBUG
59 | RCTSetLogFunction(RCTDefaultLogFunction);
60 | #endif
61 |
62 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError);
63 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS);
64 | }
65 |
66 | @end
67 |
--------------------------------------------------------------------------------
/test/react_native/metro.config.js:
--------------------------------------------------------------------------------
1 | const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
2 |
3 | /**
4 | * Metro configuration
5 | * https://reactnative.dev/docs/metro
6 | *
7 | * @type {import('metro-config').MetroConfig}
8 | */
9 | const config = {};
10 |
11 | module.exports = mergeConfig(getDefaultConfig(__dirname), config);
--------------------------------------------------------------------------------
/test/react_native/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react_native",
3 | "version": "0.0.1",
4 | "private": true,
5 | "scripts": {
6 | "android": "react-native run-android",
7 | "ios": "react-native run-ios",
8 | "lint": "eslint .",
9 | "start": "react-native start",
10 | "test": "jest"
11 | },
12 | "dependencies": {
13 | "@survicate/react-native-survicate": "^5.3.0",
14 | "react": "18.3.1",
15 | "react-native": "0.75.2"
16 | },
17 | "devDependencies": {
18 | "@babel/core": "^7.20.0",
19 | "@babel/preset-env": "^7.20.0",
20 | "@babel/runtime": "^7.20.0",
21 | "@react-native/babel-preset": "0.75.2",
22 | "@react-native/metro-config": "0.75.2",
23 | "@react-native/typescript-config": "0.75.2",
24 | "react-native-builder-bob": "^0.30.0",
25 | "react-native-dotenv": "^3.4.11"
26 | },
27 | "engines": {
28 | "node": ">=18"
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/test/react_native/react-native.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | // other fields
3 | dependency: {
4 | ...(process.env.NO_FLIPPER
5 | ? {'react-native-flipper': {platforms: {ios: null}}}
6 | : {}),
7 | },
8 | };
--------------------------------------------------------------------------------
/tsconfig.build.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig",
3 | "exclude": ["**/NativeSurvicateModule.ts", "lib", "example", "test"],
4 | }
5 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "baseUrl": ".",
4 | "paths": {
5 | "@survicate/react-native-survicate": ["./src/index"]
6 | },
7 | "allowUnreachableCode": false,
8 | "allowUnusedLabels": false,
9 | "esModuleInterop": true,
10 | "forceConsistentCasingInFileNames": true,
11 | "jsx": "react",
12 | "lib": ["esnext"],
13 | "module": "esnext",
14 | "moduleResolution": "node",
15 | "noFallthroughCasesInSwitch": true,
16 | "noImplicitReturns": true,
17 | "noImplicitUseStrict": false,
18 | "noStrictGenericChecks": false,
19 | "noUnusedLocals": true,
20 | "noUnusedParameters": true,
21 | "resolveJsonModule": true,
22 | "skipLibCheck": true,
23 | "strict": true,
24 | "target": "esnext"
25 | },
26 | }
27 |
--------------------------------------------------------------------------------