├── .circleci └── config.yml ├── .editorconfig ├── .gitattributes ├── .gitignore ├── .husky ├── .npmignore ├── commit-msg └── pre-commit ├── .yarnrc ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── android ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── com │ └── reactnativegleapsdk │ ├── GleapUtil.java │ ├── GleapsdkModule.java │ ├── GleapsdkPackage.java │ └── NoUiThreadException.java ├── babel.config.js ├── example ├── .bundle │ └── config ├── .eslintrc.js ├── .gitignore ├── .node-version ├── .prettierrc.js ├── .watchmanconfig ├── App.tsx ├── Gemfile ├── Gemfile.lock ├── __tests__ │ └── App-test.tsx ├── android │ ├── app │ │ ├── build.gradle │ │ ├── debug.keystore │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── debug │ │ │ ├── AndroidManifest.xml │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── gleapexample │ │ │ │ └── ReactNativeFlipper.java │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── gleapexample │ │ │ │ │ ├── MainActivity.java │ │ │ │ │ └── MainApplication.java │ │ │ └── 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 │ │ │ └── release │ │ │ └── java │ │ │ └── com │ │ │ └── gleapexample │ │ │ └── ReactNativeFlipper.java │ ├── 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 │ ├── GleapExample.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── GleapExample.xcscheme │ ├── GleapExample.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── GleapExample │ │ ├── AppDelegate.h │ │ ├── AppDelegate.mm │ │ ├── Images.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ └── Contents.json │ │ ├── Info.plist │ │ ├── LaunchScreen.storyboard │ │ └── main.m │ ├── GleapExampleTests │ │ ├── GleapExampleTests.m │ │ └── Info.plist │ ├── Podfile │ └── Podfile.lock ├── metro.config.js ├── package-lock.json ├── package.json └── tsconfig.json ├── ios ├── Gleapsdk.h ├── Gleapsdk.m └── Gleapsdk.xcodeproj │ └── project.pbxproj ├── package-lock.json ├── package.json ├── react-native-gleapsdk.podspec ├── scripts └── bootstrap.js ├── src ├── __tests__ │ └── index.test.tsx ├── index.tsx └── networklogger.ts ├── tsconfig.build.json └── tsconfig.json /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | 3 | executors: 4 | default: 5 | docker: 6 | - image: circleci/node:10 7 | working_directory: ~/project 8 | 9 | commands: 10 | attach_project: 11 | steps: 12 | - attach_workspace: 13 | at: ~/project 14 | 15 | jobs: 16 | install-dependencies: 17 | executor: default 18 | steps: 19 | - checkout 20 | - attach_project 21 | - restore_cache: 22 | keys: 23 | - dependencies-{{ checksum "package.json" }} 24 | - dependencies- 25 | - restore_cache: 26 | keys: 27 | - dependencies-example-{{ checksum "example/package.json" }} 28 | - dependencies-example- 29 | - run: 30 | name: Install dependencies 31 | command: | 32 | yarn install --cwd example --frozen-lockfile 33 | yarn install --frozen-lockfile 34 | - save_cache: 35 | key: dependencies-{{ checksum "package.json" }} 36 | paths: node_modules 37 | - save_cache: 38 | key: dependencies-example-{{ checksum "example/package.json" }} 39 | paths: example/node_modules 40 | - persist_to_workspace: 41 | root: . 42 | paths: . 43 | 44 | lint: 45 | executor: default 46 | steps: 47 | - attach_project 48 | - run: 49 | name: Lint files 50 | command: | 51 | yarn lint 52 | 53 | typescript: 54 | executor: default 55 | steps: 56 | - attach_project 57 | - run: 58 | name: Typecheck files 59 | command: | 60 | yarn typescript 61 | 62 | unit-tests: 63 | executor: default 64 | steps: 65 | - attach_project 66 | - run: 67 | name: Run unit tests 68 | command: | 69 | yarn test --coverage 70 | - store_artifacts: 71 | path: coverage 72 | destination: coverage 73 | 74 | build-package: 75 | executor: default 76 | steps: 77 | - attach_project 78 | - run: 79 | name: Build package 80 | command: | 81 | yarn prepare 82 | 83 | workflows: 84 | build-and-test: 85 | jobs: 86 | - install-dependencies 87 | - lint: 88 | requires: 89 | - install-dependencies 90 | - typescript: 91 | requires: 92 | - install-dependencies 93 | - unit-tests: 94 | requires: 95 | - install-dependencies 96 | - build-package: 97 | requires: 98 | - install-dependencies 99 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | [*] 8 | 9 | indent_style = space 10 | indent_size = 2 11 | 12 | end_of_line = lf 13 | charset = utf-8 14 | trim_trailing_whitespace = true 15 | insert_final_newline = true 16 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | # specific for windows script files 3 | *.bat text eol=crlf -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # XDE 6 | .expo/ 7 | 8 | # VSCode 9 | .vscode/ 10 | jsconfig.json 11 | 12 | # Xcode 13 | # 14 | build/ 15 | *.pbxuser 16 | !default.pbxuser 17 | *.mode1v3 18 | !default.mode1v3 19 | *.mode2v3 20 | !default.mode2v3 21 | *.perspectivev3 22 | !default.perspectivev3 23 | xcuserdata 24 | *.xccheckout 25 | *.moved-aside 26 | DerivedData 27 | *.hmap 28 | *.ipa 29 | *.xcuserstate 30 | project.xcworkspace 31 | 32 | # Android/IJ 33 | # 34 | .classpath 35 | .cxx 36 | .gradle 37 | .idea 38 | .project 39 | .settings 40 | local.properties 41 | android.iml 42 | 43 | # Cocoapods 44 | # 45 | example/ios/Pods 46 | 47 | # node.js 48 | # 49 | node_modules/ 50 | npm-debug.log 51 | yarn-debug.log 52 | yarn-error.log 53 | 54 | # BUCK 55 | buck-out/ 56 | \.buckd/ 57 | android/app/libs 58 | android/keystores/debug.keystore 59 | 60 | # Expo 61 | .expo/* 62 | 63 | # generated by bob 64 | lib/ 65 | -------------------------------------------------------------------------------- /.husky/.npmignore: -------------------------------------------------------------------------------- 1 | _ 2 | -------------------------------------------------------------------------------- /.husky/commit-msg: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | yarn commitlint -E HUSKY_GIT_PARAMS 5 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | yarn lint && yarn typescript 5 | -------------------------------------------------------------------------------- /.yarnrc: -------------------------------------------------------------------------------- 1 | # Override Yarn command so we can automatically setup the repo on running `yarn` 2 | 3 | yarn-path "scripts/bootstrap.js" 4 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | We want this community to be friendly and respectful to each other. Please follow it in all your interactions with the project. 4 | 5 | ## Development workflow 6 | 7 | To get started with the project, run `yarn` in the root directory to install the required dependencies for each package: 8 | 9 | ```sh 10 | yarn 11 | ``` 12 | 13 | > While it's possible to use [`npm`](https://github.com/npm/cli), the tooling is built around [`yarn`](https://classic.yarnpkg.com/), so you'll have an easier time if you use `yarn` for development. 14 | 15 | While developing, you can run the [example app](/example/) to test your changes. Any changes you make in your library's JavaScript code will be reflected in the example app without a rebuild. If you change any native code, then you'll need to rebuild the example app. 16 | 17 | To start the packager: 18 | 19 | ```sh 20 | yarn example start 21 | ``` 22 | 23 | To run the example app on Android: 24 | 25 | ```sh 26 | yarn example android 27 | ``` 28 | 29 | To run the example app on iOS: 30 | 31 | ```sh 32 | yarn example ios 33 | ``` 34 | 35 | Make sure your code passes TypeScript and ESLint. Run the following to verify: 36 | 37 | ```sh 38 | yarn typescript 39 | yarn lint 40 | ``` 41 | 42 | To fix formatting errors, run the following: 43 | 44 | ```sh 45 | yarn lint --fix 46 | ``` 47 | 48 | Remember to add tests for your change if possible. Run the unit tests by: 49 | 50 | ```sh 51 | yarn test 52 | ``` 53 | 54 | To edit the Objective-C files, open `example/ios/GleapsdkExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > react-native-gleapsdk`. 55 | 56 | To edit the Kotlin files, open `example/android` in Android studio and find the source files at `reactnativegleapsdk` under `Android`. 57 | 58 | ### Commit message convention 59 | 60 | We follow the [conventional commits specification](https://www.conventionalcommits.org/en) for our commit messages: 61 | 62 | - `fix`: bug fixes, e.g. fix crash due to deprecated method. 63 | - `feat`: new features, e.g. add new method to the module. 64 | - `refactor`: code refactor, e.g. migrate from class components to hooks. 65 | - `docs`: changes into documentation, e.g. add usage example for the module.. 66 | - `test`: adding or updating tests, e.g. add integration tests using detox. 67 | - `chore`: tooling changes, e.g. change CI config. 68 | 69 | Our pre-commit hooks verify that your commit message matches this format when committing. 70 | 71 | ### Linting and tests 72 | 73 | [ESLint](https://eslint.org/), [Prettier](https://prettier.io/), [TypeScript](https://www.typescriptlang.org/) 74 | 75 | We use [TypeScript](https://www.typescriptlang.org/) for type checking, [ESLint](https://eslint.org/) with [Prettier](https://prettier.io/) for linting and formatting the code, and [Jest](https://jestjs.io/) for testing. 76 | 77 | Our pre-commit hooks verify that the linter and tests pass when committing. 78 | 79 | ### Publishing to npm 80 | 81 | We use [release-it](https://github.com/release-it/release-it) to make it easier to publish new versions. It handles common tasks like bumping version based on semver, creating tags and releases etc. 82 | 83 | To publish new versions, run the following: 84 | 85 | ```sh 86 | yarn release 87 | ``` 88 | 89 | ### Scripts 90 | 91 | The `package.json` file contains various scripts for common tasks: 92 | 93 | - `yarn bootstrap`: setup project by installing all dependencies and pods. 94 | - `yarn typescript`: type-check files with TypeScript. 95 | - `yarn lint`: lint files with ESLint. 96 | - `yarn test`: run unit tests with Jest. 97 | - `yarn example start`: start the Metro server for the example app. 98 | - `yarn example android`: run the example app on Android. 99 | - `yarn example ios`: run the example app on iOS. 100 | 101 | ### Sending a pull request 102 | 103 | > **Working on your first pull request?** You can learn how from this _free_ series: [How to Contribute to an Open Source Project on GitHub](https://app.egghead.io/playlists/how-to-contribute-to-an-open-source-project-on-github). 104 | 105 | When you're sending a pull request: 106 | 107 | - Prefer small pull requests focused on one change. 108 | - Verify that linters and tests are passing. 109 | - Review the documentation to make sure it looks good. 110 | - Follow the pull request template when opening a pull request. 111 | - For pull requests that change the API or implementation, discuss with maintainers first by opening an issue. 112 | 113 | ## Code of Conduct 114 | 115 | ### Our Pledge 116 | 117 | We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. 118 | 119 | We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. 120 | 121 | ### Our Standards 122 | 123 | Examples of behavior that contributes to a positive environment for our community include: 124 | 125 | - Demonstrating empathy and kindness toward other people 126 | - Being respectful of differing opinions, viewpoints, and experiences 127 | - Giving and gracefully accepting constructive feedback 128 | - Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience 129 | - Focusing on what is best not just for us as individuals, but for the overall community 130 | 131 | Examples of unacceptable behavior include: 132 | 133 | - The use of sexualized language or imagery, and sexual attention or 134 | advances of any kind 135 | - Trolling, insulting or derogatory comments, and personal or political attacks 136 | - Public or private harassment 137 | - Publishing others' private information, such as a physical or email 138 | address, without their explicit permission 139 | - Other conduct which could reasonably be considered inappropriate in a 140 | professional setting 141 | 142 | ### Enforcement Responsibilities 143 | 144 | Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. 145 | 146 | Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. 147 | 148 | ### Scope 149 | 150 | This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. 151 | 152 | ### Enforcement 153 | 154 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [INSERT CONTACT METHOD]. All complaints will be reviewed and investigated promptly and fairly. 155 | 156 | All community leaders are obligated to respect the privacy and security of the reporter of any incident. 157 | 158 | ### Enforcement Guidelines 159 | 160 | Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: 161 | 162 | #### 1. Correction 163 | 164 | **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. 165 | 166 | **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. 167 | 168 | #### 2. Warning 169 | 170 | **Community Impact**: A violation through a single incident or series of actions. 171 | 172 | **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. 173 | 174 | #### 3. Temporary Ban 175 | 176 | **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. 177 | 178 | **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. 179 | 180 | #### 4. Permanent Ban 181 | 182 | **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. 183 | 184 | **Consequence**: A permanent ban from any sort of public interaction within the community. 185 | 186 | ### Attribution 187 | 188 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, 189 | available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 190 | 191 | Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). 192 | 193 | [homepage]: https://www.contributor-covenant.org 194 | 195 | For answers to common questions about this code of conduct, see the FAQ at 196 | https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations. 197 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2020 by Gleap GmbH. Permission is hereby granted to use this framework as is, modification are not allowed. All rights reserved. 2 | 3 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. FURTHER RESELLING OF THE SDK OR IT'S CODE IS ONLY GRANTED WITH A WRITTEN PERMISSION BY GLEAP GMBH. 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Gleap ReactNative SDK 2 | 3 | ![Gleap ReactNative SDK Intro](https://raw.githubusercontent.com/GleapSDK/Gleap-iOS-SDK/main/Resources/GleapHeaderImage.png) 4 | 5 | The Gleap SDK for ReactNative is the easiest way to integrate Gleap into your apps! 6 | 7 | You have two ways to set up the Gleap SDK for ReactNative. The easiest way ist to use the maven repository to add Gleap SDK to your project. (it's super easy to get started & worth using 😍) 8 | 9 | ## Installation 10 | 11 | ```sh 12 | npm install react-native-gleapsdk 13 | ``` 14 | 15 | ## Usage 16 | 17 | ```js 18 | // Import the SDK 19 | import Gleap from "react-native-gleapsdk"; 20 | 21 | // Initialize it 22 | Gleap.initialize('YOUR_API_KEY'); 23 | ``` 24 | 25 | ## Need help? 26 | 27 | Checkout our full [documentation](https://docs.gleap.io/reactnative) or [contact us](https://gleap.io/) - we are always here to help 👋. 28 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | if (project == rootProject) { 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.5.4' 10 | } 11 | } 12 | } 13 | 14 | apply plugin: 'com.android.library' 15 | 16 | def safeExtGet(prop, fallback) { 17 | rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback 18 | } 19 | 20 | android { 21 | def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION 22 | if (agpVersion.tokenize('.')[0].toInteger() >= 7) { 23 | namespace = "com.reactnativegleapsdk" 24 | } 25 | 26 | compileSdkVersion safeExtGet('Gleapsdk_compileSdkVersion', 33) 27 | defaultConfig { 28 | minSdkVersion safeExtGet('Gleapsdk_minSdkVersion', 21) 29 | targetSdkVersion safeExtGet('Gleapsdk_targetSdkVersion', 33) 30 | 31 | } 32 | 33 | buildTypes { 34 | release { 35 | minifyEnabled false 36 | } 37 | } 38 | lintOptions { 39 | disable 'GradleCompatible' 40 | } 41 | compileOptions { 42 | sourceCompatibility JavaVersion.VERSION_1_8 43 | targetCompatibility JavaVersion.VERSION_1_8 44 | } 45 | } 46 | 47 | repositories { 48 | mavenLocal() 49 | maven { 50 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 51 | url("$rootDir/../node_modules/react-native/android") 52 | } 53 | google() 54 | mavenCentral() 55 | } 56 | 57 | dependencies { 58 | implementation "com.facebook.react:react-native:+" 59 | implementation group: 'io.gleap', name: 'gleap-android-sdk', version: '14.6.3' 60 | 61 | if(rootProject && rootProject.ext) { 62 | if(rootProject.ext.targetSdkVersion == 30 || rootProject.ext.compileSdkVersion == 30) { 63 | implementation( "androidx.appcompat:appcompat:1.3.0") { 64 | force = true 65 | } 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GleapSDK/ReactNative-SDK/5025a2793cfa97ef3c8bf0f7f836e8061a260e4d/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-6.8-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or 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 UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /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%" == "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%"=="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 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /android/src/main/java/com/reactnativegleapsdk/GleapUtil.java: -------------------------------------------------------------------------------- 1 | package com.reactnativegleapsdk; 2 | 3 | import com.facebook.react.bridge.ReadableArray; 4 | import com.facebook.react.bridge.ReadableMap; 5 | import com.facebook.react.bridge.ReadableMapKeySetIterator; 6 | 7 | import org.json.JSONArray; 8 | import org.json.JSONException; 9 | import org.json.JSONObject; 10 | 11 | public class GleapUtil { 12 | protected static JSONObject convertMapToJson(ReadableMap readableMap) throws JSONException { 13 | JSONObject object = new JSONObject(); 14 | ReadableMapKeySetIterator iterator = readableMap.keySetIterator(); 15 | while (iterator.hasNextKey()) { 16 | String key = iterator.nextKey(); 17 | switch (readableMap.getType(key)) { 18 | case Null: 19 | object.put(key, JSONObject.NULL); 20 | break; 21 | case Boolean: 22 | object.put(key, readableMap.getBoolean(key)); 23 | break; 24 | case Number: 25 | object.put(key, readableMap.getDouble(key)); 26 | break; 27 | case String: 28 | object.put(key, readableMap.getString(key)); 29 | break; 30 | case Map: 31 | object.put(key, convertMapToJson(readableMap.getMap(key))); 32 | break; 33 | case Array: 34 | object.put(key, convertArrayToJson(readableMap.getArray(key))); 35 | break; 36 | } 37 | } 38 | return object; 39 | } 40 | 41 | protected static JSONArray convertArrayToJson(ReadableArray readableArray) throws JSONException { 42 | JSONArray array = new JSONArray(); 43 | for (int i = 0; i < readableArray.size(); i++) { 44 | switch (readableArray.getType(i)) { 45 | case Null: 46 | break; 47 | case Boolean: 48 | array.put(readableArray.getBoolean(i)); 49 | break; 50 | case Number: 51 | array.put(readableArray.getDouble(i)); 52 | break; 53 | case String: 54 | array.put(readableArray.getString(i)); 55 | break; 56 | case Map: 57 | array.put(convertMapToJson(readableArray.getMap(i))); 58 | break; 59 | case Array: 60 | array.put(convertArrayToJson(readableArray.getArray(i))); 61 | break; 62 | } 63 | } 64 | return array; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /android/src/main/java/com/reactnativegleapsdk/GleapsdkPackage.java: -------------------------------------------------------------------------------- 1 | package com.reactnativegleapsdk; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | import com.facebook.react.ReactPackage; 6 | import com.facebook.react.bridge.NativeModule; 7 | import com.facebook.react.bridge.ReactApplicationContext; 8 | import com.facebook.react.uimanager.ViewManager; 9 | 10 | import java.util.ArrayList; 11 | import java.util.Collections; 12 | import java.util.List; 13 | 14 | public class GleapsdkPackage implements ReactPackage { 15 | @NonNull 16 | @Override 17 | public List createNativeModules(@NonNull ReactApplicationContext reactContext) { 18 | List modules = new ArrayList<>(); 19 | modules.add(new GleapsdkModule(reactContext)); 20 | return modules; 21 | } 22 | 23 | @NonNull 24 | @Override 25 | public List createViewManagers(@NonNull ReactApplicationContext reactContext) { 26 | return Collections.emptyList(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /android/src/main/java/com/reactnativegleapsdk/NoUiThreadException.java: -------------------------------------------------------------------------------- 1 | package com.reactnativegleapsdk; 2 | 3 | public class NoUiThreadException extends Exception{ 4 | public NoUiThreadException() { 5 | super("No ui thread found. Please be careful when initialising the sdk."); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['module:metro-react-native-babel-preset'], 3 | }; 4 | -------------------------------------------------------------------------------- /example/.bundle/config: -------------------------------------------------------------------------------- 1 | BUNDLE_PATH: "vendor/bundle" 2 | BUNDLE_FORCE_RUBY_PLATFORM: 1 3 | -------------------------------------------------------------------------------- /example/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: '@react-native-community', 4 | }; 5 | -------------------------------------------------------------------------------- /example/.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 | ios/.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 | # fastlane 44 | # 45 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 46 | # screenshots whenever they are needed. 47 | # For more information about the recommended setup visit: 48 | # https://docs.fastlane.tools/best-practices/source-control/ 49 | 50 | **/fastlane/report.xml 51 | **/fastlane/Preview.html 52 | **/fastlane/screenshots 53 | **/fastlane/test_output 54 | 55 | # Bundle artifact 56 | *.jsbundle 57 | 58 | # Ruby / CocoaPods 59 | /ios/Pods/ 60 | /vendor/bundle/ 61 | 62 | # Temporary files created by Metro to check the health of the file watcher 63 | .metro-health-check* 64 | -------------------------------------------------------------------------------- /example/.node-version: -------------------------------------------------------------------------------- 1 | 18 2 | -------------------------------------------------------------------------------- /example/.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | arrowParens: 'avoid', 3 | bracketSameLine: true, 4 | bracketSpacing: false, 5 | singleQuote: true, 6 | trailingComma: 'all', 7 | }; 8 | -------------------------------------------------------------------------------- /example/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /example/App.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * Sample React Native App 3 | * https://github.com/facebook/react-native 4 | * 5 | * @format 6 | */ 7 | 8 | import React from 'react'; 9 | import type {PropsWithChildren} from 'react'; 10 | import { 11 | SafeAreaView, 12 | ScrollView, 13 | StatusBar, 14 | StyleSheet, 15 | Text, 16 | TouchableHighlight, 17 | useColorScheme, 18 | View, 19 | } from 'react-native'; 20 | import { 21 | Colors, 22 | DebugInstructions, 23 | Header, 24 | LearnMoreLinks, 25 | ReloadInstructions, 26 | } from 'react-native/Libraries/NewAppScreen'; 27 | import Gleap from 'react-native-gleapsdk'; 28 | 29 | type SectionProps = PropsWithChildren<{ 30 | title: string; 31 | }>; 32 | 33 | function Section({children, title}: SectionProps): JSX.Element { 34 | const isDarkMode = useColorScheme() === 'dark'; 35 | return ( 36 | 37 | 44 | {title} 45 | 46 | 53 | {children} 54 | 55 | 56 | ); 57 | } 58 | 59 | function App(): JSX.Element { 60 | const isDarkMode = useColorScheme() === 'dark'; 61 | 62 | const backgroundStyle = { 63 | backgroundColor: isDarkMode ? Colors.darker : Colors.lighter, 64 | }; 65 | 66 | return ( 67 | 68 | 72 | 75 |
76 | 80 |
81 | Edit App.tsx to change this 82 | screen and then come back to see your edits. 83 | { 84 | Gleap.identify("testuser2222221", { 85 | name: "Lukas", 86 | email: "lukas2222@gleap.io", 87 | sla: 199, 88 | customData: { 89 | test1: "test1" 90 | } 91 | }) 92 | }}> 93 | IDENTY. 94 | 95 | { 96 | Gleap.updateContact({ 97 | name: "MAX!", 98 | customData: { 99 | test2: "test2222" 100 | } 101 | }) 102 | }}> 103 | UPDATE. 104 | 105 | { 106 | Gleap.clearIdentity(); 107 | }}> 108 | CLEAR! 109 | 110 |
111 |
112 | 113 |
114 |
115 | 116 |
117 |
118 | Read the docs to discover what to do next: 119 |
120 | 121 |
122 | 123 | 124 | ); 125 | } 126 | 127 | const styles = StyleSheet.create({ 128 | sectionContainer: { 129 | marginTop: 32, 130 | paddingHorizontal: 24, 131 | }, 132 | sectionTitle: { 133 | fontSize: 24, 134 | fontWeight: '600', 135 | }, 136 | sectionDescription: { 137 | marginTop: 8, 138 | fontSize: 18, 139 | fontWeight: '400', 140 | }, 141 | highlight: { 142 | fontWeight: '700', 143 | }, 144 | }); 145 | 146 | export default App; 147 | -------------------------------------------------------------------------------- /example/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 | gem 'cocoapods', '>= 1.11.3' 7 | -------------------------------------------------------------------------------- /example/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | CFPropertyList (3.0.6) 5 | rexml 6 | activesupport (6.1.7.3) 7 | concurrent-ruby (~> 1.0, >= 1.0.2) 8 | i18n (>= 1.6, < 2) 9 | minitest (>= 5.1) 10 | tzinfo (~> 2.0) 11 | zeitwerk (~> 2.3) 12 | addressable (2.8.4) 13 | public_suffix (>= 2.0.2, < 6.0) 14 | algoliasearch (1.27.5) 15 | httpclient (~> 2.8, >= 2.8.3) 16 | json (>= 1.5.1) 17 | atomos (0.1.3) 18 | claide (1.1.0) 19 | cocoapods (1.12.1) 20 | addressable (~> 2.8) 21 | claide (>= 1.0.2, < 2.0) 22 | cocoapods-core (= 1.12.1) 23 | cocoapods-deintegrate (>= 1.0.3, < 2.0) 24 | cocoapods-downloader (>= 1.6.0, < 2.0) 25 | cocoapods-plugins (>= 1.0.0, < 2.0) 26 | cocoapods-search (>= 1.0.0, < 2.0) 27 | cocoapods-trunk (>= 1.6.0, < 2.0) 28 | cocoapods-try (>= 1.1.0, < 2.0) 29 | colored2 (~> 3.1) 30 | escape (~> 0.0.4) 31 | fourflusher (>= 2.3.0, < 3.0) 32 | gh_inspector (~> 1.0) 33 | molinillo (~> 0.8.0) 34 | nap (~> 1.0) 35 | ruby-macho (>= 2.3.0, < 3.0) 36 | xcodeproj (>= 1.21.0, < 2.0) 37 | cocoapods-core (1.12.1) 38 | activesupport (>= 5.0, < 8) 39 | addressable (~> 2.8) 40 | algoliasearch (~> 1.0) 41 | concurrent-ruby (~> 1.1) 42 | fuzzy_match (~> 2.0.4) 43 | nap (~> 1.0) 44 | netrc (~> 0.11) 45 | public_suffix (~> 4.0) 46 | typhoeus (~> 1.0) 47 | cocoapods-deintegrate (1.0.5) 48 | cocoapods-downloader (1.6.3) 49 | cocoapods-plugins (1.0.0) 50 | nap 51 | cocoapods-search (1.0.1) 52 | cocoapods-trunk (1.6.0) 53 | nap (>= 0.8, < 2.0) 54 | netrc (~> 0.11) 55 | cocoapods-try (1.2.0) 56 | colored2 (3.1.2) 57 | concurrent-ruby (1.2.2) 58 | escape (0.0.4) 59 | ethon (0.16.0) 60 | ffi (>= 1.15.0) 61 | ffi (1.15.5) 62 | fourflusher (2.3.1) 63 | fuzzy_match (2.0.4) 64 | gh_inspector (1.1.3) 65 | httpclient (2.8.3) 66 | i18n (1.14.1) 67 | concurrent-ruby (~> 1.0) 68 | json (2.6.3) 69 | minitest (5.18.1) 70 | molinillo (0.8.0) 71 | nanaimo (0.3.0) 72 | nap (1.1.0) 73 | netrc (0.11.0) 74 | public_suffix (4.0.7) 75 | rexml (3.2.5) 76 | ruby-macho (2.5.1) 77 | typhoeus (1.4.0) 78 | ethon (>= 0.9.0) 79 | tzinfo (2.0.6) 80 | concurrent-ruby (~> 1.0) 81 | xcodeproj (1.22.0) 82 | CFPropertyList (>= 2.3.3, < 4.0) 83 | atomos (~> 0.1.3) 84 | claide (>= 1.0.2, < 2.0) 85 | colored2 (~> 3.1) 86 | nanaimo (~> 0.3.0) 87 | rexml (~> 3.2.4) 88 | zeitwerk (2.6.8) 89 | 90 | PLATFORMS 91 | ruby 92 | 93 | DEPENDENCIES 94 | cocoapods (>= 1.11.3) 95 | 96 | RUBY VERSION 97 | ruby 2.6.10p210 98 | 99 | BUNDLED WITH 100 | 1.17.2 101 | -------------------------------------------------------------------------------- /example/__tests__/App-test.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import 'react-native'; 6 | import React from 'react'; 7 | import App from '../App'; 8 | 9 | // Note: test renderer must be required after react-native. 10 | import renderer from 'react-test-renderer'; 11 | 12 | it('renders correctly', () => { 13 | renderer.create(); 14 | }); 15 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | apply plugin: "com.facebook.react" 3 | 4 | import com.android.build.OutputFile 5 | 6 | /** 7 | * This is the configuration block to customize your React Native Android app. 8 | * By default you don't need to apply any configuration, just uncomment the lines you need. 9 | */ 10 | react { 11 | /* Folders */ 12 | // The root of your project, i.e. where "package.json" lives. Default is '..' 13 | // root = file("../") 14 | // The folder where the react-native NPM package is. Default is ../node_modules/react-native 15 | // reactNativeDir = file("../node_modules/react-native") 16 | // The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen 17 | // codegenDir = file("../node_modules/react-native-codegen") 18 | // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js 19 | // cliFile = file("../node_modules/react-native/cli.js") 20 | 21 | /* Variants */ 22 | // The list of variants to that are debuggable. For those we're going to 23 | // skip the bundling of the JS bundle and the assets. By default is just 'debug'. 24 | // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants. 25 | // debuggableVariants = ["liteDebug", "prodDebug"] 26 | 27 | /* Bundling */ 28 | // A list containing the node command and its flags. Default is just 'node'. 29 | // nodeExecutableAndArgs = ["node"] 30 | // 31 | // The command to run when bundling. By default is 'bundle' 32 | // bundleCommand = "ram-bundle" 33 | // 34 | // The path to the CLI configuration file. Default is empty. 35 | // bundleConfig = file(../rn-cli.config.js) 36 | // 37 | // The name of the generated asset file containing your JS bundle 38 | // bundleAssetName = "MyApplication.android.bundle" 39 | // 40 | // The entry file for bundle generation. Default is 'index.android.js' or 'index.js' 41 | // entryFile = file("../js/MyApplication.android.js") 42 | // 43 | // A list of extra flags to pass to the 'bundle' commands. 44 | // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle 45 | // extraPackagerArgs = [] 46 | 47 | /* Hermes Commands */ 48 | // The hermes compiler command to run. By default it is 'hermesc' 49 | // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc" 50 | // 51 | // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map" 52 | // hermesFlags = ["-O", "-output-source-map"] 53 | } 54 | 55 | /** 56 | * Set this to true to create four separate APKs instead of one, 57 | * one for each native architecture. This is useful if you don't 58 | * use App Bundles (https://developer.android.com/guide/app-bundle/) 59 | * and want to have separate APKs to upload to the Play Store. 60 | */ 61 | def enableSeparateBuildPerCPUArchitecture = false 62 | 63 | /** 64 | * Set this to true to Run Proguard on Release builds to minify the Java bytecode. 65 | */ 66 | def enableProguardInReleaseBuilds = false 67 | 68 | /** 69 | * The preferred build flavor of JavaScriptCore (JSC) 70 | * 71 | * For example, to use the international variant, you can use: 72 | * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` 73 | * 74 | * The international variant includes ICU i18n library and necessary data 75 | * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that 76 | * give correct results when using with locales other than en-US. Note that 77 | * this variant is about 6MiB larger per architecture than default. 78 | */ 79 | def jscFlavor = 'org.webkit:android-jsc:+' 80 | 81 | /** 82 | * Private function to get the list of Native Architectures you want to build. 83 | * This reads the value from reactNativeArchitectures in your gradle.properties 84 | * file and works together with the --active-arch-only flag of react-native run-android. 85 | */ 86 | def reactNativeArchitectures() { 87 | def value = project.getProperties().get("reactNativeArchitectures") 88 | return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"] 89 | } 90 | 91 | android { 92 | ndkVersion rootProject.ext.ndkVersion 93 | 94 | compileSdkVersion rootProject.ext.compileSdkVersion 95 | 96 | namespace "com.gleapexample" 97 | defaultConfig { 98 | applicationId "com.gleapexample" 99 | minSdkVersion rootProject.ext.minSdkVersion 100 | targetSdkVersion rootProject.ext.targetSdkVersion 101 | versionCode 1 102 | versionName "1.0" 103 | } 104 | 105 | splits { 106 | abi { 107 | reset() 108 | enable enableSeparateBuildPerCPUArchitecture 109 | universalApk false // If true, also generate a universal APK 110 | include (*reactNativeArchitectures()) 111 | } 112 | } 113 | signingConfigs { 114 | debug { 115 | storeFile file('debug.keystore') 116 | storePassword 'android' 117 | keyAlias 'androiddebugkey' 118 | keyPassword 'android' 119 | } 120 | } 121 | buildTypes { 122 | debug { 123 | signingConfig signingConfigs.debug 124 | } 125 | release { 126 | // Caution! In production, you need to generate your own keystore file. 127 | // see https://reactnative.dev/docs/signed-apk-android. 128 | signingConfig signingConfigs.debug 129 | minifyEnabled enableProguardInReleaseBuilds 130 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 131 | } 132 | } 133 | 134 | // applicationVariants are e.g. debug, release 135 | applicationVariants.all { variant -> 136 | variant.outputs.each { output -> 137 | // For each separate APK per architecture, set a unique version code as described here: 138 | // https://developer.android.com/studio/build/configure-apk-splits.html 139 | // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc. 140 | def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] 141 | def abi = output.getFilter(OutputFile.ABI) 142 | if (abi != null) { // null for the universal-debug, universal-release variants 143 | output.versionCodeOverride = 144 | defaultConfig.versionCode * 1000 + versionCodes.get(abi) 145 | } 146 | 147 | } 148 | } 149 | } 150 | 151 | dependencies { 152 | // The version of react-native is set by the React Native Gradle Plugin 153 | implementation("com.facebook.react:react-android") 154 | 155 | implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0") 156 | 157 | debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") 158 | debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { 159 | exclude group:'com.squareup.okhttp3', module:'okhttp' 160 | } 161 | 162 | debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") 163 | if (hermesEnabled.toBoolean()) { 164 | implementation("com.facebook.react:hermes-android") 165 | } else { 166 | implementation jscFlavor 167 | } 168 | } 169 | 170 | apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) 171 | -------------------------------------------------------------------------------- /example/android/app/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GleapSDK/ReactNative-SDK/5025a2793cfa97ef3c8bf0f7f836e8061a260e4d/example/android/app/debug.keystore -------------------------------------------------------------------------------- /example/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/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /example/android/app/src/debug/java/com/gleapexample/ReactNativeFlipper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | *

This source code is licensed under the MIT license found in the LICENSE file in the root 5 | * directory of this source tree. 6 | */ 7 | package com.gleapexample; 8 | 9 | import android.content.Context; 10 | import com.facebook.flipper.android.AndroidFlipperClient; 11 | import com.facebook.flipper.android.utils.FlipperUtils; 12 | import com.facebook.flipper.core.FlipperClient; 13 | import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin; 14 | import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin; 15 | import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin; 16 | import com.facebook.flipper.plugins.inspector.DescriptorMapping; 17 | import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin; 18 | import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor; 19 | import com.facebook.flipper.plugins.network.NetworkFlipperPlugin; 20 | import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin; 21 | import com.facebook.react.ReactInstanceEventListener; 22 | import com.facebook.react.ReactInstanceManager; 23 | import com.facebook.react.bridge.ReactContext; 24 | import com.facebook.react.modules.network.NetworkingModule; 25 | import okhttp3.OkHttpClient; 26 | 27 | /** 28 | * Class responsible of loading Flipper inside your React Native application. This is the debug 29 | * flavor of it. Here you can add your own plugins and customize the Flipper setup. 30 | */ 31 | public class ReactNativeFlipper { 32 | public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { 33 | if (FlipperUtils.shouldEnableFlipper(context)) { 34 | final FlipperClient client = AndroidFlipperClient.getInstance(context); 35 | 36 | client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults())); 37 | client.addPlugin(new DatabasesFlipperPlugin(context)); 38 | client.addPlugin(new SharedPreferencesFlipperPlugin(context)); 39 | client.addPlugin(CrashReporterPlugin.getInstance()); 40 | 41 | NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin(); 42 | NetworkingModule.setCustomClientBuilder( 43 | new NetworkingModule.CustomClientBuilder() { 44 | @Override 45 | public void apply(OkHttpClient.Builder builder) { 46 | builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin)); 47 | } 48 | }); 49 | client.addPlugin(networkFlipperPlugin); 50 | client.start(); 51 | 52 | // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized 53 | // Hence we run if after all native modules have been initialized 54 | ReactContext reactContext = reactInstanceManager.getCurrentReactContext(); 55 | if (reactContext == null) { 56 | reactInstanceManager.addReactInstanceEventListener( 57 | new ReactInstanceEventListener() { 58 | @Override 59 | public void onReactContextInitialized(ReactContext reactContext) { 60 | reactInstanceManager.removeReactInstanceEventListener(this); 61 | reactContext.runOnNativeModulesQueueThread( 62 | new Runnable() { 63 | @Override 64 | public void run() { 65 | client.addPlugin(new FrescoFlipperPlugin()); 66 | } 67 | }); 68 | } 69 | }); 70 | } else { 71 | client.addPlugin(new FrescoFlipperPlugin()); 72 | } 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 12 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/gleapexample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.gleapexample; 2 | 3 | import com.facebook.react.ReactActivity; 4 | import com.facebook.react.ReactActivityDelegate; 5 | import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint; 6 | import com.facebook.react.defaults.DefaultReactActivityDelegate; 7 | 8 | public class MainActivity extends 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 15 | protected String getMainComponentName() { 16 | return "GleapExample"; 17 | } 18 | 19 | /** 20 | * Returns the instance of the {@link ReactActivityDelegate}. Here we use a util class {@link 21 | * DefaultReactActivityDelegate} which allows you to easily enable Fabric and Concurrent React 22 | * (aka React 18) with two boolean flags. 23 | */ 24 | @Override 25 | protected ReactActivityDelegate createReactActivityDelegate() { 26 | return new DefaultReactActivityDelegate( 27 | this, 28 | getMainComponentName(), 29 | // If you opted-in for the New Architecture, we enable the Fabric Renderer. 30 | DefaultNewArchitectureEntryPoint.getFabricEnabled(), // fabricEnabled 31 | // If you opted-in for the New Architecture, we enable Concurrent React (i.e. React 18). 32 | DefaultNewArchitectureEntryPoint.getConcurrentReactEnabled() // concurrentRootEnabled 33 | ); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/gleapexample/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.gleapexample; 2 | 3 | import android.app.Application; 4 | import com.facebook.react.PackageList; 5 | import com.facebook.react.ReactApplication; 6 | import com.facebook.react.ReactNativeHost; 7 | import com.facebook.react.ReactPackage; 8 | import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint; 9 | import com.facebook.react.defaults.DefaultReactNativeHost; 10 | import com.facebook.soloader.SoLoader; 11 | import java.util.List; 12 | 13 | public class MainApplication extends Application implements ReactApplication { 14 | 15 | private final ReactNativeHost mReactNativeHost = 16 | new DefaultReactNativeHost(this) { 17 | @Override 18 | public boolean getUseDeveloperSupport() { 19 | return BuildConfig.DEBUG; 20 | } 21 | 22 | @Override 23 | protected List getPackages() { 24 | @SuppressWarnings("UnnecessaryLocalVariable") 25 | List packages = new PackageList(this).getPackages(); 26 | // Packages that cannot be autolinked yet can be added manually here, for example: 27 | // packages.add(new MyReactNativePackage()); 28 | return packages; 29 | } 30 | 31 | @Override 32 | protected String getJSMainModuleName() { 33 | return "index"; 34 | } 35 | 36 | @Override 37 | protected boolean isNewArchEnabled() { 38 | return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED; 39 | } 40 | 41 | @Override 42 | protected Boolean isHermesEnabled() { 43 | return BuildConfig.IS_HERMES_ENABLED; 44 | } 45 | }; 46 | 47 | @Override 48 | public ReactNativeHost getReactNativeHost() { 49 | return mReactNativeHost; 50 | } 51 | 52 | @Override 53 | public void onCreate() { 54 | super.onCreate(); 55 | SoLoader.init(this, /* native exopackage */ false); 56 | if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { 57 | // If you opted-in for the New Architecture, we load the native entry point for this app. 58 | DefaultNewArchitectureEntryPoint.load(); 59 | } 60 | ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/rn_edit_text_material.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 21 | 22 | 23 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GleapSDK/ReactNative-SDK/5025a2793cfa97ef3c8bf0f7f836e8061a260e4d/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GleapSDK/ReactNative-SDK/5025a2793cfa97ef3c8bf0f7f836e8061a260e4d/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GleapSDK/ReactNative-SDK/5025a2793cfa97ef3c8bf0f7f836e8061a260e4d/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GleapSDK/ReactNative-SDK/5025a2793cfa97ef3c8bf0f7f836e8061a260e4d/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GleapSDK/ReactNative-SDK/5025a2793cfa97ef3c8bf0f7f836e8061a260e4d/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GleapSDK/ReactNative-SDK/5025a2793cfa97ef3c8bf0f7f836e8061a260e4d/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GleapSDK/ReactNative-SDK/5025a2793cfa97ef3c8bf0f7f836e8061a260e4d/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GleapSDK/ReactNative-SDK/5025a2793cfa97ef3c8bf0f7f836e8061a260e4d/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GleapSDK/ReactNative-SDK/5025a2793cfa97ef3c8bf0f7f836e8061a260e4d/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GleapSDK/ReactNative-SDK/5025a2793cfa97ef3c8bf0f7f836e8061a260e4d/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | GleapExample 3 | 4 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /example/android/app/src/release/java/com/gleapexample/ReactNativeFlipper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | *

This source code is licensed under the MIT license found in the LICENSE file in the root 5 | * directory of this source tree. 6 | */ 7 | package com.gleapexample; 8 | 9 | import android.content.Context; 10 | import com.facebook.react.ReactInstanceManager; 11 | 12 | /** 13 | * Class responsible of loading Flipper inside your React Native application. This is the release 14 | * flavor of it so it's empty as we don't want to load Flipper. 15 | */ 16 | public class ReactNativeFlipper { 17 | public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { 18 | // Do nothing as we don't want to initialize Flipper on Release. 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext { 5 | buildToolsVersion = "33.0.0" 6 | minSdkVersion = 21 7 | compileSdkVersion = 34 8 | targetSdkVersion = 33 9 | 10 | // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP. 11 | ndkVersion = "23.1.7779620" 12 | } 13 | repositories { 14 | google() 15 | mavenCentral() 16 | } 17 | dependencies { 18 | classpath("com.android.tools.build:gradle:7.3.1") 19 | classpath("com.facebook.react:react-native-gradle-plugin") 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /example/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 | # Automatically convert third-party libraries to use AndroidX 25 | android.enableJetifier=true 26 | 27 | # Version of flipper SDK to use with React Native 28 | FLIPPER_VERSION=0.125.0 29 | 30 | # Use this property to specify which architecture you want to build. 31 | # You can also override it from the CLI using 32 | # ./gradlew -PreactNativeArchitectures=x86_64 33 | reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64 34 | 35 | # Use this property to enable support to the new architecture. 36 | # This will allow you to use TurboModules and the Fabric render in 37 | # your application. You should enable this flag either if you want 38 | # to write custom TurboModules/Fabric components OR use libraries that 39 | # are providing them. 40 | newArchEnabled=false 41 | 42 | # Use this property to enable or disable the Hermes JS engine. 43 | # If set to false, you will be using JSC instead. 44 | hermesEnabled=true 45 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GleapSDK/ReactNative-SDK/5025a2793cfa97ef3c8bf0f7f836e8061a260e4d/example/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /example/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-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /example/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 | # Use "xargs" to parse quoted args. 209 | # 210 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 211 | # 212 | # In Bash we could simply go: 213 | # 214 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 215 | # set -- "${ARGS[@]}" "$@" 216 | # 217 | # but POSIX shell has neither arrays nor command substitution, so instead we 218 | # post-process each arg (as a line of input to sed) to backslash-escape any 219 | # character that might be a shell metacharacter, then use eval to reverse 220 | # that process (while maintaining the separation between arguments), and wrap 221 | # the whole thing up as a single "set" statement. 222 | # 223 | # This will of course break if any of these variables contains a newline or 224 | # an unmatched quote. 225 | # 226 | 227 | eval "set -- $( 228 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 229 | xargs -n1 | 230 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 231 | tr '\n' ' ' 232 | )" '"$@"' 233 | 234 | exec "$JAVACMD" "$@" 235 | -------------------------------------------------------------------------------- /example/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%" == "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%"=="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 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'GleapExample' 2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) 3 | include ':app' 4 | includeBuild('../node_modules/react-native-gradle-plugin') 5 | -------------------------------------------------------------------------------- /example/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "GleapExample", 3 | "displayName": "GleapExample" 4 | } -------------------------------------------------------------------------------- /example/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['module:metro-react-native-babel-preset'], 3 | }; 4 | -------------------------------------------------------------------------------- /example/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 | import Gleap from 'react-native-gleapsdk'; 9 | 10 | const transactionTool = { 11 | // Name the tool. Only lowecase letters and - are allowed. 12 | name: 'send-money', 13 | // Describe the tool. This can also contain further instructions for the LLM. 14 | description: 'Send money to a given contact.', 15 | // Let the LLM know what the tool is doing. This will allow Kai to update the customer accordingly. 16 | response: 17 | 'The transfer got initiated but not completed yet. The user must confirm the transfer in the banking app.', 18 | // Specify the parameters (it's also possible to pass an empty array) 19 | parameters: [ 20 | { 21 | name: 'amount', 22 | description: 23 | 'The amount of money to send. Must be positive and provided by the user.', 24 | type: 'number', 25 | required: true, 26 | }, 27 | { 28 | name: 'contact', 29 | description: 'The contact to send money to.', 30 | type: 'string', 31 | enum: ['Alice', 'Bob'], // Optional 32 | required: true, 33 | }, 34 | ], 35 | }; 36 | 37 | // Add all available tools to the array. 38 | const tools = [transactionTool]; 39 | 40 | // Set the AI tools. 41 | Gleap.setAiTools(tools); 42 | 43 | Gleap.setTicketAttribute('note', 'This is a test value.'); 44 | 45 | Gleap.unsetTicketAttribute('note'); 46 | 47 | Gleap.clearTicketAttributes(); 48 | 49 | Gleap.initialize('ogWhNhuiZcGWrva5nlDS8l7a78OfaLlV'); 50 | 51 | Gleap.registerCustomAction(customAction => { 52 | console.log('customAction', JSON.stringify(customAction, null, 2)); 53 | }); 54 | 55 | Gleap.registerListener('toolExecution', data => { 56 | console.log('data', data); 57 | }); 58 | 59 | Gleap.registerListener('outboundSent', data => { 60 | console.log('outboundSent', data); 61 | }); 62 | 63 | Gleap.registerListener('feedbackSent', data => { 64 | console.log('feedbackSent', data); 65 | }); 66 | 67 | AppRegistry.registerComponent(appName, () => App); 68 | -------------------------------------------------------------------------------- /example/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/ios/GleapExample.xcodeproj/xcshareddata/xcschemes/GleapExample.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/ios/GleapExample.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/GleapExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/GleapExample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : RCTAppDelegate 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /example/ios/GleapExample/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 = @"GleapExample"; 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 | #if DEBUG 20 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"]; 21 | #else 22 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 23 | #endif 24 | } 25 | 26 | /// This method controls whether the `concurrentRoot`feature of React18 is turned on or off. 27 | /// 28 | /// @see: https://reactjs.org/blog/2022/03/29/react-v18.html 29 | /// @note: This requires to be rendering on Fabric (i.e. on the New Architecture). 30 | /// @return: `true` if the `concurrentRoot` feature is enabled. Otherwise, it returns `false`. 31 | - (BOOL)concurrentRootEnabled 32 | { 33 | return true; 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /example/ios/GleapExample/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/ios/GleapExample/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /example/ios/GleapExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | GleapExample 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 | NSExceptionDomains 30 | 31 | localhost 32 | 33 | NSExceptionAllowsInsecureHTTPLoads 34 | 35 | 36 | 37 | 38 | NSLocationWhenInUseUsageDescription 39 | 40 | UILaunchStoryboardName 41 | LaunchScreen 42 | UIRequiredDeviceCapabilities 43 | 44 | armv7 45 | 46 | UISupportedInterfaceOrientations 47 | 48 | UIInterfaceOrientationPortrait 49 | UIInterfaceOrientationLandscapeLeft 50 | UIInterfaceOrientationLandscapeRight 51 | 52 | UIViewControllerBasedStatusBarAppearance 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /example/ios/GleapExample/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/ios/GleapExample/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/ios/GleapExampleTests/GleapExampleTests.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 GleapExampleTests : XCTestCase 11 | 12 | @end 13 | 14 | @implementation GleapExampleTests 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/ios/GleapExampleTests/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/ios/Podfile: -------------------------------------------------------------------------------- 1 | require_relative '../node_modules/react-native/scripts/react_native_pods' 2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' 3 | 4 | platform :ios, min_ios_version_supported 5 | prepare_react_native_project! 6 | 7 | # If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set. 8 | # because `react-native-flipper` depends on (FlipperKit,...) that will be excluded 9 | # 10 | # To fix this you can also exclude `react-native-flipper` using a `react-native.config.js` 11 | # ```js 12 | # module.exports = { 13 | # dependencies: { 14 | # ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}), 15 | # ``` 16 | #flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled 17 | 18 | linkage = ENV['USE_FRAMEWORKS'] 19 | if linkage != nil 20 | Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green 21 | use_frameworks! :linkage => linkage.to_sym 22 | end 23 | 24 | target 'GleapExample' do 25 | config = use_native_modules! 26 | 27 | # Flags change depending on the env values. 28 | flags = get_default_flags() 29 | 30 | use_react_native!( 31 | :path => config[:reactNativePath], 32 | # Hermes is now enabled by default. Disable by setting this flag to false. 33 | # Upcoming versions of React Native may rely on get_default_flags(), but 34 | # we make it explicit here to aid in the React Native upgrade process. 35 | :hermes_enabled => flags[:hermes_enabled], 36 | :fabric_enabled => flags[:fabric_enabled], 37 | # Enables Flipper. 38 | # 39 | # Note that if you have use_frameworks! enabled, Flipper will not work and 40 | # you should disable the next line. 41 | # :flipper_configuration => flipper_config, 42 | # An absolute path to your application root. 43 | :app_path => "#{Pod::Config.instance.installation_root}/.." 44 | ) 45 | 46 | target 'GleapExampleTests' do 47 | inherit! :complete 48 | # Pods for testing 49 | end 50 | 51 | post_install do |installer| 52 | react_native_post_install( 53 | installer, 54 | # Set `mac_catalyst_enabled` to `true` in order to apply patches 55 | # necessary for Mac Catalyst builds 56 | :mac_catalyst_enabled => false 57 | ) 58 | __apply_Xcode_12_5_M1_post_install_workaround(installer) 59 | end 60 | end 61 | -------------------------------------------------------------------------------- /example/ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - boost (1.76.0) 3 | - DoubleConversion (1.1.6) 4 | - FBLazyVector (0.71.11) 5 | - FBReactNativeSpec (0.71.11): 6 | - RCT-Folly (= 2021.07.22.00) 7 | - RCTRequired (= 0.71.11) 8 | - RCTTypeSafety (= 0.71.11) 9 | - React-Core (= 0.71.11) 10 | - React-jsi (= 0.71.11) 11 | - ReactCommon/turbomodule/core (= 0.71.11) 12 | - fmt (6.2.1) 13 | - Gleap (14.5.0) 14 | - glog (0.3.5) 15 | - hermes-engine (0.71.11): 16 | - hermes-engine/Pre-built (= 0.71.11) 17 | - hermes-engine/Pre-built (0.71.11) 18 | - libevent (2.1.12) 19 | - RCT-Folly (2021.07.22.00): 20 | - boost 21 | - DoubleConversion 22 | - fmt (~> 6.2.1) 23 | - glog 24 | - RCT-Folly/Default (= 2021.07.22.00) 25 | - RCT-Folly/Default (2021.07.22.00): 26 | - boost 27 | - DoubleConversion 28 | - fmt (~> 6.2.1) 29 | - glog 30 | - RCT-Folly/Futures (2021.07.22.00): 31 | - boost 32 | - DoubleConversion 33 | - fmt (~> 6.2.1) 34 | - glog 35 | - libevent 36 | - RCTRequired (0.71.11) 37 | - RCTTypeSafety (0.71.11): 38 | - FBLazyVector (= 0.71.11) 39 | - RCTRequired (= 0.71.11) 40 | - React-Core (= 0.71.11) 41 | - React (0.71.11): 42 | - React-Core (= 0.71.11) 43 | - React-Core/DevSupport (= 0.71.11) 44 | - React-Core/RCTWebSocket (= 0.71.11) 45 | - React-RCTActionSheet (= 0.71.11) 46 | - React-RCTAnimation (= 0.71.11) 47 | - React-RCTBlob (= 0.71.11) 48 | - React-RCTImage (= 0.71.11) 49 | - React-RCTLinking (= 0.71.11) 50 | - React-RCTNetwork (= 0.71.11) 51 | - React-RCTSettings (= 0.71.11) 52 | - React-RCTText (= 0.71.11) 53 | - React-RCTVibration (= 0.71.11) 54 | - React-callinvoker (0.71.11) 55 | - React-Codegen (0.71.11): 56 | - FBReactNativeSpec 57 | - hermes-engine 58 | - RCT-Folly 59 | - RCTRequired 60 | - RCTTypeSafety 61 | - React-Core 62 | - React-jsi 63 | - React-jsiexecutor 64 | - ReactCommon/turbomodule/bridging 65 | - ReactCommon/turbomodule/core 66 | - React-Core (0.71.11): 67 | - glog 68 | - hermes-engine 69 | - RCT-Folly (= 2021.07.22.00) 70 | - React-Core/Default (= 0.71.11) 71 | - React-cxxreact (= 0.71.11) 72 | - React-hermes 73 | - React-jsi (= 0.71.11) 74 | - React-jsiexecutor (= 0.71.11) 75 | - React-perflogger (= 0.71.11) 76 | - Yoga 77 | - React-Core/CoreModulesHeaders (0.71.11): 78 | - glog 79 | - hermes-engine 80 | - RCT-Folly (= 2021.07.22.00) 81 | - React-Core/Default 82 | - React-cxxreact (= 0.71.11) 83 | - React-hermes 84 | - React-jsi (= 0.71.11) 85 | - React-jsiexecutor (= 0.71.11) 86 | - React-perflogger (= 0.71.11) 87 | - Yoga 88 | - React-Core/Default (0.71.11): 89 | - glog 90 | - hermes-engine 91 | - RCT-Folly (= 2021.07.22.00) 92 | - React-cxxreact (= 0.71.11) 93 | - React-hermes 94 | - React-jsi (= 0.71.11) 95 | - React-jsiexecutor (= 0.71.11) 96 | - React-perflogger (= 0.71.11) 97 | - Yoga 98 | - React-Core/DevSupport (0.71.11): 99 | - glog 100 | - hermes-engine 101 | - RCT-Folly (= 2021.07.22.00) 102 | - React-Core/Default (= 0.71.11) 103 | - React-Core/RCTWebSocket (= 0.71.11) 104 | - React-cxxreact (= 0.71.11) 105 | - React-hermes 106 | - React-jsi (= 0.71.11) 107 | - React-jsiexecutor (= 0.71.11) 108 | - React-jsinspector (= 0.71.11) 109 | - React-perflogger (= 0.71.11) 110 | - Yoga 111 | - React-Core/RCTActionSheetHeaders (0.71.11): 112 | - glog 113 | - hermes-engine 114 | - RCT-Folly (= 2021.07.22.00) 115 | - React-Core/Default 116 | - React-cxxreact (= 0.71.11) 117 | - React-hermes 118 | - React-jsi (= 0.71.11) 119 | - React-jsiexecutor (= 0.71.11) 120 | - React-perflogger (= 0.71.11) 121 | - Yoga 122 | - React-Core/RCTAnimationHeaders (0.71.11): 123 | - glog 124 | - hermes-engine 125 | - RCT-Folly (= 2021.07.22.00) 126 | - React-Core/Default 127 | - React-cxxreact (= 0.71.11) 128 | - React-hermes 129 | - React-jsi (= 0.71.11) 130 | - React-jsiexecutor (= 0.71.11) 131 | - React-perflogger (= 0.71.11) 132 | - Yoga 133 | - React-Core/RCTBlobHeaders (0.71.11): 134 | - glog 135 | - hermes-engine 136 | - RCT-Folly (= 2021.07.22.00) 137 | - React-Core/Default 138 | - React-cxxreact (= 0.71.11) 139 | - React-hermes 140 | - React-jsi (= 0.71.11) 141 | - React-jsiexecutor (= 0.71.11) 142 | - React-perflogger (= 0.71.11) 143 | - Yoga 144 | - React-Core/RCTImageHeaders (0.71.11): 145 | - glog 146 | - hermes-engine 147 | - RCT-Folly (= 2021.07.22.00) 148 | - React-Core/Default 149 | - React-cxxreact (= 0.71.11) 150 | - React-hermes 151 | - React-jsi (= 0.71.11) 152 | - React-jsiexecutor (= 0.71.11) 153 | - React-perflogger (= 0.71.11) 154 | - Yoga 155 | - React-Core/RCTLinkingHeaders (0.71.11): 156 | - glog 157 | - hermes-engine 158 | - RCT-Folly (= 2021.07.22.00) 159 | - React-Core/Default 160 | - React-cxxreact (= 0.71.11) 161 | - React-hermes 162 | - React-jsi (= 0.71.11) 163 | - React-jsiexecutor (= 0.71.11) 164 | - React-perflogger (= 0.71.11) 165 | - Yoga 166 | - React-Core/RCTNetworkHeaders (0.71.11): 167 | - glog 168 | - hermes-engine 169 | - RCT-Folly (= 2021.07.22.00) 170 | - React-Core/Default 171 | - React-cxxreact (= 0.71.11) 172 | - React-hermes 173 | - React-jsi (= 0.71.11) 174 | - React-jsiexecutor (= 0.71.11) 175 | - React-perflogger (= 0.71.11) 176 | - Yoga 177 | - React-Core/RCTSettingsHeaders (0.71.11): 178 | - glog 179 | - hermes-engine 180 | - RCT-Folly (= 2021.07.22.00) 181 | - React-Core/Default 182 | - React-cxxreact (= 0.71.11) 183 | - React-hermes 184 | - React-jsi (= 0.71.11) 185 | - React-jsiexecutor (= 0.71.11) 186 | - React-perflogger (= 0.71.11) 187 | - Yoga 188 | - React-Core/RCTTextHeaders (0.71.11): 189 | - glog 190 | - hermes-engine 191 | - RCT-Folly (= 2021.07.22.00) 192 | - React-Core/Default 193 | - React-cxxreact (= 0.71.11) 194 | - React-hermes 195 | - React-jsi (= 0.71.11) 196 | - React-jsiexecutor (= 0.71.11) 197 | - React-perflogger (= 0.71.11) 198 | - Yoga 199 | - React-Core/RCTVibrationHeaders (0.71.11): 200 | - glog 201 | - hermes-engine 202 | - RCT-Folly (= 2021.07.22.00) 203 | - React-Core/Default 204 | - React-cxxreact (= 0.71.11) 205 | - React-hermes 206 | - React-jsi (= 0.71.11) 207 | - React-jsiexecutor (= 0.71.11) 208 | - React-perflogger (= 0.71.11) 209 | - Yoga 210 | - React-Core/RCTWebSocket (0.71.11): 211 | - glog 212 | - hermes-engine 213 | - RCT-Folly (= 2021.07.22.00) 214 | - React-Core/Default (= 0.71.11) 215 | - React-cxxreact (= 0.71.11) 216 | - React-hermes 217 | - React-jsi (= 0.71.11) 218 | - React-jsiexecutor (= 0.71.11) 219 | - React-perflogger (= 0.71.11) 220 | - Yoga 221 | - React-CoreModules (0.71.11): 222 | - RCT-Folly (= 2021.07.22.00) 223 | - RCTTypeSafety (= 0.71.11) 224 | - React-Codegen (= 0.71.11) 225 | - React-Core/CoreModulesHeaders (= 0.71.11) 226 | - React-jsi (= 0.71.11) 227 | - React-RCTBlob 228 | - React-RCTImage (= 0.71.11) 229 | - ReactCommon/turbomodule/core (= 0.71.11) 230 | - React-cxxreact (0.71.11): 231 | - boost (= 1.76.0) 232 | - DoubleConversion 233 | - glog 234 | - hermes-engine 235 | - RCT-Folly (= 2021.07.22.00) 236 | - React-callinvoker (= 0.71.11) 237 | - React-jsi (= 0.71.11) 238 | - React-jsinspector (= 0.71.11) 239 | - React-logger (= 0.71.11) 240 | - React-perflogger (= 0.71.11) 241 | - React-runtimeexecutor (= 0.71.11) 242 | - React-hermes (0.71.11): 243 | - DoubleConversion 244 | - glog 245 | - hermes-engine 246 | - RCT-Folly (= 2021.07.22.00) 247 | - RCT-Folly/Futures (= 2021.07.22.00) 248 | - React-cxxreact (= 0.71.11) 249 | - React-jsi 250 | - React-jsiexecutor (= 0.71.11) 251 | - React-jsinspector (= 0.71.11) 252 | - React-perflogger (= 0.71.11) 253 | - React-jsi (0.71.11): 254 | - boost (= 1.76.0) 255 | - DoubleConversion 256 | - glog 257 | - hermes-engine 258 | - RCT-Folly (= 2021.07.22.00) 259 | - React-jsiexecutor (0.71.11): 260 | - DoubleConversion 261 | - glog 262 | - hermes-engine 263 | - RCT-Folly (= 2021.07.22.00) 264 | - React-cxxreact (= 0.71.11) 265 | - React-jsi (= 0.71.11) 266 | - React-perflogger (= 0.71.11) 267 | - React-jsinspector (0.71.11) 268 | - React-logger (0.71.11): 269 | - glog 270 | - react-native-gleapsdk (14.5.0): 271 | - Gleap (= 14.5.0) 272 | - React-Core 273 | - React-perflogger (0.71.11) 274 | - React-RCTActionSheet (0.71.11): 275 | - React-Core/RCTActionSheetHeaders (= 0.71.11) 276 | - React-RCTAnimation (0.71.11): 277 | - RCT-Folly (= 2021.07.22.00) 278 | - RCTTypeSafety (= 0.71.11) 279 | - React-Codegen (= 0.71.11) 280 | - React-Core/RCTAnimationHeaders (= 0.71.11) 281 | - React-jsi (= 0.71.11) 282 | - ReactCommon/turbomodule/core (= 0.71.11) 283 | - React-RCTAppDelegate (0.71.11): 284 | - RCT-Folly 285 | - RCTRequired 286 | - RCTTypeSafety 287 | - React-Core 288 | - ReactCommon/turbomodule/core 289 | - React-RCTBlob (0.71.11): 290 | - hermes-engine 291 | - RCT-Folly (= 2021.07.22.00) 292 | - React-Codegen (= 0.71.11) 293 | - React-Core/RCTBlobHeaders (= 0.71.11) 294 | - React-Core/RCTWebSocket (= 0.71.11) 295 | - React-jsi (= 0.71.11) 296 | - React-RCTNetwork (= 0.71.11) 297 | - ReactCommon/turbomodule/core (= 0.71.11) 298 | - React-RCTImage (0.71.11): 299 | - RCT-Folly (= 2021.07.22.00) 300 | - RCTTypeSafety (= 0.71.11) 301 | - React-Codegen (= 0.71.11) 302 | - React-Core/RCTImageHeaders (= 0.71.11) 303 | - React-jsi (= 0.71.11) 304 | - React-RCTNetwork (= 0.71.11) 305 | - ReactCommon/turbomodule/core (= 0.71.11) 306 | - React-RCTLinking (0.71.11): 307 | - React-Codegen (= 0.71.11) 308 | - React-Core/RCTLinkingHeaders (= 0.71.11) 309 | - React-jsi (= 0.71.11) 310 | - ReactCommon/turbomodule/core (= 0.71.11) 311 | - React-RCTNetwork (0.71.11): 312 | - RCT-Folly (= 2021.07.22.00) 313 | - RCTTypeSafety (= 0.71.11) 314 | - React-Codegen (= 0.71.11) 315 | - React-Core/RCTNetworkHeaders (= 0.71.11) 316 | - React-jsi (= 0.71.11) 317 | - ReactCommon/turbomodule/core (= 0.71.11) 318 | - React-RCTSettings (0.71.11): 319 | - RCT-Folly (= 2021.07.22.00) 320 | - RCTTypeSafety (= 0.71.11) 321 | - React-Codegen (= 0.71.11) 322 | - React-Core/RCTSettingsHeaders (= 0.71.11) 323 | - React-jsi (= 0.71.11) 324 | - ReactCommon/turbomodule/core (= 0.71.11) 325 | - React-RCTText (0.71.11): 326 | - React-Core/RCTTextHeaders (= 0.71.11) 327 | - React-RCTVibration (0.71.11): 328 | - RCT-Folly (= 2021.07.22.00) 329 | - React-Codegen (= 0.71.11) 330 | - React-Core/RCTVibrationHeaders (= 0.71.11) 331 | - React-jsi (= 0.71.11) 332 | - ReactCommon/turbomodule/core (= 0.71.11) 333 | - React-runtimeexecutor (0.71.11): 334 | - React-jsi (= 0.71.11) 335 | - ReactCommon/turbomodule/bridging (0.71.11): 336 | - DoubleConversion 337 | - glog 338 | - hermes-engine 339 | - RCT-Folly (= 2021.07.22.00) 340 | - React-callinvoker (= 0.71.11) 341 | - React-Core (= 0.71.11) 342 | - React-cxxreact (= 0.71.11) 343 | - React-jsi (= 0.71.11) 344 | - React-logger (= 0.71.11) 345 | - React-perflogger (= 0.71.11) 346 | - ReactCommon/turbomodule/core (0.71.11): 347 | - DoubleConversion 348 | - glog 349 | - hermes-engine 350 | - RCT-Folly (= 2021.07.22.00) 351 | - React-callinvoker (= 0.71.11) 352 | - React-Core (= 0.71.11) 353 | - React-cxxreact (= 0.71.11) 354 | - React-jsi (= 0.71.11) 355 | - React-logger (= 0.71.11) 356 | - React-perflogger (= 0.71.11) 357 | - Yoga (1.14.0) 358 | 359 | DEPENDENCIES: 360 | - boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`) 361 | - DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`) 362 | - FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`) 363 | - FBReactNativeSpec (from `../node_modules/react-native/React/FBReactNativeSpec`) 364 | - glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`) 365 | - hermes-engine (from `../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`) 366 | - libevent (~> 2.1.12) 367 | - RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`) 368 | - RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`) 369 | - RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`) 370 | - React (from `../node_modules/react-native/`) 371 | - React-callinvoker (from `../node_modules/react-native/ReactCommon/callinvoker`) 372 | - React-Codegen (from `build/generated/ios`) 373 | - React-Core (from `../node_modules/react-native/`) 374 | - React-Core/RCTWebSocket (from `../node_modules/react-native/`) 375 | - React-CoreModules (from `../node_modules/react-native/React/CoreModules`) 376 | - React-cxxreact (from `../node_modules/react-native/ReactCommon/cxxreact`) 377 | - React-hermes (from `../node_modules/react-native/ReactCommon/hermes`) 378 | - React-jsi (from `../node_modules/react-native/ReactCommon/jsi`) 379 | - React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`) 380 | - React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`) 381 | - React-logger (from `../node_modules/react-native/ReactCommon/logger`) 382 | - react-native-gleapsdk (from `../node_modules/react-native-gleapsdk`) 383 | - React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`) 384 | - React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`) 385 | - React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`) 386 | - React-RCTAppDelegate (from `../node_modules/react-native/Libraries/AppDelegate`) 387 | - React-RCTBlob (from `../node_modules/react-native/Libraries/Blob`) 388 | - React-RCTImage (from `../node_modules/react-native/Libraries/Image`) 389 | - React-RCTLinking (from `../node_modules/react-native/Libraries/LinkingIOS`) 390 | - React-RCTNetwork (from `../node_modules/react-native/Libraries/Network`) 391 | - React-RCTSettings (from `../node_modules/react-native/Libraries/Settings`) 392 | - React-RCTText (from `../node_modules/react-native/Libraries/Text`) 393 | - React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`) 394 | - React-runtimeexecutor (from `../node_modules/react-native/ReactCommon/runtimeexecutor`) 395 | - ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`) 396 | - Yoga (from `../node_modules/react-native/ReactCommon/yoga`) 397 | 398 | SPEC REPOS: 399 | trunk: 400 | - fmt 401 | - Gleap 402 | - libevent 403 | 404 | EXTERNAL SOURCES: 405 | boost: 406 | :podspec: "../node_modules/react-native/third-party-podspecs/boost.podspec" 407 | DoubleConversion: 408 | :podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec" 409 | FBLazyVector: 410 | :path: "../node_modules/react-native/Libraries/FBLazyVector" 411 | FBReactNativeSpec: 412 | :path: "../node_modules/react-native/React/FBReactNativeSpec" 413 | glog: 414 | :podspec: "../node_modules/react-native/third-party-podspecs/glog.podspec" 415 | hermes-engine: 416 | :podspec: "../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec" 417 | RCT-Folly: 418 | :podspec: "../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec" 419 | RCTRequired: 420 | :path: "../node_modules/react-native/Libraries/RCTRequired" 421 | RCTTypeSafety: 422 | :path: "../node_modules/react-native/Libraries/TypeSafety" 423 | React: 424 | :path: "../node_modules/react-native/" 425 | React-callinvoker: 426 | :path: "../node_modules/react-native/ReactCommon/callinvoker" 427 | React-Codegen: 428 | :path: build/generated/ios 429 | React-Core: 430 | :path: "../node_modules/react-native/" 431 | React-CoreModules: 432 | :path: "../node_modules/react-native/React/CoreModules" 433 | React-cxxreact: 434 | :path: "../node_modules/react-native/ReactCommon/cxxreact" 435 | React-hermes: 436 | :path: "../node_modules/react-native/ReactCommon/hermes" 437 | React-jsi: 438 | :path: "../node_modules/react-native/ReactCommon/jsi" 439 | React-jsiexecutor: 440 | :path: "../node_modules/react-native/ReactCommon/jsiexecutor" 441 | React-jsinspector: 442 | :path: "../node_modules/react-native/ReactCommon/jsinspector" 443 | React-logger: 444 | :path: "../node_modules/react-native/ReactCommon/logger" 445 | react-native-gleapsdk: 446 | :path: "../node_modules/react-native-gleapsdk" 447 | React-perflogger: 448 | :path: "../node_modules/react-native/ReactCommon/reactperflogger" 449 | React-RCTActionSheet: 450 | :path: "../node_modules/react-native/Libraries/ActionSheetIOS" 451 | React-RCTAnimation: 452 | :path: "../node_modules/react-native/Libraries/NativeAnimation" 453 | React-RCTAppDelegate: 454 | :path: "../node_modules/react-native/Libraries/AppDelegate" 455 | React-RCTBlob: 456 | :path: "../node_modules/react-native/Libraries/Blob" 457 | React-RCTImage: 458 | :path: "../node_modules/react-native/Libraries/Image" 459 | React-RCTLinking: 460 | :path: "../node_modules/react-native/Libraries/LinkingIOS" 461 | React-RCTNetwork: 462 | :path: "../node_modules/react-native/Libraries/Network" 463 | React-RCTSettings: 464 | :path: "../node_modules/react-native/Libraries/Settings" 465 | React-RCTText: 466 | :path: "../node_modules/react-native/Libraries/Text" 467 | React-RCTVibration: 468 | :path: "../node_modules/react-native/Libraries/Vibration" 469 | React-runtimeexecutor: 470 | :path: "../node_modules/react-native/ReactCommon/runtimeexecutor" 471 | ReactCommon: 472 | :path: "../node_modules/react-native/ReactCommon" 473 | Yoga: 474 | :path: "../node_modules/react-native/ReactCommon/yoga" 475 | 476 | SPEC CHECKSUMS: 477 | boost: 57d2868c099736d80fcd648bf211b4431e51a558 478 | DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54 479 | FBLazyVector: c511d4cd0210f416cb5c289bd5ae6b36d909b048 480 | FBReactNativeSpec: a911fb22def57aef1d74215e8b6b8761d25c1c54 481 | fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 482 | Gleap: d6fdda16ef1b54a758a45e77977152d1d62d9dfd 483 | glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b 484 | hermes-engine: 34c863b446d0135b85a6536fa5fd89f48196f848 485 | libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 486 | RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1 487 | RCTRequired: f6187ec763637e6a57f5728dd9a3bdabc6d6b4e0 488 | RCTTypeSafety: a01aca2dd3b27fa422d5239252ad38e54e958750 489 | React: 741b4f5187e7a2137b69c88e65f940ba40600b4b 490 | React-callinvoker: 72ba74b2d5d690c497631191ae6eeca0c043d9cf 491 | React-Codegen: 8a7cda1633e4940de8a710f6bf5cae5dd673546e 492 | React-Core: 72bb19702c465b6451a40501a2879532bec9acee 493 | React-CoreModules: ffd19b082fc36b9b463fedf30955138b5426c053 494 | React-cxxreact: 8b3dd87e3b8ea96dd4ad5c7bac8f31f1cc3da97f 495 | React-hermes: be95942c3f47fc032da1387360413f00dae0ea68 496 | React-jsi: 9978e2a64c2a4371b40e109f4ef30a33deaa9bcb 497 | React-jsiexecutor: 18b5b33c5f2687a784a61bc8176611b73524ae77 498 | React-jsinspector: b6ed4cb3ffa27a041cd440300503dc512b761450 499 | React-logger: 186dd536128ae5924bc38ed70932c00aa740cd5b 500 | react-native-gleapsdk: 06c7081d7da006a6627731c1e3abe161727c2cf7 501 | React-perflogger: e706562ab7eb8eb590aa83a224d26fa13963d7f2 502 | React-RCTActionSheet: 57d4bd98122f557479a3359ad5dad8e109e20c5a 503 | React-RCTAnimation: ccf3ef00101ea74bda73a045d79a658b36728a60 504 | React-RCTAppDelegate: d0c28a35c65e9a0aef287ac0dafe1b71b1ac180c 505 | React-RCTBlob: 1700b92ece4357af0a49719c9638185ad2902e95 506 | React-RCTImage: f2e4904566ccccaa4b704170fcc5ae144ca347bf 507 | React-RCTLinking: 52a3740e3651e30aa11dff5a6debed7395dd8169 508 | React-RCTNetwork: ea0976f2b3ffc7877cd7784e351dc460adf87b12 509 | React-RCTSettings: ed5ac992b23e25c65c3cc31f11b5c940ae5e3e60 510 | React-RCTText: c9dfc6722621d56332b4f3a19ac38105e7504145 511 | React-RCTVibration: f09f08de63e4122deb32506e20ca4cae6e4e14c1 512 | React-runtimeexecutor: 4817d63dbc9d658f8dc0ec56bd9b83ce531129f0 513 | ReactCommon: 08723d2ed328c5cbcb0de168f231bc7bae7f8aa1 514 | Yoga: f7decafdc5e8c125e6fa0da38a687e35238420fa 515 | 516 | PODFILE CHECKSUM: 6b8c820492fb956619040b4a0dc28a14ac11e07f 517 | 518 | COCOAPODS: 1.16.2 519 | -------------------------------------------------------------------------------- /example/metro.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Metro configuration for React Native 3 | * https://github.com/facebook/react-native 4 | * 5 | * @format 6 | */ 7 | // paths to local packages 8 | const localPackagePaths = [ 9 | '../', 10 | ] 11 | 12 | module.exports = { 13 | transformer: { 14 | getTransformOptions: async () => ({ 15 | transform: { 16 | experimentalImportSupport: false, 17 | inlineRequires: true, 18 | }, 19 | }), 20 | }, 21 | resolver: { 22 | nodeModulesPaths: [...localPackagePaths], // update to resolver 23 | }, 24 | watchFolders: [...localPackagePaths], // update to watch 25 | }; 26 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "GleapExample", 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.2.0", 14 | "react-native": "0.71.11", 15 | "react-native-gleapsdk": "file:.." 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-community/eslint-config": "^3.2.0", 22 | "@tsconfig/react-native": "^2.0.2", 23 | "@types/jest": "^29.2.1", 24 | "@types/react": "^18.0.24", 25 | "@types/react-test-renderer": "^18.0.0", 26 | "babel-jest": "^29.2.1", 27 | "eslint": "^8.19.0", 28 | "jest": "^29.2.1", 29 | "metro-react-native-babel-preset": "0.73.10", 30 | "prettier": "^2.4.1", 31 | "react-test-renderer": "18.2.0", 32 | "typescript": "4.8.4" 33 | }, 34 | "jest": { 35 | "preset": "react-native" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /example/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/react-native/tsconfig.json" 3 | } 4 | -------------------------------------------------------------------------------- /ios/Gleapsdk.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | 5 | @interface Gleapsdk : RCTEventEmitter 6 | 7 | @end 8 | -------------------------------------------------------------------------------- /ios/Gleapsdk.m: -------------------------------------------------------------------------------- 1 | #import "Gleapsdk.h" 2 | 3 | #import 4 | #import 5 | #import 6 | 7 | static NSString *const RCTShowDevMenuNotification = @"RCTShowDevMenuNotification"; 8 | 9 | #if !RCT_DEV 10 | 11 | @implementation UIWindow (RNShakeEvent) 12 | 13 | - (void)handleShakeEvent:(__unused UIEventSubtype)motion withEvent:(UIEvent *)event 14 | { 15 | if (event.subtype == UIEventSubtypeMotionShake) { 16 | [[NSNotificationCenter defaultCenter] postNotificationName: RCTShowDevMenuNotification object:nil]; 17 | } 18 | } 19 | 20 | @end 21 | 22 | #endif 23 | 24 | @implementation Gleapsdk 25 | { 26 | BOOL _hasListeners; 27 | } 28 | 29 | RCT_EXPORT_MODULE() 30 | 31 | - (void)initSDK { 32 | Gleap.sharedInstance.delegate = self; 33 | [Gleap setApplicationType: REACTNATIVE]; 34 | } 35 | 36 | RCT_EXPORT_METHOD(initialize:(NSString *)token) 37 | { 38 | dispatch_async(dispatch_get_main_queue(), ^{ 39 | [self initSDK]; 40 | [Gleap setAutoActivationMethodsDisabled]; 41 | [Gleap initializeWithToken: token]; 42 | [Gleap trackEvent: @"pageView" withData: @{ 43 | @"page": @"MainPage" 44 | }]; 45 | }); 46 | } 47 | 48 | - (void)configLoaded:(NSDictionary *)config { 49 | // Hook up shake gesture recognizer. 50 | [[NSNotificationCenter defaultCenter] addObserver: self 51 | selector: @selector(motionEnded:) 52 | name: RCTShowDevMenuNotification 53 | object: nil]; 54 | 55 | #if !RCT_DEV 56 | RCTSwapInstanceMethods([UIWindow class], @selector(motionEnded:withEvent:), @selector(handleShakeEvent:withEvent:)); 57 | #endif 58 | 59 | // Add screenshot gesture recognizer 60 | NSOperationQueue *mainQueue = [NSOperationQueue mainQueue]; 61 | [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationUserDidTakeScreenshotNotification 62 | object:nil 63 | queue:mainQueue 64 | usingBlock:^(NSNotification *note) { 65 | if ([Gleap isActivationMethodActive: SCREENSHOT]) { 66 | [Gleap open]; 67 | } 68 | }]; 69 | 70 | if ([Gleap getActivationMethods].count == 0) { 71 | NSMutableArray *activationMethods = [[NSMutableArray alloc] init]; 72 | if ([config objectForKey: @"activationMethodShake"] != nil && [[config objectForKey: @"activationMethodShake"] boolValue] == YES) { 73 | [activationMethods addObject: @(SHAKE)]; 74 | } 75 | if ([config objectForKey: @"activationMethodScreenshotGesture"] != nil && [[config objectForKey: @"activationMethodScreenshotGesture"] boolValue] == YES) { 76 | [activationMethods addObject: @(SCREENSHOT)]; 77 | } 78 | 79 | [Gleap setActivationMethods: activationMethods]; 80 | } 81 | 82 | if (_hasListeners) { 83 | [self sendEventWithName:@"configLoaded" body: config]; 84 | } 85 | } 86 | 87 | - (void)initialized { 88 | if (_hasListeners) { 89 | [self sendEventWithName:@"initialized" body: @{}]; 90 | } 91 | } 92 | 93 | - (void)motionEnded:(NSNotification *)notification 94 | { 95 | if ([Gleap isActivationMethodActive: SHAKE]) { 96 | [Gleap open]; 97 | } 98 | } 99 | 100 | - (void)notificationCountUpdated:(NSInteger)count { 101 | if (_hasListeners) { 102 | [self sendEventWithName:@"notificationCountUpdated" body: @(count)]; 103 | } 104 | } 105 | 106 | - (void)feedbackSendingFailed { 107 | if (_hasListeners) { 108 | [self sendEventWithName:@"feedbackSendingFailed" body:@{}]; 109 | } 110 | } 111 | 112 | - (void)widgetOpened { 113 | if (_hasListeners) { 114 | [self sendEventWithName:@"widgetOpened" body:@{}]; 115 | } 116 | } 117 | 118 | - (void)widgetClosed { 119 | if (_hasListeners) { 120 | [self sendEventWithName:@"widgetClosed" body:@{}]; 121 | } 122 | } 123 | 124 | - (void)registerPushMessageGroup:(NSString *)pushMessageGroup { 125 | if (_hasListeners) { 126 | [self sendEventWithName:@"registerPushMessageGroup" body: pushMessageGroup]; 127 | } 128 | } 129 | 130 | - (void)unregisterPushMessageGroup:(NSString *)pushMessageGroup { 131 | if (_hasListeners) { 132 | [self sendEventWithName:@"unregisterPushMessageGroup" body: pushMessageGroup]; 133 | } 134 | } 135 | 136 | - (void)onToolExecution:(NSDictionary *)toolExecution { 137 | if (_hasListeners) { 138 | [self sendEventWithName:@"toolExecution" body: toolExecution]; 139 | } 140 | } 141 | 142 | - (void)feedbackSent:(NSDictionary *)data { 143 | if (_hasListeners) { 144 | [self sendEventWithName:@"feedbackSent" body: data]; 145 | } 146 | } 147 | 148 | - (void)outboundSent:(NSDictionary *)data { 149 | if (_hasListeners) { 150 | [self sendEventWithName:@"outboundSent" body: data]; 151 | } 152 | } 153 | 154 | - (void)customActionCalled:(NSString *)customAction withShareToken:(NSString *)shareToken { 155 | if (!_hasListeners) { return; } 156 | 157 | [self sendEventWithName:@"customActionTriggered" 158 | body:@{ 159 | @"name": customAction ?: @"", 160 | @"shareToken": shareToken ?: @"" 161 | } 162 | ]; 163 | } 164 | 165 | - (void)feedbackFlowStarted:(NSDictionary *)feedbackAction { 166 | if (_hasListeners) { 167 | [self sendEventWithName:@"feedbackFlowStarted" body: feedbackAction]; 168 | } 169 | } 170 | 171 | - (void)startObserving 172 | { 173 | _hasListeners = YES; 174 | } 175 | 176 | - (void)stopObserving 177 | { 178 | _hasListeners = NO; 179 | } 180 | 181 | - (NSArray *)supportedEvents { 182 | return @[@"feedbackSent", @"outboundSent", @"toolExecution", @"feedbackSendingFailed", @"notificationCountUpdated", @"initialized", @"configLoaded", @"customActionTriggered", @"feedbackFlowStarted", @"widgetOpened", @"widgetClosed", @"registerPushMessageGroup", @"unregisterPushMessageGroup"]; 183 | } 184 | 185 | RCT_EXPORT_METHOD(sendSilentCrashReport:(NSString *)description andSeverity:(NSString *)severity) 186 | { 187 | dispatch_async(dispatch_get_main_queue(), ^{ 188 | GleapBugSeverity prio = MEDIUM; 189 | if ([severity isEqualToString: @"LOW"]) { 190 | prio = LOW; 191 | } 192 | if ([severity isEqualToString: @"HIGH"]) { 193 | prio = HIGH; 194 | } 195 | 196 | [Gleap sendSilentCrashReportWith: description andSeverity: prio andDataExclusion: nil andCompletion:^(bool success) {}]; 197 | }); 198 | } 199 | 200 | RCT_EXPORT_METHOD(sendSilentCrashReportWithExcludeData:(NSString *)description andSeverity:(NSString *)severity andExcludeData:(NSDictionary *)excludeData) 201 | { 202 | dispatch_async(dispatch_get_main_queue(), ^{ 203 | GleapBugSeverity prio = MEDIUM; 204 | if ([severity isEqualToString: @"LOW"]) { 205 | prio = LOW; 206 | } 207 | if ([severity isEqualToString: @"HIGH"]) { 208 | prio = HIGH; 209 | } 210 | 211 | [Gleap sendSilentCrashReportWith: description andSeverity: prio andDataExclusion: excludeData andCompletion:^(bool success) {}]; 212 | }); 213 | } 214 | 215 | RCT_EXPORT_METHOD(attachNetworkLog:(NSArray *)networkLogs) 216 | { 217 | dispatch_async(dispatch_get_main_queue(), ^{ 218 | [Gleap attachExternalData: @{ @"networkLogs": networkLogs }]; 219 | }); 220 | } 221 | 222 | RCT_EXPORT_METHOD(setTags:(NSArray *)tags) 223 | { 224 | dispatch_async(dispatch_get_main_queue(), ^{ 225 | [Gleap setTags: tags]; 226 | }); 227 | } 228 | 229 | RCT_EXPORT_METHOD(setNetworkLogsBlacklist:(NSArray *)networkLogBlacklist) 230 | { 231 | dispatch_async(dispatch_get_main_queue(), ^{ 232 | [Gleap setNetworkLogsBlacklist: networkLogBlacklist]; 233 | }); 234 | } 235 | 236 | RCT_EXPORT_METHOD(setNetworkLogPropsToIgnore:(NSArray *)networkLogPropsToIgnore) 237 | { 238 | dispatch_async(dispatch_get_main_queue(), ^{ 239 | [Gleap setNetworkLogPropsToIgnore: networkLogPropsToIgnore]; 240 | }); 241 | } 242 | 243 | RCT_EXPORT_METHOD(setActivationMethods:(NSArray *)activationMethods) 244 | { 245 | dispatch_async(dispatch_get_main_queue(), ^{ 246 | NSMutableArray *internalActivationMethods = [[NSMutableArray alloc] init]; 247 | for (int i = 0; i < activationMethods.count; i++) { 248 | if ([[activationMethods objectAtIndex: i] isEqualToString: @"SHAKE"]) { 249 | [internalActivationMethods addObject: @(SHAKE)]; 250 | } 251 | if ([[activationMethods objectAtIndex: i] isEqualToString: @"SCREENSHOT"]) { 252 | [internalActivationMethods addObject: @(SCREENSHOT)]; 253 | } 254 | } 255 | 256 | [Gleap setActivationMethods: internalActivationMethods]; 257 | }); 258 | } 259 | 260 | RCT_EXPORT_METHOD(startBot:(NSString *)botId andShowBackButton:(BOOL)showBackButton) 261 | { 262 | dispatch_async(dispatch_get_main_queue(), ^{ 263 | [Gleap startBot: botId showBackButton: showBackButton]; 264 | }); 265 | } 266 | 267 | RCT_EXPORT_METHOD(openConversations:(BOOL)showBackButton) 268 | { 269 | dispatch_async(dispatch_get_main_queue(), ^{ 270 | [Gleap openConversations: showBackButton]; 271 | }); 272 | } 273 | 274 | RCT_EXPORT_METHOD(openConversation:(NSString *)shareToken) 275 | { 276 | dispatch_async(dispatch_get_main_queue(), ^{ 277 | [Gleap openConversation: shareToken]; 278 | }); 279 | } 280 | 281 | RCT_EXPORT_METHOD(startConversation:(BOOL)showBackButton) 282 | { 283 | dispatch_async(dispatch_get_main_queue(), ^{ 284 | [Gleap startConversation: showBackButton]; 285 | }); 286 | } 287 | 288 | RCT_EXPORT_METHOD(startFeedbackFlow:(NSString *)feedbackFlow andShowBackButton:(BOOL)showBackButton) 289 | { 290 | dispatch_async(dispatch_get_main_queue(), ^{ 291 | [Gleap startFeedbackFlow: feedbackFlow showBackButton: showBackButton]; 292 | }); 293 | } 294 | 295 | RCT_EXPORT_METHOD(startClassicForm:(NSString *)formId andShowBackButton:(BOOL)showBackButton) 296 | { 297 | dispatch_async(dispatch_get_main_queue(), ^{ 298 | [Gleap startClassicForm: formId showBackButton: showBackButton]; 299 | }); 300 | } 301 | 302 | RCT_EXPORT_METHOD(showSurvey:(NSString *)surveyId andFormat:(NSString *)format) 303 | { 304 | GleapSurveyFormat surveyFormat = SURVEY; 305 | if (format != nil && [format isEqualToString: @"survey_full"]) { 306 | surveyFormat = SURVEY_FULL; 307 | } 308 | 309 | dispatch_async(dispatch_get_main_queue(), ^{ 310 | [Gleap showSurvey: surveyId andFormat: surveyFormat]; 311 | }); 312 | } 313 | 314 | RCT_EXPORT_METHOD(logWithLogLevel:(NSString *)message andLogLevel:(NSString *)logLevel) 315 | { 316 | GleapLogLevel logLevelType = INFO; 317 | if (logLevel != nil && [logLevel isEqualToString: @"WARNING"]) { 318 | logLevelType = WARNING; 319 | } 320 | if (logLevel != nil && [logLevel isEqualToString: @"ERROR"]) { 321 | logLevelType = ERROR; 322 | } 323 | 324 | dispatch_async(dispatch_get_main_queue(), ^{ 325 | [Gleap log: message withLogLevel: logLevelType]; 326 | }); 327 | } 328 | 329 | RCT_EXPORT_METHOD(log:(NSString *)message) 330 | { 331 | dispatch_async(dispatch_get_main_queue(), ^{ 332 | [Gleap log: message]; 333 | }); 334 | } 335 | 336 | RCT_EXPORT_METHOD(disableConsoleLog) 337 | { 338 | dispatch_async(dispatch_get_main_queue(), ^{ 339 | [Gleap disableConsoleLog]; 340 | }); 341 | } 342 | 343 | RCT_EXPORT_METHOD(enableDebugConsoleLog) 344 | { 345 | dispatch_async(dispatch_get_main_queue(), ^{ 346 | [Gleap enableDebugConsoleLog]; 347 | }); 348 | } 349 | 350 | RCT_EXPORT_METHOD(open) 351 | { 352 | dispatch_async(dispatch_get_main_queue(), ^{ 353 | [Gleap open]; 354 | }); 355 | } 356 | 357 | RCT_EXPORT_METHOD(setDisableInAppNotifications: (BOOL)disableInAppNotifications) 358 | { 359 | dispatch_async(dispatch_get_main_queue(), ^{ 360 | [Gleap setDisableInAppNotifications: disableInAppNotifications]; 361 | }); 362 | } 363 | 364 | RCT_EXPORT_METHOD(openChecklists: (BOOL)showBackButton) 365 | { 366 | dispatch_async(dispatch_get_main_queue(), ^{ 367 | [Gleap openChecklists: showBackButton]; 368 | }); 369 | } 370 | 371 | RCT_EXPORT_METHOD(openChecklist: (NSString *)checklistId andShowBackButton:(BOOL)showBackButton) 372 | { 373 | dispatch_async(dispatch_get_main_queue(), ^{ 374 | [Gleap openChecklist: checklistId andShowBackButton: showBackButton]; 375 | }); 376 | } 377 | 378 | RCT_EXPORT_METHOD(startChecklist: (NSString *)outboundId andShowBackButton:(BOOL)showBackButton) 379 | { 380 | dispatch_async(dispatch_get_main_queue(), ^{ 381 | [Gleap startChecklist: outboundId andShowBackButton: showBackButton]; 382 | }); 383 | } 384 | 385 | RCT_EXPORT_METHOD(openNews: (BOOL)showBackButton) 386 | { 387 | dispatch_async(dispatch_get_main_queue(), ^{ 388 | [Gleap openNews: showBackButton]; 389 | }); 390 | } 391 | 392 | RCT_EXPORT_METHOD(openNewsArticle: (NSString *)articleId andShowBackButton:(BOOL)showBackButton) 393 | { 394 | dispatch_async(dispatch_get_main_queue(), ^{ 395 | [Gleap openNewsArticle: articleId andShowBackButton: showBackButton]; 396 | }); 397 | } 398 | 399 | RCT_EXPORT_METHOD(openHelpCenterCollection: (NSString *)collectionId andShowBackButton:(BOOL)showBackButton) 400 | { 401 | dispatch_async(dispatch_get_main_queue(), ^{ 402 | [Gleap openHelpCenterCollection: collectionId andShowBackButton: showBackButton]; 403 | }); 404 | } 405 | 406 | RCT_EXPORT_METHOD(openHelpCenterArticle: (NSString *)articleId andShowBackButton:(BOOL)showBackButton) 407 | { 408 | dispatch_async(dispatch_get_main_queue(), ^{ 409 | [Gleap openHelpCenterArticle: articleId andShowBackButton: showBackButton]; 410 | }); 411 | } 412 | 413 | RCT_EXPORT_METHOD(searchHelpCenter: (NSString *)term andShowBackButton:(BOOL)showBackButton) 414 | { 415 | dispatch_async(dispatch_get_main_queue(), ^{ 416 | [Gleap searchHelpCenter: term andShowBackButton: showBackButton]; 417 | }); 418 | } 419 | 420 | RCT_EXPORT_METHOD(openHelpCenter: (BOOL)showBackButton) 421 | { 422 | dispatch_async(dispatch_get_main_queue(), ^{ 423 | [Gleap openHelpCenter: showBackButton]; 424 | }); 425 | } 426 | 427 | RCT_EXPORT_METHOD(openFeatureRequests: (BOOL)showBackButton) 428 | { 429 | dispatch_async(dispatch_get_main_queue(), ^{ 430 | [Gleap openFeatureRequests: showBackButton]; 431 | }); 432 | } 433 | 434 | RCT_EXPORT_METHOD(close) 435 | { 436 | dispatch_async(dispatch_get_main_queue(), ^{ 437 | [Gleap close]; 438 | }); 439 | } 440 | 441 | RCT_EXPORT_METHOD(setLanguage:(NSString *)language) 442 | { 443 | dispatch_async(dispatch_get_main_queue(), ^{ 444 | [Gleap setLanguage: language]; 445 | }); 446 | } 447 | 448 | RCT_EXPORT_METHOD(clearIdentity) 449 | { 450 | dispatch_async(dispatch_get_main_queue(), ^{ 451 | [Gleap clearIdentity]; 452 | }); 453 | } 454 | 455 | RCT_EXPORT_METHOD(getIdentity:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) 456 | { 457 | dispatch_async(dispatch_get_main_queue(), ^{ 458 | NSDictionary * userIdentity = [Gleap getIdentity]; 459 | resolve(userIdentity); 460 | }); 461 | } 462 | 463 | RCT_EXPORT_METHOD(isOpened:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) 464 | { 465 | dispatch_async(dispatch_get_main_queue(), ^{ 466 | resolve(@([Gleap isOpened])); 467 | }); 468 | } 469 | 470 | RCT_EXPORT_METHOD(isUserIdentified:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) 471 | { 472 | dispatch_async(dispatch_get_main_queue(), ^{ 473 | BOOL isUserIdentified = [Gleap isUserIdentified]; 474 | resolve(@(isUserIdentified)); 475 | }); 476 | } 477 | 478 | RCT_EXPORT_METHOD(updateContact: (NSDictionary *)userProperties) 479 | { 480 | dispatch_async(dispatch_get_main_queue(), ^{ 481 | GleapUserProperty *userProperty = [[GleapUserProperty alloc] init]; 482 | if (userProperties != nil && [userProperties objectForKey: @"name"] != nil) { 483 | userProperty.name = [userProperties objectForKey: @"name"]; 484 | } 485 | if (userProperties != nil && [userProperties objectForKey: @"email"] != nil) { 486 | userProperty.email = [userProperties objectForKey: @"email"]; 487 | } 488 | if (userProperties != nil && [userProperties objectForKey: @"phone"] != nil) { 489 | userProperty.phone = [userProperties objectForKey: @"phone"]; 490 | } 491 | if (userProperties != nil && [userProperties objectForKey: @"value"] != nil) { 492 | userProperty.value = [userProperties objectForKey: @"value"]; 493 | } 494 | if (userProperties != nil && [userProperties objectForKey: @"sla"] != nil) { 495 | userProperty.sla = [userProperties objectForKey: @"sla"]; 496 | } 497 | if (userProperties != nil && [userProperties objectForKey: @"plan"] != nil) { 498 | userProperty.plan = [userProperties objectForKey: @"plan"]; 499 | } 500 | if (userProperties != nil && [userProperties objectForKey: @"companyName"] != nil) { 501 | userProperty.companyName = [userProperties objectForKey: @"companyName"]; 502 | } 503 | if (userProperties != nil && [userProperties objectForKey: @"companyId"] != nil) { 504 | userProperty.companyId = [userProperties objectForKey: @"companyId"]; 505 | } 506 | if (userProperties != nil && [userProperties objectForKey: @"avatar"] != nil) { 507 | userProperty.avatar = [userProperties objectForKey: @"avatar"]; 508 | } 509 | if (userProperties != nil && [userProperties objectForKey: @"customData"] != nil) { 510 | userProperty.customData = [userProperties objectForKey: @"customData"]; 511 | } 512 | [Gleap updateContact: userProperty]; 513 | }); 514 | } 515 | 516 | RCT_EXPORT_METHOD(identifyWithUserHash:(NSString *)userId withUserProperties: (NSDictionary *)userProperties andUserHash:(NSString *)userHash) 517 | { 518 | dispatch_async(dispatch_get_main_queue(), ^{ 519 | GleapUserProperty *userProperty = [[GleapUserProperty alloc] init]; 520 | if (userProperties != nil && [userProperties objectForKey: @"name"] != nil) { 521 | userProperty.name = [userProperties objectForKey: @"name"]; 522 | } 523 | if (userProperties != nil && [userProperties objectForKey: @"email"] != nil) { 524 | userProperty.email = [userProperties objectForKey: @"email"]; 525 | } 526 | if (userProperties != nil && [userProperties objectForKey: @"phone"] != nil) { 527 | userProperty.phone = [userProperties objectForKey: @"phone"]; 528 | } 529 | if (userProperties != nil && [userProperties objectForKey: @"value"] != nil) { 530 | userProperty.value = [userProperties objectForKey: @"value"]; 531 | } 532 | if (userProperties != nil && [userProperties objectForKey: @"plan"] != nil) { 533 | userProperty.plan = [userProperties objectForKey: @"plan"]; 534 | } 535 | if (userProperties != nil && [userProperties objectForKey: @"sla"] != nil) { 536 | userProperty.sla = [userProperties objectForKey: @"sla"]; 537 | } 538 | if (userProperties != nil && [userProperties objectForKey: @"companyName"] != nil) { 539 | userProperty.companyName = [userProperties objectForKey: @"companyName"]; 540 | } 541 | if (userProperties != nil && [userProperties objectForKey: @"companyId"] != nil) { 542 | userProperty.companyId = [userProperties objectForKey: @"companyId"]; 543 | } 544 | if (userProperties != nil && [userProperties objectForKey: @"avatar"] != nil) { 545 | userProperty.avatar = [userProperties objectForKey: @"avatar"]; 546 | } 547 | if (userProperties != nil && [userProperties objectForKey: @"customData"] != nil) { 548 | userProperty.customData = [userProperties objectForKey: @"customData"]; 549 | } 550 | [Gleap identifyContact: userId andData: userProperty andUserHash: userHash]; 551 | }); 552 | } 553 | 554 | RCT_EXPORT_METHOD(identify:(NSString *)userId withUserProperties: (NSDictionary *)userProperties) 555 | { 556 | dispatch_async(dispatch_get_main_queue(), ^{ 557 | GleapUserProperty *userProperty = [[GleapUserProperty alloc] init]; 558 | if (userProperties != nil && [userProperties objectForKey: @"name"] != nil) { 559 | userProperty.name = [userProperties objectForKey: @"name"]; 560 | } 561 | if (userProperties != nil && [userProperties objectForKey: @"email"] != nil) { 562 | userProperty.email = [userProperties objectForKey: @"email"]; 563 | } 564 | if (userProperties != nil && [userProperties objectForKey: @"phone"] != nil) { 565 | userProperty.phone = [userProperties objectForKey: @"phone"]; 566 | } 567 | if (userProperties != nil && [userProperties objectForKey: @"value"] != nil) { 568 | userProperty.value = [userProperties objectForKey: @"value"]; 569 | } 570 | if (userProperties != nil && [userProperties objectForKey: @"sla"] != nil) { 571 | userProperty.sla = [userProperties objectForKey: @"sla"]; 572 | } 573 | if (userProperties != nil && [userProperties objectForKey: @"plan"] != nil) { 574 | userProperty.plan = [userProperties objectForKey: @"plan"]; 575 | } 576 | if (userProperties != nil && [userProperties objectForKey: @"companyName"] != nil) { 577 | userProperty.companyName = [userProperties objectForKey: @"companyName"]; 578 | } 579 | if (userProperties != nil && [userProperties objectForKey: @"companyId"] != nil) { 580 | userProperty.companyId = [userProperties objectForKey: @"companyId"]; 581 | } 582 | if (userProperties != nil && [userProperties objectForKey: @"avatar"] != nil) { 583 | userProperty.avatar = [userProperties objectForKey: @"avatar"]; 584 | } 585 | if (userProperties != nil && [userProperties objectForKey: @"customData"] != nil) { 586 | userProperty.customData = [userProperties objectForKey: @"customData"]; 587 | } 588 | [Gleap identifyContact: userId andData: userProperty]; 589 | }); 590 | } 591 | 592 | RCT_EXPORT_METHOD(preFillForm:(NSDictionary *)formData) 593 | { 594 | dispatch_async(dispatch_get_main_queue(), ^{ 595 | [Gleap preFillForm: formData]; 596 | }); 597 | } 598 | 599 | RCT_EXPORT_METHOD(attachCustomData:(NSDictionary *)customData) 600 | { 601 | dispatch_async(dispatch_get_main_queue(), ^{ 602 | [Gleap attachCustomData: customData]; 603 | }); 604 | } 605 | 606 | RCT_EXPORT_METHOD(setTicketAttribute:(NSString *)key andValue:(NSString *)value) 607 | { 608 | dispatch_async(dispatch_get_main_queue(), ^{ 609 | [Gleap setTicketAttributeWithKey: key value: value]; 610 | }); 611 | } 612 | 613 | RCT_EXPORT_METHOD(unsetTicketAttribute:(NSString *)key) { 614 | dispatch_async(dispatch_get_main_queue(), ^{ 615 | [Gleap unsetTicketAttributeWithKey: key]; 616 | }); 617 | } 618 | 619 | RCT_EXPORT_METHOD(clearTicketAttributes) { 620 | dispatch_async(dispatch_get_main_queue(), ^{ 621 | [Gleap clearTicketAttributes]; 622 | }); 623 | } 624 | 625 | RCT_EXPORT_METHOD(setAiTools:(NSArray *)toolsArray) { 626 | dispatch_async(dispatch_get_main_queue(), ^{ 627 | @try { 628 | NSMutableArray *aiTools = [[NSMutableArray alloc] init]; 629 | 630 | for (NSDictionary *toolDict in toolsArray) { 631 | // Safely unwrap tool dictionary properties 632 | NSString *name = toolDict[@"name"]; 633 | NSString *toolDescription = toolDict[@"description"]; 634 | NSString *response = toolDict[@"response"]; 635 | NSString *executionType = toolDict[@"executionType"]; 636 | NSArray *parametersArray = toolDict[@"parameters"]; 637 | 638 | if (name && toolDescription && response && parametersArray) { 639 | NSMutableArray *parameters = [[NSMutableArray alloc] init]; 640 | 641 | for (NSDictionary *paramDict in parametersArray) { 642 | // Safely unwrap parameter dictionary properties 643 | NSString *paramName = paramDict[@"name"]; 644 | NSString *paramDescription = paramDict[@"description"]; 645 | NSString *type = paramDict[@"type"]; 646 | NSNumber *required = paramDict[@"required"]; 647 | NSArray *enums = paramDict[@"enum"]; 648 | if (enums == nil) { 649 | enums = [[NSArray alloc] init]; 650 | } 651 | 652 | // Check for required properties in parameter dictionary 653 | if (paramName && paramDescription && type && required) { 654 | GleapAiToolParameter *parameter = [[GleapAiToolParameter alloc] 655 | initWithName:paramName 656 | parameterDescription:paramDescription 657 | type:type 658 | required:[required boolValue] 659 | enums:enums]; 660 | 661 | [parameters addObject:parameter]; 662 | } 663 | } 664 | 665 | GleapAiTool *aiTool = [[GleapAiTool alloc] 666 | initWithName:name 667 | toolDescription:toolDescription 668 | response:response 669 | executionType:executionType 670 | parameters:parameters]; 671 | 672 | [aiTools addObject:aiTool]; 673 | } 674 | } 675 | 676 | [Gleap setAiTools:aiTools]; 677 | } @catch (NSException *exception) { 678 | 679 | } 680 | }); 681 | } 682 | 683 | RCT_EXPORT_METHOD(setCustomData:(NSString *)key andValue:(NSString *)value) 684 | { 685 | dispatch_async(dispatch_get_main_queue(), ^{ 686 | [Gleap setCustomData: value forKey: key]; 687 | }); 688 | } 689 | 690 | RCT_EXPORT_METHOD(removeCustomDataForKey:(NSString *)key) 691 | { 692 | dispatch_async(dispatch_get_main_queue(), ^{ 693 | [Gleap removeCustomDataForKey: key]; 694 | }); 695 | } 696 | 697 | RCT_EXPORT_METHOD(clearCustomData) 698 | { 699 | dispatch_async(dispatch_get_main_queue(), ^{ 700 | [Gleap clearCustomData]; 701 | }); 702 | } 703 | 704 | RCT_EXPORT_METHOD(setApiUrl: (NSString *)apiUrl) 705 | { 706 | dispatch_async(dispatch_get_main_queue(), ^{ 707 | [Gleap setApiUrl: apiUrl]; 708 | }); 709 | } 710 | 711 | RCT_EXPORT_METHOD(setFrameUrl: (NSString *)frameUrl) 712 | { 713 | dispatch_async(dispatch_get_main_queue(), ^{ 714 | [Gleap setFrameUrl: frameUrl]; 715 | }); 716 | } 717 | 718 | RCT_EXPORT_METHOD(showFeedbackButton: (BOOL)show) 719 | { 720 | dispatch_async(dispatch_get_main_queue(), ^{ 721 | [Gleap showFeedbackButton: show]; 722 | }); 723 | } 724 | 725 | RCT_EXPORT_METHOD(trackPage:(NSString *)pageName) 726 | { 727 | dispatch_async(dispatch_get_main_queue(), ^{ 728 | [Gleap trackEvent: @"pageView" withData: @{ 729 | @"page": pageName 730 | }]; 731 | }); 732 | } 733 | 734 | RCT_EXPORT_METHOD(trackEvent:(NSString *)name andData:(NSDictionary *)data) 735 | { 736 | dispatch_async(dispatch_get_main_queue(), ^{ 737 | [Gleap trackEvent: name withData: data]; 738 | }); 739 | } 740 | 741 | RCT_EXPORT_METHOD(removeAllAttachments) 742 | { 743 | dispatch_async(dispatch_get_main_queue(), ^{ 744 | [Gleap removeAllAttachments]; 745 | }); 746 | } 747 | 748 | RCT_EXPORT_METHOD(addAttachment:(NSString *)base64file withFileName:(NSString *)fileName) 749 | { 750 | dispatch_async(dispatch_get_main_queue(), ^{ 751 | NSArray *dataParts = [base64file componentsSeparatedByString: @";base64,"]; 752 | NSData *fileData = [[NSData alloc] initWithBase64EncodedString: [dataParts lastObject] options:0]; 753 | if (fileData != nil) { 754 | [Gleap addAttachmentWithData: fileData andName: fileName]; 755 | } else { 756 | NSLog(@"[Gleap]: Invalid base64 string passed."); 757 | } 758 | }); 759 | } 760 | 761 | - (void)dealloc 762 | { 763 | @try{ 764 | [[NSNotificationCenter defaultCenter] removeObserver: self]; 765 | } @catch(id anException) {} 766 | } 767 | 768 | @end 769 | 770 | -------------------------------------------------------------------------------- /ios/Gleapsdk.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 11 | 5E555C0D2413F4C50049A1A2 /* Gleapsdk.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* Gleapsdk.m */; }; 12 | 13 | /* End PBXBuildFile section */ 14 | 15 | /* Begin PBXCopyFilesBuildPhase section */ 16 | 58B511D91A9E6C8500147676 /* CopyFiles */ = { 17 | isa = PBXCopyFilesBuildPhase; 18 | buildActionMask = 2147483647; 19 | dstPath = "include/$(PRODUCT_NAME)"; 20 | dstSubfolderSpec = 16; 21 | files = ( 22 | ); 23 | runOnlyForDeploymentPostprocessing = 0; 24 | }; 25 | /* End PBXCopyFilesBuildPhase section */ 26 | 27 | /* Begin PBXFileReference section */ 28 | 134814201AA4EA6300B7C361 /* libGleapsdk.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libGleapsdk.a; sourceTree = BUILT_PRODUCTS_DIR; }; 29 | 30 | B3E7B5881CC2AC0600A0062D /* Gleapsdk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Gleapsdk.h; sourceTree = ""; }; 31 | B3E7B5891CC2AC0600A0062D /* Gleapsdk.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Gleapsdk.m; sourceTree = ""; }; 32 | 33 | /* End PBXFileReference section */ 34 | 35 | /* Begin PBXFrameworksBuildPhase section */ 36 | 58B511D81A9E6C8500147676 /* Frameworks */ = { 37 | isa = PBXFrameworksBuildPhase; 38 | buildActionMask = 2147483647; 39 | files = ( 40 | ); 41 | runOnlyForDeploymentPostprocessing = 0; 42 | }; 43 | /* End PBXFrameworksBuildPhase section */ 44 | 45 | /* Begin PBXGroup section */ 46 | 134814211AA4EA7D00B7C361 /* Products */ = { 47 | isa = PBXGroup; 48 | children = ( 49 | 134814201AA4EA6300B7C361 /* libGleapsdk.a */, 50 | ); 51 | name = Products; 52 | sourceTree = ""; 53 | }; 54 | 58B511D21A9E6C8500147676 = { 55 | isa = PBXGroup; 56 | children = ( 57 | 58 | B3E7B5881CC2AC0600A0062D /* Gleapsdk.h */, 59 | B3E7B5891CC2AC0600A0062D /* Gleapsdk.m */, 60 | 61 | 134814211AA4EA7D00B7C361 /* Products */, 62 | ); 63 | sourceTree = ""; 64 | }; 65 | /* End PBXGroup section */ 66 | 67 | /* Begin PBXNativeTarget section */ 68 | 58B511DA1A9E6C8500147676 /* Gleapsdk */ = { 69 | isa = PBXNativeTarget; 70 | buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "Gleapsdk" */; 71 | buildPhases = ( 72 | 58B511D71A9E6C8500147676 /* Sources */, 73 | 58B511D81A9E6C8500147676 /* Frameworks */, 74 | 58B511D91A9E6C8500147676 /* CopyFiles */, 75 | ); 76 | buildRules = ( 77 | ); 78 | dependencies = ( 79 | ); 80 | name = Gleapsdk; 81 | productName = RCTDataManager; 82 | productReference = 134814201AA4EA6300B7C361 /* libGleapsdk.a */; 83 | productType = "com.apple.product-type.library.static"; 84 | }; 85 | /* End PBXNativeTarget section */ 86 | 87 | /* Begin PBXProject section */ 88 | 58B511D31A9E6C8500147676 /* Project object */ = { 89 | isa = PBXProject; 90 | attributes = { 91 | LastUpgradeCheck = 0920; 92 | ORGANIZATIONNAME = Facebook; 93 | TargetAttributes = { 94 | 58B511DA1A9E6C8500147676 = { 95 | CreatedOnToolsVersion = 6.1.1; 96 | }; 97 | }; 98 | }; 99 | buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "Gleapsdk" */; 100 | compatibilityVersion = "Xcode 3.2"; 101 | developmentRegion = English; 102 | hasScannedForEncodings = 0; 103 | knownRegions = ( 104 | English, 105 | en, 106 | ); 107 | mainGroup = 58B511D21A9E6C8500147676; 108 | productRefGroup = 58B511D21A9E6C8500147676; 109 | projectDirPath = ""; 110 | projectRoot = ""; 111 | targets = ( 112 | 58B511DA1A9E6C8500147676 /* Gleapsdk */, 113 | ); 114 | }; 115 | /* End PBXProject section */ 116 | 117 | /* Begin PBXSourcesBuildPhase section */ 118 | 58B511D71A9E6C8500147676 /* Sources */ = { 119 | isa = PBXSourcesBuildPhase; 120 | buildActionMask = 2147483647; 121 | files = ( 122 | 123 | B3E7B58A1CC2AC0600A0062D /* Gleapsdk.m in Sources */, 124 | 125 | ); 126 | runOnlyForDeploymentPostprocessing = 0; 127 | }; 128 | /* End PBXSourcesBuildPhase section */ 129 | 130 | /* Begin XCBuildConfiguration section */ 131 | 58B511ED1A9E6C8500147676 /* Debug */ = { 132 | isa = XCBuildConfiguration; 133 | buildSettings = { 134 | ALWAYS_SEARCH_USER_PATHS = NO; 135 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 136 | CLANG_CXX_LIBRARY = "libc++"; 137 | CLANG_ENABLE_MODULES = YES; 138 | CLANG_ENABLE_OBJC_ARC = YES; 139 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 140 | CLANG_WARN_BOOL_CONVERSION = YES; 141 | CLANG_WARN_COMMA = YES; 142 | CLANG_WARN_CONSTANT_CONVERSION = YES; 143 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 144 | CLANG_WARN_EMPTY_BODY = YES; 145 | CLANG_WARN_ENUM_CONVERSION = YES; 146 | CLANG_WARN_INFINITE_RECURSION = YES; 147 | CLANG_WARN_INT_CONVERSION = YES; 148 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 149 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 150 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 151 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 152 | CLANG_WARN_STRICT_PROTOTYPES = YES; 153 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 154 | CLANG_WARN_UNREACHABLE_CODE = YES; 155 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 156 | COPY_PHASE_STRIP = NO; 157 | ENABLE_STRICT_OBJC_MSGSEND = YES; 158 | ENABLE_TESTABILITY = YES; 159 | GCC_C_LANGUAGE_STANDARD = gnu99; 160 | GCC_DYNAMIC_NO_PIC = NO; 161 | GCC_NO_COMMON_BLOCKS = YES; 162 | GCC_OPTIMIZATION_LEVEL = 0; 163 | GCC_PREPROCESSOR_DEFINITIONS = ( 164 | "DEBUG=1", 165 | "$(inherited)", 166 | ); 167 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 168 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 169 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 170 | GCC_WARN_UNDECLARED_SELECTOR = YES; 171 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 172 | GCC_WARN_UNUSED_FUNCTION = YES; 173 | GCC_WARN_UNUSED_VARIABLE = YES; 174 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 175 | MTL_ENABLE_DEBUG_INFO = YES; 176 | ONLY_ACTIVE_ARCH = YES; 177 | SDKROOT = iphoneos; 178 | }; 179 | name = Debug; 180 | }; 181 | 58B511EE1A9E6C8500147676 /* Release */ = { 182 | isa = XCBuildConfiguration; 183 | buildSettings = { 184 | ALWAYS_SEARCH_USER_PATHS = NO; 185 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 186 | CLANG_CXX_LIBRARY = "libc++"; 187 | CLANG_ENABLE_MODULES = YES; 188 | CLANG_ENABLE_OBJC_ARC = YES; 189 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 190 | CLANG_WARN_BOOL_CONVERSION = YES; 191 | CLANG_WARN_COMMA = YES; 192 | CLANG_WARN_CONSTANT_CONVERSION = YES; 193 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 194 | CLANG_WARN_EMPTY_BODY = YES; 195 | CLANG_WARN_ENUM_CONVERSION = YES; 196 | CLANG_WARN_INFINITE_RECURSION = YES; 197 | CLANG_WARN_INT_CONVERSION = YES; 198 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 199 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 200 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 201 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 202 | CLANG_WARN_STRICT_PROTOTYPES = YES; 203 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 204 | CLANG_WARN_UNREACHABLE_CODE = YES; 205 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 206 | COPY_PHASE_STRIP = YES; 207 | ENABLE_NS_ASSERTIONS = NO; 208 | ENABLE_STRICT_OBJC_MSGSEND = YES; 209 | GCC_C_LANGUAGE_STANDARD = gnu99; 210 | GCC_NO_COMMON_BLOCKS = YES; 211 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 212 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 213 | GCC_WARN_UNDECLARED_SELECTOR = YES; 214 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 215 | GCC_WARN_UNUSED_FUNCTION = YES; 216 | GCC_WARN_UNUSED_VARIABLE = YES; 217 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 218 | MTL_ENABLE_DEBUG_INFO = NO; 219 | SDKROOT = iphoneos; 220 | VALIDATE_PRODUCT = YES; 221 | }; 222 | name = Release; 223 | }; 224 | 58B511F01A9E6C8500147676 /* Debug */ = { 225 | isa = XCBuildConfiguration; 226 | buildSettings = { 227 | HEADER_SEARCH_PATHS = ( 228 | "$(inherited)", 229 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 230 | "$(SRCROOT)/../../../React/**", 231 | "$(SRCROOT)/../../react-native/React/**", 232 | ); 233 | LIBRARY_SEARCH_PATHS = "$(inherited)"; 234 | OTHER_LDFLAGS = "-ObjC"; 235 | PRODUCT_NAME = Gleapsdk; 236 | SKIP_INSTALL = YES; 237 | 238 | }; 239 | name = Debug; 240 | }; 241 | 58B511F11A9E6C8500147676 /* Release */ = { 242 | isa = XCBuildConfiguration; 243 | buildSettings = { 244 | HEADER_SEARCH_PATHS = ( 245 | "$(inherited)", 246 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 247 | "$(SRCROOT)/../../../React/**", 248 | "$(SRCROOT)/../../react-native/React/**", 249 | ); 250 | LIBRARY_SEARCH_PATHS = "$(inherited)"; 251 | OTHER_LDFLAGS = "-ObjC"; 252 | PRODUCT_NAME = Gleapsdk; 253 | SKIP_INSTALL = YES; 254 | 255 | }; 256 | name = Release; 257 | }; 258 | /* End XCBuildConfiguration section */ 259 | 260 | /* Begin XCConfigurationList section */ 261 | 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "Gleapsdk" */ = { 262 | isa = XCConfigurationList; 263 | buildConfigurations = ( 264 | 58B511ED1A9E6C8500147676 /* Debug */, 265 | 58B511EE1A9E6C8500147676 /* Release */, 266 | ); 267 | defaultConfigurationIsVisible = 0; 268 | defaultConfigurationName = Release; 269 | }; 270 | 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "Gleapsdk" */ = { 271 | isa = XCConfigurationList; 272 | buildConfigurations = ( 273 | 58B511F01A9E6C8500147676 /* Debug */, 274 | 58B511F11A9E6C8500147676 /* Release */, 275 | ); 276 | defaultConfigurationIsVisible = 0; 277 | defaultConfigurationName = Release; 278 | }; 279 | /* End XCConfigurationList section */ 280 | }; 281 | rootObject = 58B511D31A9E6C8500147676 /* Project object */; 282 | } 283 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-gleapsdk", 3 | "version": "14.6.4", 4 | "description": "Know exactly why and how a bug happened. Get reports with screenshots, live action replays and all of the important metadata every time.", 5 | "main": "lib/commonjs/index", 6 | "module": "lib/module/index", 7 | "types": "lib/typescript/index.d.ts", 8 | "react-native": "src/index", 9 | "source": "src/index", 10 | "files": [ 11 | "src", 12 | "lib", 13 | "android", 14 | "ios", 15 | "cpp", 16 | "react-native-gleapsdk.podspec", 17 | "!lib/typescript/example", 18 | "!android/build", 19 | "!ios/build", 20 | "!**/__tests__", 21 | "!**/__fixtures__", 22 | "!**/__mocks__" 23 | ], 24 | "scripts": { 25 | "test": "jest", 26 | "typescript": "tsc --noEmit", 27 | "lint": "eslint \"**/*.{js,ts,tsx}\"", 28 | "prepare": "bob build", 29 | "release": "release-it", 30 | "example": "yarn --cwd example", 31 | "pods": "cd example && pod-install --quiet", 32 | "bootstrap": "yarn example && yarn && yarn pods" 33 | }, 34 | "keywords": [ 35 | "react-native", 36 | "ios", 37 | "android" 38 | ], 39 | "repository": "https://github.com/GleapSDK/ReactNative-SDK", 40 | "author": "gleap (https://github.com/GleapSDK)", 41 | "license": "MIT", 42 | "bugs": { 43 | "url": "https://github.com/GleapSDK/ReactNative-SDK/issues" 44 | }, 45 | "homepage": "https://github.com/GleapSDK/ReactNative-SDK#readme", 46 | "publishConfig": { 47 | "registry": "https://registry.npmjs.org/" 48 | }, 49 | "devDependencies": { 50 | "@commitlint/config-conventional": "^11.0.0", 51 | "@react-native-community/eslint-config": "^2.0.0", 52 | "@release-it/conventional-changelog": "^2.0.0", 53 | "@types/jest": "^26.0.0", 54 | "@types/react-native": "^0.72.2", 55 | "commitlint": "^11.0.0", 56 | "eslint": "^7.2.0", 57 | "eslint-config-prettier": "^7.0.0", 58 | "eslint-plugin-prettier": "^3.1.3", 59 | "husky": "^6.0.0", 60 | "jest": "^26.0.1", 61 | "pod-install": "^0.1.0", 62 | "prettier": "^2.0.5", 63 | "react": "^17.0.2", 64 | "react-native": "^0.66.0", 65 | "react-native-builder-bob": "^0.20.4", 66 | "release-it": "^14.2.2", 67 | "typescript": "^4.1.3" 68 | }, 69 | "peerDependencies": { 70 | "react": "*", 71 | "react-native": "*" 72 | }, 73 | "jest": { 74 | "preset": "react-native", 75 | "modulePathIgnorePatterns": [ 76 | "/example/node_modules", 77 | "/lib/" 78 | ] 79 | }, 80 | "commitlint": { 81 | "extends": [ 82 | "@commitlint/config-conventional" 83 | ] 84 | }, 85 | "release-it": { 86 | "git": { 87 | "commitMessage": "chore: release ${version}", 88 | "tagName": "v${version}" 89 | }, 90 | "npm": { 91 | "publish": true 92 | }, 93 | "github": { 94 | "release": true 95 | }, 96 | "plugins": { 97 | "@release-it/conventional-changelog": { 98 | "preset": "angular" 99 | } 100 | } 101 | }, 102 | "eslintConfig": { 103 | "root": true, 104 | "extends": [ 105 | "@react-native-community", 106 | "prettier" 107 | ], 108 | "rules": { 109 | "prettier/prettier": [ 110 | "error", 111 | { 112 | "quoteProps": "consistent", 113 | "singleQuote": true, 114 | "tabWidth": 2, 115 | "trailingComma": "es5", 116 | "useTabs": false 117 | } 118 | ] 119 | } 120 | }, 121 | "eslintIgnore": [ 122 | "node_modules/", 123 | "lib/" 124 | ], 125 | "prettier": { 126 | "quoteProps": "consistent", 127 | "singleQuote": true, 128 | "tabWidth": 2, 129 | "trailingComma": "es5", 130 | "useTabs": false 131 | }, 132 | "react-native-builder-bob": { 133 | "source": "src", 134 | "output": "lib", 135 | "targets": [ 136 | "commonjs", 137 | "module", 138 | [ 139 | "typescript", 140 | { 141 | "project": "tsconfig.build.json" 142 | } 143 | ] 144 | ] 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /react-native-gleapsdk.podspec: -------------------------------------------------------------------------------- 1 | require "json" 2 | 3 | package = JSON.parse(File.read(File.join(__dir__, "package.json"))) 4 | 5 | Pod::Spec.new do |s| 6 | s.name = "react-native-gleapsdk" 7 | s.version = package["version"] 8 | s.summary = package["description"] 9 | s.homepage = package["homepage"] 10 | s.license = package["license"] 11 | s.authors = package["author"] 12 | 13 | s.platforms = { :ios => "10.0" } 14 | s.source = { :git => "https://github.com/GleapSDK/ReactNative-SDK.git", :tag => "#{s.version}" } 15 | 16 | s.source_files = "ios/**/*.{h,m,mm}" 17 | 18 | s.dependency "React-Core" 19 | s.dependency "Gleap", "14.6.2" 20 | end 21 | -------------------------------------------------------------------------------- /scripts/bootstrap.js: -------------------------------------------------------------------------------- 1 | const os = require('os'); 2 | const path = require('path'); 3 | const child_process = require('child_process'); 4 | 5 | const root = path.resolve(__dirname, '..'); 6 | const args = process.argv.slice(2); 7 | const options = { 8 | cwd: process.cwd(), 9 | env: process.env, 10 | stdio: 'inherit', 11 | encoding: 'utf-8', 12 | }; 13 | 14 | if (os.type() === 'Windows_NT') { 15 | options.shell = true; 16 | } 17 | 18 | let result; 19 | 20 | if (process.cwd() !== root || args.length) { 21 | // We're not in the root of the project, or additional arguments were passed 22 | // In this case, forward the command to `yarn` 23 | result = child_process.spawnSync('yarn', args, options); 24 | } else { 25 | // If `yarn` is run without arguments, perform bootstrap 26 | result = child_process.spawnSync('yarn', ['bootstrap'], options); 27 | } 28 | 29 | process.exitCode = result.status; 30 | -------------------------------------------------------------------------------- /src/__tests__/index.test.tsx: -------------------------------------------------------------------------------- 1 | it.todo('write a test'); 2 | -------------------------------------------------------------------------------- /src/index.tsx: -------------------------------------------------------------------------------- 1 | import { NativeModules, NativeEventEmitter, Platform } from 'react-native'; 2 | import GleapNetworkIntercepter from './networklogger'; 3 | 4 | const LINKING_ERROR = 5 | `The package 'react-native-gleapsdk' doesn't seem to be linked. Make sure: \n\n` + 6 | Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) + 7 | '- You rebuilt the app after installing the package\n' + 8 | '- You are not using Expo managed workflow\n'; 9 | 10 | export type GleapUserProperty = { 11 | email?: string; 12 | name?: string; 13 | phone?: string; 14 | value?: number; 15 | sla?: number; 16 | plan?: string; 17 | companyName?: string; 18 | companyId?: string; 19 | avatar?: string; 20 | customData?: { [key: string]: string | number }; 21 | }; 22 | 23 | type GleapActivationMethod = 'SHAKE' | 'SCREENSHOT'; 24 | 25 | type GleapSdkType = { 26 | initialize(token: string): void; 27 | startFeedbackFlow(feedbackFlow: string, showBackButton: boolean): void; 28 | startBot(botId: string, showBackButton: boolean): void; 29 | sendSilentCrashReport( 30 | description: string, 31 | severity: 'LOW' | 'MEDIUM' | 'HIGH' 32 | ): void; 33 | sendSilentCrashReportWithExcludeData( 34 | description: string, 35 | severity: 'LOW' | 'MEDIUM' | 'HIGH', 36 | excludeData: { 37 | customData?: Boolean; 38 | metaData?: Boolean; 39 | attachments?: Boolean; 40 | consoleLog?: Boolean; 41 | networkLogs?: Boolean; 42 | customEventLog?: Boolean; 43 | screenshot?: Boolean; 44 | replays?: Boolean; 45 | } 46 | ): void; 47 | openConversations(showBackButton: boolean): void; 48 | openConversation(shareToken: string): void; 49 | startConversation(showBackButton: boolean): void; 50 | startClassicForm(formId: string, showBackButton: boolean): void; 51 | open(): void; 52 | openNews(showBackButton: boolean): void; 53 | openNewsArticle(articleId: string, showBackButton: boolean): void; 54 | openChecklists(showBackButton: boolean): void; 55 | openChecklist(checklistId: string, showBackButton: boolean): void; 56 | startChecklist(outboundId: string, showBackButton: boolean): void; 57 | openFeatureRequests(showBackButton: boolean): void; 58 | openHelpCenter(showBackButton: boolean): void; 59 | openHelpCenterCollection(collectionId: string, showBackButton: boolean): void; 60 | openHelpCenterArticle(articleId: string, showBackButton: boolean): void; 61 | searchHelpCenter(term: string, showBackButton: boolean): void; 62 | close(): void; 63 | isOpened(): Promise; 64 | identify(userId: string, userProperties: GleapUserProperty): void; 65 | identifyWithUserHash( 66 | userId: string, 67 | userProperties: GleapUserProperty, 68 | userHash: string 69 | ): void; 70 | updateContact(userProperties: GleapUserProperty): void; 71 | showFeedbackButton(show: boolean): void; 72 | clearIdentity(): void; 73 | preFillForm(formData: { [key: string]: string }): void; 74 | setNetworkLogsBlacklist(networkLogBlacklist: string[]): void; 75 | setNetworkLogPropsToIgnore(networkLogPropsToIgnore: string[]): void; 76 | setApiUrl(apiUrl: string): void; 77 | setFrameUrl(frameUrl: string): void; 78 | attachCustomData(customData: any): void; 79 | setCustomData(key: string, value: string): void; 80 | removeCustomDataForKey(key: string): void; 81 | clearCustomData(): void; 82 | setDisableInAppNotifications(disableInAppNotifications: boolean): void; 83 | registerListener(eventType: string, callback: (data?: any) => void): void; 84 | setLanguage(language: string): void; 85 | enableDebugConsoleLog(): void; 86 | disableConsoleLog(): void; 87 | setTags(tags: string[]): void; 88 | trackPage(pageName: String): void; 89 | showSurvey(surveyId: String, format: 'survey' | 'survey_full'): void; 90 | log(message: string): void; 91 | logWithLogLevel( 92 | message: string, 93 | logLevel: 'INFO' | 'WARNING' | 'ERROR' 94 | ): void; 95 | logEvent(name: string, data: any): void; 96 | trackEvent(name: string, data: any): void; 97 | addAttachment(base64file: string, fileName: string): void; 98 | removeAllAttachments(): void; 99 | startNetworkLogging(): void; 100 | stopNetworkLogging(): void; 101 | setActivationMethods(activationMethods: GleapActivationMethod[]): void; 102 | registerCustomAction( 103 | customActionCallback: (data: { name: string; shareToken?: string }) => void 104 | ): void; 105 | getIdentity(): Promise; 106 | isUserIdentified(): Promise; 107 | setTicketAttribute(key: string, value: string): void; 108 | unsetTicketAttribute(key: string): void; 109 | clearTicketAttributes(): void; 110 | setAiTools( 111 | tools: { 112 | name: string; 113 | description: string; 114 | response: string; 115 | executionType: 'auto' | 'button'; 116 | parameters: { 117 | name: string; 118 | description: string; 119 | type: 'string' | 'number' | 'boolean'; 120 | required: boolean; 121 | enums?: string[]; 122 | }[]; 123 | }[] 124 | ): void; 125 | }; 126 | 127 | const GleapSdk = NativeModules.Gleapsdk 128 | ? NativeModules.Gleapsdk 129 | : new Proxy( 130 | {}, 131 | { 132 | get() { 133 | throw new Error(LINKING_ERROR); 134 | }, 135 | } 136 | ); 137 | 138 | if (GleapSdk && !GleapSdk.touched) { 139 | const networkLogger = new GleapNetworkIntercepter(); 140 | 141 | // Push the network log to the native SDK. 142 | GleapSdk.startNetworkLogging = () => { 143 | // Set the callback. 144 | networkLogger.setUpdatedCallback(() => { 145 | if (!networkLogger) { 146 | return; 147 | } 148 | 149 | const requests = networkLogger.getRequests(); 150 | 151 | if ( 152 | requests && 153 | GleapSdk && 154 | typeof GleapSdk.attachNetworkLog !== 'undefined' 155 | ) { 156 | if (Platform.OS === 'android') { 157 | GleapSdk.attachNetworkLog(JSON.stringify(requests)); 158 | } else { 159 | GleapSdk.attachNetworkLog(JSON.parse(JSON.stringify(requests))); 160 | } 161 | } 162 | }); 163 | 164 | // Start the logger. 165 | networkLogger.start(); 166 | }; 167 | 168 | GleapSdk.stopNetworkLogging = () => { 169 | networkLogger.setStopped(true); 170 | }; 171 | 172 | // eslint-disable-next-line @typescript-eslint/no-unused-vars 173 | GleapSdk.logEvent = (name: string, data: any) => { 174 | console.log('logEvent is deprecated. Use trackEvent instead.'); 175 | GleapSdk.trackEvent(name, data); 176 | }; 177 | 178 | var callbacks: any = {}; 179 | 180 | GleapSdk.registerListener = (eventType: string, callback: any) => { 181 | if (!callbacks[eventType]) { 182 | callbacks[eventType] = []; 183 | } 184 | callbacks[eventType].push(callback); 185 | }; 186 | 187 | GleapSdk.registerCustomAction = (customActionCallback: any) => { 188 | GleapSdk.registerListener('customActionTriggered', customActionCallback); 189 | }; 190 | 191 | const notifyCallback = function (eventType: string, data?: any) { 192 | if (callbacks && callbacks[eventType] && callbacks[eventType].length > 0) { 193 | for (var i = 0; i < callbacks[eventType].length; i++) { 194 | if (callbacks[eventType][i]) { 195 | callbacks[eventType][i](data); 196 | } 197 | } 198 | } 199 | }; 200 | 201 | const gleapEmitter = new NativeEventEmitter(NativeModules.Gleapsdk); 202 | 203 | gleapEmitter.addListener('configLoaded', (config: any) => { 204 | try { 205 | const configJSON = config instanceof Object ? config : JSON.parse(config); 206 | if (configJSON.enableNetworkLogs) { 207 | GleapSdk.startNetworkLogging(); 208 | } 209 | notifyCallback('configLoaded', configJSON); 210 | } catch (exp) {} 211 | }); 212 | 213 | gleapEmitter.addListener('initialized', () => { 214 | try { 215 | notifyCallback('initialized'); 216 | } catch (exp) {} 217 | }); 218 | 219 | gleapEmitter.addListener('toolExecution', (data) => { 220 | try { 221 | const dataJSON = data instanceof Object ? data : JSON.parse(data); 222 | notifyCallback('toolExecution', dataJSON); 223 | } catch (exp) {} 224 | }); 225 | 226 | gleapEmitter.addListener('feedbackSent', (data) => { 227 | try { 228 | const dataJSON = data instanceof Object ? data : JSON.parse(data); 229 | notifyCallback('feedbackSent', dataJSON); 230 | } catch (exp) {} 231 | }); 232 | 233 | gleapEmitter.addListener('outboundSent', (data) => { 234 | try { 235 | const dataJSON = data instanceof Object ? data : JSON.parse(data); 236 | notifyCallback('outboundSent', dataJSON); 237 | } catch (exp) {} 238 | }); 239 | 240 | gleapEmitter.addListener('feedbackFlowStarted', (feedbackAction) => { 241 | notifyCallback('feedbackFlowStarted', feedbackAction); 242 | }); 243 | 244 | gleapEmitter.addListener('feedbackSendingFailed', () => { 245 | notifyCallback('feedbackSendingFailed'); 246 | }); 247 | 248 | gleapEmitter.addListener('notificationCountUpdated', (count) => { 249 | notifyCallback('notificationCountUpdated', count); 250 | }); 251 | 252 | gleapEmitter.addListener('widgetOpened', () => { 253 | notifyCallback('widgetOpened'); 254 | }); 255 | 256 | gleapEmitter.addListener('widgetClosed', () => { 257 | notifyCallback('widgetClosed'); 258 | }); 259 | 260 | gleapEmitter.addListener('registerPushMessageGroup', (pushMessageGroup) => { 261 | notifyCallback('registerPushMessageGroup', pushMessageGroup); 262 | }); 263 | 264 | gleapEmitter.addListener('unregisterPushMessageGroup', (pushMessageGroup) => { 265 | notifyCallback('unregisterPushMessageGroup', pushMessageGroup); 266 | }); 267 | 268 | function isJsonString(str: string) { 269 | try { 270 | JSON.parse(str); 271 | } catch (e) { 272 | return false; 273 | } 274 | return true; 275 | } 276 | 277 | gleapEmitter.addListener('customActionTriggered', (data: any) => { 278 | try { 279 | if (isJsonString(data)) { 280 | data = JSON.parse(data); 281 | } 282 | const { name, shareToken } = data; 283 | if (name) { 284 | notifyCallback('customActionTriggered', { 285 | name, 286 | shareToken, 287 | }); 288 | } 289 | } catch (exp) {} 290 | }); 291 | 292 | GleapSdk.removeAllAttachments(); 293 | GleapSdk.touched = true; 294 | } 295 | 296 | export default GleapSdk as GleapSdkType; 297 | -------------------------------------------------------------------------------- /src/networklogger.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/no-unused-vars */ 2 | class GleapNetworkIntercepter { 3 | requestId = 0; 4 | requests: any = {}; 5 | maxRequests = 25; 6 | stopped = false; 7 | updatedCallback: any = null; 8 | 9 | setUpdatedCallback(updatedCallback: any) { 10 | this.updatedCallback = updatedCallback; 11 | } 12 | 13 | getRequests() { 14 | return Object.values(this.requests); 15 | } 16 | 17 | setMaxRequests(maxRequests: number) { 18 | this.maxRequests = maxRequests; 19 | } 20 | 21 | setStopped(stopped: boolean) { 22 | this.stopped = stopped; 23 | } 24 | 25 | cleanRequests() { 26 | var keys = Object.keys(this.requests); 27 | if (keys.length > this.maxRequests) { 28 | var keysToRemove = keys.slice(0, keys.length - this.maxRequests); 29 | for (var i = 0; i < keysToRemove.length; i++) { 30 | delete this.requests[keysToRemove[i]]; 31 | } 32 | } 33 | 34 | if (this.updatedCallback) { 35 | this.updatedCallback(); 36 | } 37 | } 38 | 39 | calcRequestTime(gleapRequestId: string | number) { 40 | if (!this.requests[gleapRequestId]) { 41 | return; 42 | } 43 | 44 | var startDate = this.requests[gleapRequestId].date; 45 | if ( 46 | startDate && 47 | typeof startDate.getTime === 'function' && 48 | !Object.isFrozen(this.requests[gleapRequestId]) 49 | ) { 50 | this.requests[gleapRequestId].duration = 51 | new Date().getTime() - startDate.getTime(); 52 | this.requests[gleapRequestId].date = 53 | this.requests[gleapRequestId].date.toString(); 54 | } 55 | } 56 | 57 | getTextContentSizeOk(text: string) { 58 | if (text && text.length) { 59 | const size = text.length * 16; 60 | const kiloBytes = size / 1024; 61 | const megaBytes = kiloBytes / 1024; 62 | if (megaBytes < 0.2) { 63 | return true; 64 | } 65 | } 66 | return false; 67 | } 68 | 69 | prepareContent(text: string) { 70 | if (!this.getTextContentSizeOk(text)) { 71 | return ''; 72 | } 73 | 74 | return text; 75 | } 76 | 77 | cleanupPayload(payload: any) { 78 | if (payload === undefined || payload === null) { 79 | return '{}'; 80 | } 81 | 82 | try { 83 | if (ArrayBuffer.isView(payload)) { 84 | return `{ type: "binary", length: ${payload.byteLength} }`; 85 | } 86 | } catch (exp) {} 87 | 88 | return payload; 89 | } 90 | 91 | preparePayload(payload: any) { 92 | var payloadText = this.cleanupPayload(payload); 93 | return this.prepareContent(payloadText); 94 | } 95 | 96 | start() { 97 | this.setStopped(false); 98 | this.interceptNetworkRequests({ 99 | onFetch: (params: any[], gleapRequestId: any) => { 100 | if (this.stopped || params.length === 0) { 101 | return; 102 | } 103 | 104 | if (params.length >= 2 && params[1] !== undefined) { 105 | var method = params[1].method ? params[1].method : 'GET'; 106 | this.requests[gleapRequestId] = { 107 | request: { 108 | payload: this.preparePayload(params[1].body), 109 | headers: params[1].headers, 110 | }, 111 | type: method, 112 | url: params[0], 113 | date: new Date(), 114 | }; 115 | } else { 116 | this.requests[gleapRequestId] = { 117 | request: {}, 118 | url: params[0], 119 | type: 'GET', 120 | date: new Date(), 121 | }; 122 | } 123 | 124 | this.cleanRequests(); 125 | }, 126 | onFetchLoad: (req: any, gleapRequestId: any) => { 127 | if ( 128 | this.stopped || 129 | !gleapRequestId || 130 | !this.requests || 131 | !this.requests[gleapRequestId] 132 | ) { 133 | return; 134 | } 135 | 136 | try { 137 | this.requests[gleapRequestId].success = true; 138 | this.requests[gleapRequestId].response = { 139 | status: req.status, 140 | statusText: '', 141 | responseText: '', 142 | }; 143 | this.calcRequestTime(gleapRequestId); 144 | } catch (exp) {} 145 | 146 | req 147 | .text() 148 | .then((responseText: any) => { 149 | if (this.requests && this.requests[gleapRequestId]) { 150 | this.requests[gleapRequestId].success = true; 151 | this.requests[gleapRequestId].response = { 152 | status: req.status, 153 | statusText: req.statusText, 154 | responseText: this.prepareContent(responseText), 155 | }; 156 | 157 | this.calcRequestTime(gleapRequestId); 158 | this.cleanRequests(); 159 | } 160 | }) 161 | .catch((_err: any) => { 162 | if (this) { 163 | this.cleanRequests(); 164 | } 165 | }); 166 | }, 167 | onFetchFailed: (_err: any, gleapRequestId: any) => { 168 | if (this.stopped || !gleapRequestId) { 169 | return; 170 | } 171 | 172 | if (this.requests && this.requests[gleapRequestId]) { 173 | this.requests[gleapRequestId].success = false; 174 | this.calcRequestTime(gleapRequestId); 175 | } 176 | this.cleanRequests(); 177 | }, 178 | onOpen: (request: any, args: string | any[]) => { 179 | if (this.stopped) { 180 | return; 181 | } 182 | 183 | if ( 184 | request && 185 | request.gleapRequestId && 186 | args.length >= 2 && 187 | this.requests 188 | ) { 189 | this.requests[request.gleapRequestId] = { 190 | type: args[0], 191 | url: args[1], 192 | date: new Date(), 193 | }; 194 | } 195 | 196 | this.cleanRequests(); 197 | }, 198 | onSend: (request: any, args: string | any[]) => { 199 | if (this.stopped) { 200 | return; 201 | } 202 | 203 | if ( 204 | request && 205 | request.gleapRequestId && 206 | this.requests && 207 | this.requests[request.gleapRequestId] 208 | ) { 209 | this.requests[request.gleapRequestId].request = { 210 | payload: this.preparePayload(args.length > 0 ? args[0] : ''), 211 | headers: request.requestHeaders, 212 | }; 213 | } 214 | 215 | this.cleanRequests(); 216 | }, 217 | onError: (request: any) => { 218 | if ( 219 | !this.stopped && 220 | this.requests && 221 | request && 222 | request.gleapRequestId && 223 | this.requests[request.gleapRequestId] 224 | ) { 225 | this.requests[request.gleapRequestId].success = false; 226 | this.calcRequestTime(request.gleapRequestId); 227 | } 228 | 229 | this.cleanRequests(); 230 | }, 231 | onLoad: (request: any) => { 232 | if (this.stopped) { 233 | return; 234 | } 235 | 236 | if ( 237 | request && 238 | request.gleapRequestId && 239 | this.requests && 240 | this.requests[request.gleapRequestId] 241 | ) { 242 | const contentType = request.getResponseHeader('content-type'); 243 | const isTextOrJSON = 244 | contentType && 245 | (contentType.includes('json') || contentType.includes('text')); 246 | 247 | var responseText = '<' + contentType + '>'; 248 | if (request.responseType === '' || request.responseType === 'text') { 249 | responseText = request.responseText; 250 | } 251 | if (request._response && isTextOrJSON) { 252 | responseText = request._response; 253 | } 254 | 255 | this.requests[request.gleapRequestId].success = true; 256 | this.requests[request.gleapRequestId].response = { 257 | status: request.status, 258 | responseText: this.prepareContent(responseText), 259 | }; 260 | 261 | this.calcRequestTime(request.gleapRequestId); 262 | } 263 | 264 | this.cleanRequests(); 265 | }, 266 | }); 267 | } 268 | 269 | interceptNetworkRequests(callback: any) { 270 | // eslint-disable-next-line consistent-this 271 | var self = this; 272 | 273 | // @ts-ignore 274 | if (XMLHttpRequest.prototype.gleapTouched) { 275 | return; 276 | } 277 | 278 | // @ts-ignore 279 | XMLHttpRequest.prototype.gleapTouched = true; 280 | 281 | // XMLHttpRequest 282 | const open = XMLHttpRequest.prototype.open; 283 | const send = XMLHttpRequest.prototype.send; 284 | 285 | // @ts-ignore 286 | XMLHttpRequest.prototype.wrappedSetRequestHeader = 287 | XMLHttpRequest.prototype.setRequestHeader; 288 | XMLHttpRequest.prototype.setRequestHeader = function (header, value) { 289 | // @ts-ignore 290 | if (!this.requestHeaders) { 291 | // @ts-ignore 292 | this.requestHeaders = {}; 293 | } 294 | 295 | // @ts-ignore 296 | if (this.requestHeaders && this.requestHeaders.hasOwnProperty(header)) { 297 | return; 298 | } 299 | 300 | // @ts-ignore 301 | if (!this.requestHeaders[header]) { 302 | // @ts-ignore 303 | this.requestHeaders[header] = []; 304 | } 305 | 306 | // @ts-ignore 307 | this.requestHeaders[header].push(value); 308 | // @ts-ignore 309 | this.wrappedSetRequestHeader(header, value); 310 | }; 311 | 312 | XMLHttpRequest.prototype.open = function () { 313 | (this as any).gleapRequestId = ++self.requestId; 314 | callback.onOpen && callback.onOpen(this, arguments); 315 | 316 | if (callback.onLoad) { 317 | this.addEventListener('load', function () { 318 | // @ts-ignore 319 | callback.onLoad(this); 320 | }); 321 | } 322 | if (callback.onError) { 323 | this.addEventListener('error', function () { 324 | // @ts-ignore 325 | callback.onError(this); 326 | }); 327 | } 328 | 329 | // @ts-ignore 330 | return open.apply(this, arguments); 331 | }; 332 | 333 | XMLHttpRequest.prototype.send = function () { 334 | callback.onSend && callback.onSend(this, arguments); 335 | // @ts-ignore 336 | return send.apply(this, arguments); 337 | }; 338 | 339 | // Fetch 340 | if (global) { 341 | (function () { 342 | var originalFetch = global.fetch; 343 | global.fetch = function () { 344 | var gleapRequestId = ++self.requestId; 345 | callback.onFetch(arguments, gleapRequestId); 346 | 347 | return ( 348 | originalFetch 349 | // @ts-ignore 350 | .apply(this, arguments) 351 | .then(function (response) { 352 | if (response && typeof response.clone === 'function') { 353 | const data = response.clone(); 354 | callback.onFetchLoad(data, gleapRequestId); 355 | } 356 | 357 | return response; 358 | }) 359 | .catch((err) => { 360 | callback.onFetchFailed(err, gleapRequestId); 361 | throw err; 362 | }) 363 | ); 364 | }; 365 | })(); 366 | } 367 | 368 | return callback; 369 | } 370 | } 371 | 372 | export default GleapNetworkIntercepter; 373 | -------------------------------------------------------------------------------- /tsconfig.build.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "extends": "./tsconfig", 4 | "exclude": ["example"] 5 | } 6 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": "./", 4 | "paths": { 5 | "react-native-gleapsdk": ["./src/index"] 6 | }, 7 | "allowUnreachableCode": false, 8 | "allowUnusedLabels": false, 9 | "esModuleInterop": true, 10 | "importsNotUsedAsValues": "error", 11 | "forceConsistentCasingInFileNames": true, 12 | "jsx": "react", 13 | "lib": ["esnext"], 14 | "module": "esnext", 15 | "moduleResolution": "node", 16 | "noFallthroughCasesInSwitch": true, 17 | "noImplicitReturns": true, 18 | "noImplicitUseStrict": false, 19 | "noStrictGenericChecks": false, 20 | "noUnusedLocals": true, 21 | "noUnusedParameters": true, 22 | "resolveJsonModule": true, 23 | "skipLibCheck": true, 24 | "strict": true, 25 | "target": "esnext" 26 | } 27 | } 28 | --------------------------------------------------------------------------------