├── .circleci └── config.yml ├── .editorconfig ├── .gitattributes ├── .github └── workflows │ └── release.yml ├── .gitignore ├── .husky ├── .npmignore ├── commit-msg └── pre-commit ├── .yarnrc ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── android ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── com │ └── openimsdkrn │ ├── BaseImpl.java │ ├── OpenImSdkRnModule.java │ ├── OpenImSdkRnPackage.java │ ├── SendMsgCallBack.java │ ├── listener │ ├── AdvancedMsgListener.java │ ├── BatchMsgListener.java │ ├── InitSDKListener.java │ ├── OnConversationListener.java │ ├── OnFriendshipListener.java │ ├── OnGroupListener.java │ ├── OnSignalingListener.java │ ├── SetCustomBusinessListener.java │ ├── UploadFileCallbackListener.java │ ├── UploadLogProgressListener.java │ └── UserListener.java │ └── utils │ └── Emitter.java ├── babel.config.js ├── example ├── .bundle │ └── config ├── .watchmanconfig ├── Gemfile ├── README.md ├── android │ ├── app │ │ ├── build.gradle │ │ ├── debug.keystore │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── debug │ │ │ ├── AndroidManifest.xml │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── openimsdkrnexample │ │ │ │ └── ReactNativeFlipper.java │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── openimsdkrnexample │ │ │ │ │ ├── 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 │ │ │ └── openimsdkrnexample │ │ │ └── ReactNativeFlipper.java │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── hs_err_pid14404.log │ ├── hs_err_pid19400.log │ ├── hs_err_pid20108.log │ ├── hs_err_pid22216.log │ └── settings.gradle ├── app.json ├── babel.config.js ├── index.js ├── ios │ ├── .xcode.env │ ├── File.swift │ ├── OpenImSdkRnExample-Bridging-Header.h │ ├── OpenImSdkRnExample.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── OpenImSdkRnExample.xcscheme │ ├── OpenImSdkRnExample.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── OpenImSdkRnExample │ │ ├── AppDelegate.h │ │ ├── AppDelegate.mm │ │ ├── Images.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ └── Contents.json │ │ ├── Info.plist │ │ ├── LaunchScreen.storyboard │ │ └── main.m │ ├── OpenImSdkRnExampleTests │ │ ├── Info.plist │ │ └── OpenImSdkRnExampleTests.m │ ├── Podfile │ └── Podfile.lock ├── jest.config.js ├── metro.config.js ├── package-lock.json ├── package.json ├── react-native.config.js ├── src │ └── App.tsx └── yarn.lock ├── ios ├── CallbackProxy.h ├── CallbackProxy.m ├── OpenImSdkRn.h ├── OpenImSdkRn.m ├── OpenImSdkRn.xcodeproj │ └── project.pbxproj ├── SendMessageCallbackProxy.h ├── SendMessageCallbackProxy.m ├── UploadFileCallbackProxy.h ├── UploadFileCallbackProxy.m ├── UploadLogCallbackProxy.h └── UploadLogCallbackProxy.m ├── lefthook.yml ├── open-im-sdk-rn.podspec ├── package-lock.json ├── package.json ├── scripts └── bootstrap.js ├── src ├── index.tsx └── types │ ├── entity.ts │ ├── enum.ts │ └── params.ts ├── tsconfig.build.json ├── tsconfig.json ├── turbo.json └── yarn.lock /.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 -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | tags: 6 | - 'v*' 7 | workflow_dispatch: 8 | 9 | jobs: 10 | release: 11 | name: Release 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - name: Checkout code 16 | uses: actions/checkout@v2 17 | 18 | - name: Set up Node.js 19 | uses: actions/setup-node@v3 20 | with: 21 | node-version: '20' 22 | 23 | - name: Install Yarn 24 | run: npm install -g yarn@1.22.15 25 | 26 | - name: Install dependencies 27 | run: yarn 28 | 29 | - name: Build 30 | run: yarn prepack 31 | 32 | - name: Authenticate with npm registry 33 | run: npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} 34 | 35 | - name: Config npm 36 | run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc 37 | env: 38 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 39 | 40 | - name: Publish 41 | env: 42 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 43 | run: npm publish -r --access public --no-git-checks 44 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, caste, color, religion, or sexual 10 | identity and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | - Demonstrating empathy and kindness toward other people 21 | - Being respectful of differing opinions, viewpoints, and experiences 22 | - Giving and gracefully accepting constructive feedback 23 | - Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | - Focusing on what is best not just for us as individuals, but for the overall 26 | community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | - The use of sexualized language or imagery, and sexual attention or advances of 31 | any kind 32 | - Trolling, insulting or derogatory comments, and personal or political attacks 33 | - Public or private harassment 34 | - Publishing others' private information, such as a physical or email address, 35 | without their explicit permission 36 | - Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | [INSERT CONTACT METHOD]. 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series of 86 | actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or permanent 93 | ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within the 113 | community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.1, available at 119 | [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. 120 | 121 | Community Impact Guidelines were inspired by 122 | [Mozilla's code of conduct enforcement ladder][Mozilla CoC]. 123 | 124 | For answers to common questions about this code of conduct, see the FAQ at 125 | [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at 126 | [https://www.contributor-covenant.org/translations][translations]. 127 | 128 | [homepage]: https://www.contributor-covenant.org 129 | [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html 130 | [Mozilla CoC]: https://github.com/mozilla/diversity 131 | [FAQ]: https://www.contributor-covenant.org/faq 132 | [translations]: https://www.contributor-covenant.org/translations 133 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Contributions are always welcome, no matter how large or small! 4 | 5 | We want this community to be friendly and respectful to each other. Please follow it in all your interactions with the project. Before contributing, please read the [code of conduct](./CODE_OF_CONDUCT.md). 6 | 7 | ## Development workflow 8 | 9 | To get started with the project, run `yarn` in the root directory to install the required dependencies for each package: 10 | 11 | ```sh 12 | yarn 13 | ``` 14 | 15 | > 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. 16 | 17 | 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. 18 | 19 | To start the packager: 20 | 21 | ```sh 22 | yarn example start 23 | ``` 24 | 25 | To run the example app on Android: 26 | 27 | ```sh 28 | yarn example android 29 | ``` 30 | 31 | To run the example app on iOS: 32 | 33 | ```sh 34 | yarn example ios 35 | ``` 36 | 37 | Make sure your code passes TypeScript and ESLint. Run the following to verify: 38 | 39 | ```sh 40 | yarn typecheck 41 | yarn lint 42 | ``` 43 | 44 | To fix formatting errors, run the following: 45 | 46 | ```sh 47 | yarn lint --fix 48 | ``` 49 | 50 | Remember to add tests for your change if possible. Run the unit tests by: 51 | 52 | ```sh 53 | yarn test 54 | ``` 55 | 56 | To edit the Objective-C or Swift files, open `example/ios/OpenImSdkRnExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > open-im-sdk-rn`. 57 | 58 | To edit the Java or Kotlin files, open `example/android` in Android studio and find the source files at `open-im-sdk-rn` under `Android`. 59 | 60 | ### Commit message convention 61 | 62 | We follow the [conventional commits specification](https://www.conventionalcommits.org/en) for our commit messages: 63 | 64 | - `fix`: bug fixes, e.g. fix crash due to deprecated method. 65 | - `feat`: new features, e.g. add new method to the module. 66 | - `refactor`: code refactor, e.g. migrate from class components to hooks. 67 | - `docs`: changes into documentation, e.g. add usage example for the module.. 68 | - `test`: adding or updating tests, e.g. add integration tests using detox. 69 | - `chore`: tooling changes, e.g. change CI config. 70 | 71 | Our pre-commit hooks verify that your commit message matches this format when committing. 72 | 73 | ### Linting and tests 74 | 75 | [ESLint](https://eslint.org/), [Prettier](https://prettier.io/), [TypeScript](https://www.typescriptlang.org/) 76 | 77 | 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. 78 | 79 | Our pre-commit hooks verify that the linter and tests pass when committing. 80 | 81 | ### Publishing to npm 82 | 83 | 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. 84 | 85 | To publish new versions, run the following: 86 | 87 | ```sh 88 | yarn release 89 | ``` 90 | 91 | ### Scripts 92 | 93 | The `package.json` file contains various scripts for common tasks: 94 | 95 | - `yarn bootstrap`: setup project by installing all dependencies and pods. 96 | - `yarn typecheck`: type-check files with TypeScript. 97 | - `yarn lint`: lint files with ESLint. 98 | - `yarn test`: run unit tests with Jest. 99 | - `yarn example start`: start the Metro server for the example app. 100 | - `yarn example android`: run the example app on Android. 101 | - `yarn example ios`: run the example app on iOS. 102 | 103 | ### Sending a pull request 104 | 105 | > **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). 106 | 107 | When you're sending a pull request: 108 | 109 | - Prefer small pull requests focused on one change. 110 | - Verify that linters and tests are passing. 111 | - Review the documentation to make sure it looks good. 112 | - Follow the pull request template when opening a pull request. 113 | - For pull requests that change the API or implementation, discuss with maintainers first by opening an issue. 114 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # React Native Client SDK for OpenIM 👨‍💻💬 2 | 3 | Use this SDK to add instant messaging capabilities to your application. By connecting to a self-hosted [OpenIM](https://www.openim.io) server, you can quickly integrate instant messaging capabilities into your app with just a few lines of code. 4 | 5 | The iOS SDK core is implemented in [OpenIM SDK Core](https://github.com/openimsdk/openim-sdk-core). Using [gomobile](https://github.com/golang/mobile), it can be compiled into an XCFramework for iOS integration. iOS interacts with the [OpenIM SDK Core](https://github.com/openimsdk/openim-sdk-core) through JSON, and the SDK exposes a re-encapsulated API for easy usage. In terms of data storage, iOS utilizes the SQLite layer provided internally by the [OpenIM SDK Core](https://github.com/openimsdk/openim-sdk-core). 6 | 7 | The android SDK core is implemented in [OpenIM SDK Core](https://github.com/openimsdk/openim-sdk-core). Using [gomobile](https://github.com/golang/mobile), it can be compiled into an AAR file for Android integration. Android interacts with the [OpenIM SDK Core](https://github.com/openimsdk/openim-sdk-core) through JSON, and the SDK exposes a re-encapsulated API for easy usage. In terms of data storage, Android utilizes the SQLite layer provided internally by the [OpenIM SDK Core](https://github.com/openimsdk/openim-sdk-core). 8 | 9 | The React Native Client SDK use [NativeModule](https://reactnative.dev/docs/native-modules-intro) system exposes instances of Java/Objective-C classes to JavaScript (JS) as JS objects, thereby allowing you to execute arbitrary native code from within JS. 10 | 11 | ## Tips 🔔 12 | 13 | 1. The open-im-sdk-rn@3.5.1 has contains ***significant disruptive updates***. If you need to upgrade, please check the incoming data and the returned data. 14 | 15 | 2. Unlike other SDKS, React Native SDK operationID is not optional, but required. 16 | 17 | ## Documentation 📚 18 | 19 | Visit [https://doc.rentsoft.cn](https://doc.rentsoft.cn) for detailed documentation and guides. 20 | 21 | For the SDK reference, see [https://doc.rentsoft.cn/sdks/quickstart/reactnative](https://doc.rentsoft.cn/sdks/quickstart/reactnative). 22 | 23 | ## Installation 💻 24 | 25 | ### Adding Dependencies 26 | 27 | ```sh 28 | yarn add open-im-sdk-rn 29 | ``` 30 | 31 | ## Usage 🚀 32 | 33 | The following examples demonstrate how to use the SDK. TypeScript is used, providing complete type hints. 34 | 35 | ### Importing the SDK and init 36 | 37 | ```typescript 38 | import OpenIMSDKRN from 'open-im-sdk-rn'; 39 | import RNFS from 'react-native-fs'; 40 | 41 | RNFS.mkdir(RNFS.DocumentDirectoryPath + '/tmp'); 42 | 43 | OpenIMSDKRN.initSDK({ 44 | platformID: 2, // 1: ios, 2: android 45 | apiAddr: 'http://your-server-ip:10002', 46 | wsAddr: 'ws://your-server-ip:10001', 47 | dataDir: RNFS.DocumentDirectoryPath + '/tmp', 48 | logLevel: 5, 49 | isLogStandardOutput: true, 50 | }, 'opid'); 51 | ``` 52 | 53 | ### Logging In and Listening for Connection Status 54 | 55 | ```typescript 56 | import OpenIMSDKRN, { OpenIMEmitter } from 'open-im-sdk-rn'; 57 | 58 | OpenIMSDKRN.login({ 59 | userID: 'IM user ID', 60 | token: 'IM user token', 61 | }, 'opid'); 62 | 63 | OpenIMEmitter.addListener('onConnecting', () => { 64 | console.log('onConnecting'); 65 | }); 66 | 67 | OpenIMEmitter.addListener('onConnectSuccess', () => { 68 | console.log('onConnectSuccess'); 69 | }); 70 | 71 | OpenIMEmitter.addListener('onConnectFailed', ({ errCode, errMsg }) => { 72 | console.log('onConnectFailed', errCode, errMsg); 73 | }); 74 | ``` 75 | 76 | To log into the IM server, you need to create an account and obtain a user ID and token. Refer to the [access token documentation](https://doc.rentsoft.cn/restapi/userManagement/userRegister) for details. 77 | 78 | ### Receiving and Sending Messages 💬 79 | 80 | OpenIM makes it easy to send and receive messages. By default, there is no restriction on having a friend relationship to send messages (although you can configure other policies on the server). If you know the user ID of the recipient, you can conveniently send a message to them. 81 | 82 | ```typescript 83 | import OpenIMSDKRN, { OpenIMEmitter } from 'open-im-sdk-rn'; 84 | import type { MessageItem } from 'open-im-sdk-rn'; 85 | 86 | OpenIMEmitter.addListener('onRecvNewMessages', (data: MessageItem[]) => { 87 | console.log('onRecvNewMessages', data); 88 | }); 89 | 90 | const message = await OpenIMSDKRN.createTextMessage('hello openim', 'opid'); 91 | 92 | OpenIMSDKRN.sendMessage({ 93 | recvID: 'recipient user ID', 94 | groupID: '', 95 | message, 96 | }, 'opid') 97 | .then(() => { 98 | // Message sent successfully ✉️ 99 | }) 100 | .catch(err => { 101 | // Failed to send message ❌ 102 | console.log(err); 103 | }); 104 | ``` 105 | 106 | ## Examples 🌟 107 | 108 | You can find a demo web app that use the SDK in the [openim-reactnative-demo](https://github.com/openimsdk/openim-reactnative-demo) repository. 109 | 110 | or: 111 | 112 | Use the examples(only the simplest SDK calls) under this project to try it out: 113 | 114 | ```sh 115 | yarn 116 | 117 | yarn example android 118 | 119 | yarn example ios 120 | ``` 121 | 122 | ## Community :busts_in_silhouette: 123 | 124 | - 📚 [OpenIM Community](https://github.com/OpenIMSDK/community) 125 | - 💕 [OpenIM Interest Group](https://github.com/Openim-sigs) 126 | - 🚀 [Join our Slack community](https://join.slack.com/t/openimsdk/shared_invite/zt-2ijy1ys1f-O0aEDCr7ExRZ7mwsHAVg9A) 127 | - :eyes: [Join our wechat (微信群)](https://openim-1253691595.cos.ap-nanjing.myqcloud.com/WechatIMG20.jpeg) 128 | 129 | ## Community Meetings :calendar: 130 | 131 | We want anyone to get involved in our community and contributing code, we offer gifts and rewards, and we welcome you to join us every Thursday night. 132 | 133 | Our conference is in the [OpenIM Slack](https://join.slack.com/t/openimsdk/shared_invite/zt-2ijy1ys1f-O0aEDCr7ExRZ7mwsHAVg9A) 🎯, then you can search the Open-IM-Server pipeline to join 134 | 135 | We take notes of each [biweekly meeting](https://github.com/orgs/OpenIMSDK/discussions/categories/meeting) in [GitHub discussions](https://github.com/openimsdk/open-im-server/discussions/categories/meeting), Our historical meeting notes, as well as replays of the meetings are available at [Google Docs :bookmark_tabs:](https://docs.google.com/document/d/1nx8MDpuG74NASx081JcCpxPgDITNTpIIos0DS6Vr9GU/edit?usp=sharing). 136 | 137 | ## Who are using OpenIM :eyes: 138 | 139 | Check out our [user case studies](https://github.com/OpenIMSDK/community/blob/main/ADOPTERS.md) page for a list of the project users. Don't hesitate to leave a [📝comment](https://github.com/openimsdk/open-im-server/issues/379) and share your use case. 140 | 141 | ## License :page_facing_up: 142 | 143 | OpenIM is licensed under the Apache 2.0 license. See [LICENSE](https://github.com/openimsdk/open-im-server/tree/main/LICENSE) for the full license text. 144 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | // if (project == rootProject) { 3 | repositories { 4 | google() 5 | mavenCentral() 6 | jcenter() 7 | } 8 | 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:4.2.0' 11 | } 12 | // } 13 | } 14 | 15 | apply plugin: 'com.android.library' 16 | 17 | def safeExtGet(prop, fallback) { 18 | rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback 19 | } 20 | 21 | android { 22 | compileSdkVersion safeExtGet('OpenImSdkRn_compileSdkVersion', 33) 23 | defaultConfig { 24 | minSdkVersion safeExtGet('OpenImSdkRn_minSdkVersion', 16) 25 | targetSdkVersion safeExtGet('OpenImSdkRn_targetSdkVersion', 33) 26 | versionCode 1 27 | versionName "1.0" 28 | 29 | } 30 | 31 | buildTypes { 32 | release { 33 | minifyEnabled false 34 | } 35 | } 36 | lintOptions { 37 | disable 'GradleCompatible' 38 | } 39 | compileOptions { 40 | sourceCompatibility JavaVersion.VERSION_1_8 41 | targetCompatibility JavaVersion.VERSION_1_8 42 | } 43 | } 44 | 45 | repositories { 46 | mavenLocal() 47 | maven { 48 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 49 | url("$rootDir/../node_modules/react-native/android") 50 | } 51 | google() 52 | mavenCentral() 53 | jcenter() 54 | } 55 | 56 | dependencies { 57 | //noinspection GradleDynamicVersion 58 | implementation "com.facebook.react:react-native:+" // From node_modules 59 | implementation 'androidx.collection:collection:1.1.0' 60 | implementation 'com.alibaba:fastjson:1.1.72.android' 61 | implementation 'io.openim:core-sdk:3.8.3-patch3@aar' 62 | // implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'], exclude: []) 63 | } 64 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | android.useAndroidX=true 2 | android.enableJetifier=true -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-reactnative/ad4169bed6778c60bf1e887fad9952fdd5288dcc/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /android/gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 84 | 85 | APP_NAME="Gradle" 86 | APP_BASE_NAME=${0##*/} 87 | 88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 90 | 91 | # Use the maximum available, or set MAX_FD != -1 to use that value. 92 | MAX_FD=maximum 93 | 94 | warn () { 95 | echo "$*" 96 | } >&2 97 | 98 | die () { 99 | echo 100 | echo "$*" 101 | echo 102 | exit 1 103 | } >&2 104 | 105 | # OS specific support (must be 'true' or 'false'). 106 | cygwin=false 107 | msys=false 108 | darwin=false 109 | nonstop=false 110 | case "$( uname )" in #( 111 | CYGWIN* ) cygwin=true ;; #( 112 | Darwin* ) darwin=true ;; #( 113 | MSYS* | MINGW* ) msys=true ;; #( 114 | NONSTOP* ) nonstop=true ;; 115 | esac 116 | 117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 118 | 119 | 120 | # Determine the Java command to use to start the JVM. 121 | if [ -n "$JAVA_HOME" ] ; then 122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 123 | # IBM's JDK on AIX uses strange locations for the executables 124 | JAVACMD=$JAVA_HOME/jre/sh/java 125 | else 126 | JAVACMD=$JAVA_HOME/bin/java 127 | fi 128 | if [ ! -x "$JAVACMD" ] ; then 129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 130 | 131 | Please set the JAVA_HOME variable in your environment to match the 132 | location of your Java installation." 133 | fi 134 | else 135 | JAVACMD=java 136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | 142 | # Increase the maximum file descriptors if we can. 143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 144 | case $MAX_FD in #( 145 | max*) 146 | MAX_FD=$( ulimit -H -n ) || 147 | warn "Could not query maximum file descriptor limit" 148 | esac 149 | case $MAX_FD in #( 150 | '' | soft) :;; #( 151 | *) 152 | ulimit -n "$MAX_FD" || 153 | warn "Could not set maximum file descriptor limit to $MAX_FD" 154 | esac 155 | fi 156 | 157 | # Collect all arguments for the java command, stacking in reverse order: 158 | # * args from the command line 159 | # * the main class name 160 | # * -classpath 161 | # * -D...appname settings 162 | # * --module-path (only if needed) 163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 164 | 165 | # For Cygwin or MSYS, switch paths to Windows format before running java 166 | if "$cygwin" || "$msys" ; then 167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 169 | 170 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 171 | 172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 173 | for arg do 174 | if 175 | case $arg in #( 176 | -*) false ;; # don't mess with options #( 177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 178 | [ -e "$t" ] ;; #( 179 | *) false ;; 180 | esac 181 | then 182 | arg=$( cygpath --path --ignore --mixed "$arg" ) 183 | fi 184 | # Roll the args list around exactly as many times as the number of 185 | # args, so each arg winds up back in the position where it started, but 186 | # possibly modified. 187 | # 188 | # NB: a `for` loop captures its iteration list before it begins, so 189 | # changing the positional parameters here affects neither the number of 190 | # iterations, nor the values presented in `arg`. 191 | shift # remove old arg 192 | set -- "$@" "$arg" # push replacement arg 193 | done 194 | fi 195 | 196 | # Collect all arguments for the java command; 197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 198 | # shell script including quotes and variable substitutions, so put them in 199 | # double quotes to make sure that they get re-expanded; and 200 | # * put everything else in single quotes, so that it's not re-expanded. 201 | 202 | set -- \ 203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 204 | -classpath "$CLASSPATH" \ 205 | org.gradle.wrapper.GradleWrapperMain \ 206 | "$@" 207 | 208 | # 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 | -------------------------------------------------------------------------------- /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/openimsdkrn/BaseImpl.java: -------------------------------------------------------------------------------- 1 | package com.openimsdkrn; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.facebook.react.bridge.Promise; 5 | 6 | import open_im_sdk_callback.Base; 7 | 8 | import com.openimsdkrn.utils.Emitter; 9 | 10 | public class BaseImpl implements Base { 11 | final private Promise promise; 12 | 13 | private Emitter emitter = new Emitter(); 14 | 15 | public BaseImpl(Promise promise) { 16 | this.promise = promise; 17 | } 18 | 19 | @Override 20 | public void onError(int ErrorCode, String ErrorMsg) { 21 | promise.reject(String.valueOf(ErrorCode), ErrorMsg); 22 | } 23 | 24 | @Override 25 | public void onSuccess(String s) { 26 | try { 27 | promise.resolve(emitter.convertJsonToMap(JSON.parseObject(s))); 28 | } catch (Exception e1) { 29 | try { 30 | promise.resolve(emitter.convertJsonToArray(JSON.parseArray(s))); 31 | } catch (Exception e2) { 32 | promise.resolve(s); 33 | } 34 | } 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /android/src/main/java/com/openimsdkrn/OpenImSdkRnPackage.java: -------------------------------------------------------------------------------- 1 | package com.openimsdkrn; 2 | 3 | import java.util.Arrays; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | import com.facebook.react.ReactPackage; 8 | import com.facebook.react.bridge.NativeModule; 9 | import com.facebook.react.bridge.ReactApplicationContext; 10 | import com.facebook.react.uimanager.ViewManager; 11 | import com.facebook.react.bridge.JavaScriptModule; 12 | 13 | public class OpenImSdkRnPackage implements ReactPackage { 14 | @Override 15 | public List createNativeModules(ReactApplicationContext reactContext) { 16 | return Arrays.asList(new OpenImSdkRnModule(reactContext)); 17 | } 18 | 19 | public List> createJSModules() { 20 | return Collections.emptyList(); 21 | } 22 | 23 | @Override 24 | public List createViewManagers(ReactApplicationContext reactContext) { 25 | return Collections.emptyList(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /android/src/main/java/com/openimsdkrn/SendMsgCallBack.java: -------------------------------------------------------------------------------- 1 | package com.openimsdkrn; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.facebook.react.bridge.ReadableMap; 5 | import com.openimsdkrn.utils.Emitter; 6 | import com.facebook.react.bridge.ReactApplicationContext; 7 | import com.facebook.react.bridge.WritableMap; 8 | import com.facebook.react.bridge.Arguments; 9 | import com.facebook.react.bridge.Promise; 10 | 11 | public class SendMsgCallBack extends Emitter implements open_im_sdk_callback.SendMsgCallBack { 12 | final ReactApplicationContext ctx; 13 | final private Promise promise; 14 | final private ReadableMap message; 15 | 16 | public SendMsgCallBack(ReactApplicationContext ctx, Promise promise, ReadableMap message) { 17 | this.ctx = ctx; 18 | this.promise = promise; 19 | this.message = message; 20 | } 21 | 22 | @Override 23 | public void onError(int ErrCode, String ErrString) { 24 | promise.reject(String.valueOf(ErrCode), ErrString); 25 | } 26 | 27 | @Override 28 | public void onProgress(long progress) { 29 | WritableMap params = Arguments.createMap(); 30 | params.putInt("progress", (int) progress); 31 | params.putMap("message", Arguments.makeNativeMap(message.toHashMap())); 32 | send(ctx, "SendMessageProgress", params); 33 | } 34 | 35 | @Override 36 | public void onSuccess(String s) { 37 | promise.resolve(convertJsonToMap(JSON.parseObject(s))); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /android/src/main/java/com/openimsdkrn/listener/AdvancedMsgListener.java: -------------------------------------------------------------------------------- 1 | package com.openimsdkrn.listener; 2 | 3 | import com.facebook.react.bridge.ReactApplicationContext; 4 | 5 | import com.openimsdkrn.utils.Emitter; 6 | import open_im_sdk_callback.OnAdvancedMsgListener; 7 | 8 | public class AdvancedMsgListener extends Emitter implements OnAdvancedMsgListener { 9 | private final ReactApplicationContext ctx; 10 | public AdvancedMsgListener(ReactApplicationContext ctx){ 11 | this.ctx = ctx; 12 | } 13 | 14 | 15 | @Override 16 | public void onMsgDeleted(String s) { 17 | send(ctx,"onMsgDeleted",jsonStringToMap(s)); 18 | } 19 | 20 | @Override 21 | public void onNewRecvMessageRevoked(String s) { 22 | send(ctx,"onNewRecvMessageRevoked",jsonStringToMap(s)); 23 | } 24 | 25 | @Override 26 | public void onRecvC2CReadReceipt(String s) { 27 | send(ctx,"onRecvC2CReadReceipt",jsonStringToArray(s)); 28 | } 29 | 30 | @Override 31 | public void onRecvNewMessage(String s) { 32 | send(ctx,"onRecvNewMessage",jsonStringToMap(s)); 33 | } 34 | 35 | @Override 36 | public void onRecvOfflineNewMessage(String s) { 37 | send(ctx,"onRecvOfflineNewMessage",jsonStringToMap(s)); 38 | } 39 | 40 | @Override 41 | public void onRecvOnlineOnlyMessage(String s) { 42 | send(ctx,"onRecvOnlineOnlyMessage",jsonStringToMap(s)); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /android/src/main/java/com/openimsdkrn/listener/BatchMsgListener.java: -------------------------------------------------------------------------------- 1 | package com.openimsdkrn.listener; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.alibaba.fastjson.JSONArray; 5 | import com.alibaba.fastjson.JSONObject; 6 | import com.facebook.react.bridge.ReactApplicationContext; 7 | import com.facebook.react.bridge.WritableArray; 8 | import com.facebook.react.bridge.WritableNativeArray; 9 | import com.facebook.react.modules.core.DeviceEventManagerModule; 10 | import com.openimsdkrn.utils.Emitter; 11 | 12 | import open_im_sdk_callback.OnBatchMsgListener; 13 | 14 | public class BatchMsgListener extends Emitter implements OnBatchMsgListener { 15 | private final ReactApplicationContext ctx; 16 | 17 | public BatchMsgListener(ReactApplicationContext ctx) { 18 | this.ctx = ctx; 19 | } 20 | 21 | @Override 22 | public void onRecvNewMessages(String s) { 23 | send(ctx,"onRecvNewMessages",jsonStringToArray(s)); 24 | } 25 | 26 | @Override 27 | public void onRecvOfflineNewMessages(String s) { 28 | send(ctx,"onRecvOfflineNewMessages",jsonStringToArray(s)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /android/src/main/java/com/openimsdkrn/listener/InitSDKListener.java: -------------------------------------------------------------------------------- 1 | package com.openimsdkrn.listener; 2 | 3 | import android.util.Log; 4 | 5 | import com.facebook.react.bridge.Arguments; 6 | import com.facebook.react.bridge.ReactApplicationContext; 7 | import com.facebook.react.bridge.WritableMap; 8 | 9 | import com.facebook.react.bridge.WritableNativeMap; 10 | import com.openimsdkrn.utils.Emitter; 11 | 12 | import open_im_sdk_callback.OnConnListener; 13 | 14 | public class InitSDKListener extends Emitter implements OnConnListener { 15 | private final ReactApplicationContext ctx; 16 | 17 | public InitSDKListener(ReactApplicationContext ctx) { 18 | this.ctx = ctx; 19 | } 20 | 21 | @Override 22 | public void onConnectFailed(int errCode, String errMsg) { 23 | WritableMap params = Arguments.createMap(); 24 | params.putInt("errCode", (int) errCode); 25 | params.putString("errMsg", errMsg); 26 | send(ctx, "onConnectFailed", params); 27 | } 28 | 29 | @Override 30 | public void onConnectSuccess() { 31 | send(ctx, "onConnectSuccess", null); 32 | } 33 | 34 | @Override 35 | public void onConnecting() { 36 | send(ctx, "onConnecting", null); 37 | } 38 | 39 | @Override 40 | public void onKickedOffline() { 41 | send(ctx, "onKickedOffline", null); 42 | } 43 | 44 | @Override 45 | public void onUserTokenExpired() { 46 | send(ctx, "onUserTokenExpired", null); 47 | } 48 | 49 | @Override 50 | public void onUserTokenInvalid(String s) { 51 | send(ctx, "onUserTokenInvalid", null); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /android/src/main/java/com/openimsdkrn/listener/OnConversationListener.java: -------------------------------------------------------------------------------- 1 | package com.openimsdkrn.listener; 2 | 3 | import com.facebook.react.bridge.Arguments; 4 | import com.facebook.react.bridge.ReactApplicationContext; 5 | 6 | import com.facebook.react.bridge.WritableMap; 7 | import com.openimsdkrn.utils.Emitter; 8 | 9 | 10 | public class OnConversationListener extends Emitter implements open_im_sdk_callback.OnConversationListener { 11 | private final ReactApplicationContext ctx; 12 | 13 | public OnConversationListener(ReactApplicationContext ctx) { 14 | this.ctx = ctx; 15 | } 16 | 17 | 18 | @Override 19 | public void onConversationChanged(String s) { 20 | send(ctx, "onConversationChanged", jsonStringToArray(s)); 21 | } 22 | 23 | @Override 24 | public void onConversationUserInputStatusChanged(String s) { 25 | send(ctx, "onInputStatusChanged", jsonStringToMap(s)); 26 | } 27 | 28 | @Override 29 | public void onNewConversation(String s) { 30 | send(ctx, "onNewConversation", jsonStringToArray(s)); 31 | } 32 | 33 | @Override 34 | public void onSyncServerFailed(boolean b) { 35 | send(ctx, "onSyncServerFailed", b); 36 | } 37 | 38 | @Override 39 | public void onSyncServerFinish(boolean b) { 40 | send(ctx, "onSyncServerFinish", b); 41 | } 42 | 43 | @Override 44 | public void onSyncServerStart(boolean b) { 45 | send(ctx, "onSyncServerStart", b); 46 | } 47 | 48 | @Override 49 | public void onSyncServerProgress(long l) { 50 | int intValue = (int) l; 51 | send(ctx, "onSyncServerProgress", intValue); 52 | } 53 | 54 | @Override 55 | public void onTotalUnreadMessageCountChanged(int i) { 56 | send(ctx, "onTotalUnreadMessageCountChanged", i); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /android/src/main/java/com/openimsdkrn/listener/OnFriendshipListener.java: -------------------------------------------------------------------------------- 1 | package com.openimsdkrn.listener; 2 | 3 | import com.facebook.react.bridge.ReactApplicationContext; 4 | 5 | import com.openimsdkrn.utils.Emitter; 6 | 7 | public class OnFriendshipListener extends Emitter implements open_im_sdk_callback.OnFriendshipListener { 8 | private final ReactApplicationContext ctx; 9 | public OnFriendshipListener(ReactApplicationContext ctx) { 10 | this.ctx = ctx; 11 | } 12 | 13 | 14 | @Override 15 | public void onBlackAdded(String s) { 16 | send(ctx,"onBlackAdded",jsonStringToMap(s)); 17 | } 18 | 19 | @Override 20 | public void onBlackDeleted(String s) { 21 | send(ctx,"onBlackDeleted",jsonStringToMap(s)); 22 | } 23 | 24 | @Override 25 | public void onFriendAdded(String s) { 26 | send(ctx,"onFriendAdded",jsonStringToMap(s)); 27 | } 28 | 29 | @Override 30 | public void onFriendApplicationAccepted(String s) { 31 | send(ctx,"onFriendApplicationAccepted",jsonStringToMap(s)); 32 | } 33 | 34 | @Override 35 | public void onFriendApplicationAdded(String s) { 36 | send(ctx,"onFriendApplicationAdded",jsonStringToMap(s)); 37 | } 38 | 39 | @Override 40 | public void onFriendApplicationDeleted(String s) { 41 | send(ctx,"onFriendApplicationDeleted",jsonStringToMap(s)); 42 | } 43 | 44 | @Override 45 | public void onFriendApplicationRejected(String s) { 46 | send(ctx,"onFriendApplicationRejected",jsonStringToMap(s)); 47 | } 48 | 49 | @Override 50 | public void onFriendDeleted(String s) { 51 | send(ctx,"onFriendDeleted",jsonStringToMap(s)); 52 | } 53 | 54 | @Override 55 | public void onFriendInfoChanged(String s) { 56 | send(ctx,"onFriendInfoChanged",jsonStringToMap(s)); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /android/src/main/java/com/openimsdkrn/listener/OnGroupListener.java: -------------------------------------------------------------------------------- 1 | package com.openimsdkrn.listener; 2 | 3 | import com.alibaba.fastjson.JSONObject; 4 | import com.facebook.react.bridge.Arguments; 5 | import com.facebook.react.bridge.Callback; 6 | import com.facebook.react.bridge.ReactApplicationContext; 7 | import com.facebook.react.bridge.WritableMap; 8 | 9 | import java.util.HashMap; 10 | import java.util.Map; 11 | 12 | import com.openimsdkrn.utils.Emitter; 13 | 14 | public class OnGroupListener extends Emitter implements open_im_sdk_callback.OnGroupListener { 15 | 16 | private final ReactApplicationContext ctx; 17 | 18 | public OnGroupListener(ReactApplicationContext ctx){ 19 | this.ctx = ctx; 20 | } 21 | 22 | 23 | @Override 24 | public void onGroupApplicationAccepted(String s) { 25 | send(ctx,"onGroupApplicationAccepted",jsonStringToMap(s)); 26 | } 27 | 28 | @Override 29 | public void onGroupApplicationAdded(String s) { 30 | send(ctx,"onGroupApplicationAdded",jsonStringToMap(s)); 31 | } 32 | 33 | @Override 34 | public void onGroupApplicationDeleted(String s) { 35 | send(ctx,"onGroupApplicationDeleted",jsonStringToMap(s)); 36 | } 37 | 38 | @Override 39 | public void onGroupApplicationRejected(String s) { 40 | send(ctx,"onGroupApplicationRejected",jsonStringToMap(s)); 41 | } 42 | 43 | @Override 44 | public void onGroupDismissed(String s) { 45 | send(ctx,"onGroupDismissed",jsonStringToMap(s)); 46 | } 47 | 48 | @Override 49 | public void onGroupInfoChanged(String s) { 50 | send(ctx,"onGroupInfoChanged",jsonStringToMap(s)); 51 | } 52 | 53 | @Override 54 | public void onGroupMemberAdded(String s) { 55 | send(ctx,"onGroupMemberAdded",jsonStringToMap(s)); 56 | } 57 | 58 | @Override 59 | public void onGroupMemberDeleted(String s) { 60 | send(ctx,"onGroupMemberDeleted",jsonStringToMap(s)); 61 | } 62 | 63 | @Override 64 | public void onGroupMemberInfoChanged(String s) { 65 | send(ctx,"onGroupMemberInfoChanged",jsonStringToMap(s)); 66 | } 67 | 68 | @Override 69 | public void onJoinedGroupAdded(String s) { 70 | send(ctx,"onJoinedGroupAdded",jsonStringToMap(s)); 71 | } 72 | 73 | @Override 74 | public void onJoinedGroupDeleted(String s) { 75 | send(ctx,"onJoinedGroupDeleted",jsonStringToMap(s)); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /android/src/main/java/com/openimsdkrn/listener/OnSignalingListener.java: -------------------------------------------------------------------------------- 1 | //package com.openimsdkrn.listener; 2 | // 3 | //import com.facebook.react.bridge.ReactApplicationContext; 4 | //import com.openimsdkrn.utils.Emitter; 5 | // 6 | // 7 | //public class OnSignalingListener extends Emitter implements open_im_sdk_callback.OnSignalingListener { 8 | // private final ReactApplicationContext ctx; 9 | // 10 | // public OnSignalingListener(ReactApplicationContext ctx){ 11 | // this.ctx = ctx; 12 | // } 13 | // 14 | // 15 | // @Override 16 | // public void onHangUp(String s) { 17 | // send(ctx,"onHangUp",getParams(0,"",s)); 18 | // } 19 | // 20 | // @Override 21 | // public void onInvitationCancelled(String s) { 22 | // send(ctx,"onInvitationCancelled",getParams(0,"",s)); 23 | // } 24 | // 25 | // @Override 26 | // public void onInvitationTimeout(String s) { 27 | // send(ctx,"onInvitationTimeout",getParams(0,"",s)); 28 | // } 29 | // 30 | // @Override 31 | // public void onInviteeAccepted(String s) { 32 | // send(ctx,"onInviteeAccepted",getParams(0,"",s)); 33 | // } 34 | // 35 | // @Override 36 | // public void onInviteeAcceptedByOtherDevice(String s) { 37 | // send(ctx,"onInviteeAcceptedByOtherDevice",getParams(0,"",s)); 38 | // } 39 | // 40 | // @Override 41 | // public void onInviteeRejected(String s) { 42 | // send(ctx,"onInviteeRejected",getParams(0,"",s)); 43 | // } 44 | // 45 | // @Override 46 | // public void onInviteeRejectedByOtherDevice(String s) { 47 | // send(ctx,"onInviteeRejectedByOtherDevice",getParams(0,"",s)); 48 | // } 49 | // 50 | // @Override 51 | // public void onReceiveNewInvitation(String s) { 52 | // send(ctx,"onReceiveNewInvitation",getParams(0,"",s)); 53 | // } 54 | // 55 | // @Override 56 | // public void onRoomParticipantConnected(String s) { 57 | // 58 | // } 59 | // 60 | // @Override 61 | // public void onRoomParticipantDisconnected(String s) { 62 | // 63 | // } 64 | //} 65 | -------------------------------------------------------------------------------- /android/src/main/java/com/openimsdkrn/listener/SetCustomBusinessListener.java: -------------------------------------------------------------------------------- 1 | package com.openimsdkrn.listener; 2 | 3 | import com.facebook.react.bridge.ReactApplicationContext; 4 | import com.openimsdkrn.utils.Emitter; 5 | 6 | import open_im_sdk_callback.OnCustomBusinessListener; 7 | 8 | public class SetCustomBusinessListener extends Emitter implements OnCustomBusinessListener { 9 | private final ReactApplicationContext ctx; 10 | 11 | public SetCustomBusinessListener(ReactApplicationContext ctx) { 12 | this.ctx = ctx; 13 | } 14 | 15 | @Override 16 | public void onRecvCustomBusinessMessage(String s) { 17 | send(ctx,"onRecvCustomBusinessMessage",jsonStringToMap(s)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /android/src/main/java/com/openimsdkrn/listener/UploadFileCallbackListener.java: -------------------------------------------------------------------------------- 1 | package com.openimsdkrn.listener; 2 | 3 | import com.alibaba.fastjson.JSONObject; 4 | import com.facebook.react.bridge.Arguments; 5 | import com.facebook.react.bridge.ReactApplicationContext; 6 | import com.facebook.react.bridge.WritableMap; 7 | import com.facebook.react.bridge.WritableNativeMap; 8 | import com.openimsdkrn.utils.Emitter; 9 | 10 | import open_im_sdk_callback.UploadFileCallback; 11 | 12 | public class UploadFileCallbackListener extends Emitter implements UploadFileCallback { 13 | private final ReactApplicationContext ctx; 14 | private final String operationID; 15 | public UploadFileCallbackListener(ReactApplicationContext ctx,String operationID){ 16 | this.ctx = ctx; 17 | this.operationID = operationID; 18 | } 19 | 20 | @Override 21 | public void complete(long l, String s, long l1) { 22 | 23 | } 24 | 25 | @Override 26 | public void hashPartComplete(String s, String s1) { 27 | 28 | } 29 | 30 | @Override 31 | public void hashPartProgress(long l, long l1, String s) { 32 | 33 | } 34 | 35 | @Override 36 | public void open(long l) { 37 | 38 | } 39 | 40 | @Override 41 | public void partSize(long l, long l1) { 42 | 43 | } 44 | 45 | @Override 46 | public void uploadComplete(long l, long l1, long l2) { 47 | WritableMap params = Arguments.createMap();WritableMap data = new WritableNativeMap(); 48 | data.putInt("fileSize", (int) l); 49 | data.putInt("streamSize", (int) l1); 50 | data.putInt("storageSize", (int) l2); 51 | data.putString("operationID", operationID); 52 | params.putMap("data", data); 53 | send(ctx,"uploadComplete",params); 54 | } 55 | 56 | @Override 57 | public void uploadID(String s) { 58 | 59 | } 60 | 61 | @Override 62 | public void uploadPartComplete(long l, long l1, String s) { 63 | 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /android/src/main/java/com/openimsdkrn/listener/UploadLogProgressListener.java: -------------------------------------------------------------------------------- 1 | package com.openimsdkrn.listener; 2 | 3 | import com.facebook.react.bridge.Arguments; 4 | import com.facebook.react.bridge.ReactApplicationContext; 5 | import com.facebook.react.bridge.WritableMap; 6 | import com.openimsdkrn.utils.Emitter; 7 | 8 | import open_im_sdk_callback.UploadLogProgress; 9 | 10 | public class UploadLogProgressListener extends Emitter implements UploadLogProgress { 11 | private final ReactApplicationContext ctx; 12 | private final String operationID; 13 | public UploadLogProgressListener(ReactApplicationContext ctx, String operationID) { 14 | this.ctx = ctx; 15 | this.operationID = operationID; 16 | } 17 | 18 | @Override 19 | public void onProgress(long l, long l1) { 20 | WritableMap params = Arguments.createMap(); 21 | params.putInt("current", (int) l); 22 | params.putInt("size", (int) l1); 23 | params.putString("operationID", operationID); 24 | send(ctx,"uploadOnProgress",params); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /android/src/main/java/com/openimsdkrn/listener/UserListener.java: -------------------------------------------------------------------------------- 1 | package com.openimsdkrn.listener; 2 | 3 | import com.facebook.react.bridge.ReactApplicationContext; 4 | import com.openimsdkrn.utils.Emitter; 5 | 6 | import open_im_sdk_callback.OnUserListener; 7 | 8 | public class UserListener extends Emitter implements OnUserListener { 9 | private final ReactApplicationContext ctx; 10 | 11 | public UserListener(ReactApplicationContext ctx) { 12 | this.ctx = ctx; 13 | } 14 | 15 | @Override 16 | public void onSelfInfoUpdated(String s) { 17 | send(ctx, "onSelfInfoUpdated", jsonStringToMap(s)); 18 | } 19 | 20 | @Override 21 | public void onUserCommandAdd(String s) { 22 | 23 | } 24 | 25 | @Override 26 | public void onUserCommandDelete(String s) { 27 | 28 | } 29 | 30 | @Override 31 | public void onUserCommandUpdate(String s) { 32 | 33 | } 34 | 35 | @Override 36 | public void onUserStatusChanged(String s) { 37 | send(ctx, "onUserStatusChanged", jsonStringToMap(s)); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /android/src/main/java/com/openimsdkrn/utils/Emitter.java: -------------------------------------------------------------------------------- 1 | package com.openimsdkrn.utils; 2 | 3 | import androidx.annotation.Nullable; 4 | 5 | import com.alibaba.fastjson.JSON; 6 | import com.alibaba.fastjson.JSONArray; 7 | import com.alibaba.fastjson.JSONObject; 8 | import com.facebook.react.bridge.Arguments; 9 | import com.facebook.react.bridge.ReactContext; 10 | import com.facebook.react.bridge.ReadableMap; 11 | import com.facebook.react.bridge.WritableArray; 12 | import com.facebook.react.bridge.WritableMap; 13 | 14 | import com.facebook.react.bridge.WritableNativeArray; 15 | import com.facebook.react.modules.core.DeviceEventManagerModule; 16 | 17 | import java.math.BigDecimal; 18 | 19 | 20 | public class Emitter { 21 | public void send(ReactContext reactContext, String eventName, @Nullable Object params) { 22 | reactContext 23 | .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) 24 | .emit(eventName, params); 25 | } 26 | 27 | public WritableMap jsonStringToMap(String data) { 28 | JSONObject parsedData = JSON.parseObject(data); 29 | return convertJsonToMap(parsedData); 30 | } 31 | 32 | public WritableArray jsonStringToArray(String data) { 33 | JSONArray parsedArray = JSON.parseArray(data); 34 | WritableArray dataArray = new WritableNativeArray(); 35 | for (Object item : parsedArray) { 36 | dataArray.pushMap(convertJsonToMap((JSONObject) item)); 37 | } 38 | 39 | return dataArray; 40 | } 41 | 42 | public WritableMap convertJsonToMap(JSONObject jsonObject) { 43 | WritableMap writableMap = Arguments.createMap(); 44 | for (String key : jsonObject.keySet()) { 45 | Object value = jsonObject.get(key); 46 | if (value instanceof String) { 47 | writableMap.putString(key, (String) value); 48 | } else if (value instanceof Integer) { 49 | writableMap.putInt(key, (Integer) value); 50 | } else if (value instanceof Long) { 51 | writableMap.putDouble(key, ((Long) value).doubleValue()); 52 | } else if (value instanceof BigDecimal) { 53 | BigDecimal bd = (BigDecimal) value; 54 | try { 55 | writableMap.putInt(key, bd.intValueExact()); 56 | } catch (ArithmeticException e) { 57 | writableMap.putDouble(key, bd.doubleValue()); 58 | } 59 | } else if (value instanceof Boolean) { 60 | writableMap.putBoolean(key, (Boolean) value); 61 | } else if (value instanceof JSONObject) { 62 | writableMap.putMap(key, convertJsonToMap((JSONObject) value)); 63 | } else if (value instanceof JSONArray) { 64 | writableMap.putArray(key, convertJsonToArray((JSONArray) value)); 65 | } else { 66 | writableMap.putNull(key); 67 | } 68 | } 69 | return writableMap; 70 | } 71 | 72 | public WritableArray convertJsonToArray(JSONArray jsonArray) { 73 | WritableArray writableArray = Arguments.createArray(); 74 | for (int i = 0; i < jsonArray.size(); i++) { 75 | Object item = jsonArray.get(i); 76 | if (item instanceof JSONObject) { 77 | writableArray.pushMap(convertJsonToMap((JSONObject) item)); 78 | } else if (item instanceof JSONArray) { 79 | writableArray.pushArray(convertJsonToArray((JSONArray) item)); 80 | } else if (item instanceof String) { 81 | writableArray.pushString((String) item); 82 | } else if (item instanceof Integer) { 83 | writableArray.pushInt((Integer) item); 84 | } else if (item instanceof Long) { 85 | writableArray.pushDouble(((Long) item).doubleValue()); 86 | } else if (item instanceof Double) { 87 | writableArray.pushDouble((Double) item); 88 | } else if (item instanceof Boolean) { 89 | writableArray.pushBoolean((Boolean) item); 90 | } else { 91 | writableArray.pushNull(); 92 | } 93 | } 94 | return writableArray; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /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/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /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.12' 7 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | This is a new [**React Native**](https://reactnative.dev) project, bootstrapped using [`@react-native-community/cli`](https://github.com/react-native-community/cli). 2 | 3 | # Getting Started 4 | 5 | > **Note**: Make sure you have completed the [React Native - Environment Setup](https://reactnative.dev/docs/environment-setup) instructions till "Creating a new application" step, before proceeding. 6 | 7 | ## Step 1: Start the Metro Server 8 | 9 | First, you will need to start **Metro**, the JavaScript _bundler_ that ships _with_ React Native. 10 | 11 | To start Metro, run the following command from the _root_ of your React Native project: 12 | 13 | ```bash 14 | # using npm 15 | npm start 16 | 17 | # OR using Yarn 18 | yarn start 19 | ``` 20 | 21 | ## Step 2: Start your Application 22 | 23 | Let Metro Bundler run in its _own_ terminal. Open a _new_ terminal from the _root_ of your React Native project. Run the following command to start your _Android_ or _iOS_ app: 24 | 25 | ### For Android 26 | 27 | ```bash 28 | # using npm 29 | npm run android 30 | 31 | # OR using Yarn 32 | yarn android 33 | ``` 34 | 35 | ### For iOS 36 | 37 | ```bash 38 | # using npm 39 | npm run ios 40 | 41 | # OR using Yarn 42 | yarn ios 43 | ``` 44 | 45 | If everything is set up _correctly_, you should see your new app running in your _Android Emulator_ or _iOS Simulator_ shortly provided you have set up your emulator/simulator correctly. 46 | 47 | This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively. 48 | 49 | ## Step 3: Modifying your App 50 | 51 | Now that you have successfully run the app, let's modify it. 52 | 53 | 1. Open `App.tsx` in your text editor of choice and edit some lines. 54 | 2. For **Android**: Press the R key twice or select **"Reload"** from the **Developer Menu** (Ctrl + M (on Window and Linux) or Cmd ⌘ + M (on macOS)) to see your changes! 55 | 56 | For **iOS**: Hit Cmd ⌘ + R in your iOS Simulator to reload the app and see your changes! 57 | 58 | ## Congratulations! :tada: 59 | 60 | You've successfully run and modified your React Native App. :partying_face: 61 | 62 | ### Now what? 63 | 64 | - If you want to add this new React Native code to an existing application, check out the [Integration guide](https://reactnative.dev/docs/integration-with-existing-apps). 65 | - If you're curious to learn more about React Native, check out the [Introduction to React Native](https://reactnative.dev/docs/getting-started). 66 | 67 | # Troubleshooting 68 | 69 | If you can't get this to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page. 70 | 71 | # Learn More 72 | 73 | To learn more about React Native, take a look at the following resources: 74 | 75 | - [React Native Website](https://reactnative.dev) - learn more about React Native. 76 | - [Getting Started](https://reactnative.dev/docs/environment-setup) - an **overview** of React Native and how setup your environment. 77 | - [Learn the Basics](https://reactnative.dev/docs/getting-started) - a **guided tour** of the React Native **basics**. 78 | - [Blog](https://reactnative.dev/blog) - read the latest official React Native **Blog** posts. 79 | - [`@facebook/react-native`](https://github.com/facebook/react-native) - the Open Source; GitHub **repository** for React Native. 80 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | apply plugin: "com.facebook.react" 3 | 4 | /** 5 | * This is the configuration block to customize your React Native Android app. 6 | * By default you don't need to apply any configuration, just uncomment the lines you need. 7 | */ 8 | react { 9 | /* Folders */ 10 | // The root of your project, i.e. where "package.json" lives. Default is '..' 11 | // root = file("../") 12 | // The folder where the react-native NPM package is. Default is ../node_modules/react-native 13 | // reactNativeDir = file("../node_modules/react-native") 14 | // The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen 15 | // codegenDir = file("../node_modules/@react-native/codegen") 16 | // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js 17 | // cliFile = file("../node_modules/react-native/cli.js") 18 | 19 | /* Variants */ 20 | // The list of variants to that are debuggable. For those we're going to 21 | // skip the bundling of the JS bundle and the assets. By default is just 'debug'. 22 | // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants. 23 | // debuggableVariants = ["liteDebug", "prodDebug"] 24 | 25 | /* Bundling */ 26 | // A list containing the node command and its flags. Default is just 'node'. 27 | // nodeExecutableAndArgs = ["node"] 28 | // 29 | // The command to run when bundling. By default is 'bundle' 30 | // bundleCommand = "ram-bundle" 31 | // 32 | // The path to the CLI configuration file. Default is empty. 33 | // bundleConfig = file(../rn-cli.config.js) 34 | // 35 | // The name of the generated asset file containing your JS bundle 36 | // bundleAssetName = "MyApplication.android.bundle" 37 | // 38 | // The entry file for bundle generation. Default is 'index.android.js' or 'index.js' 39 | // entryFile = file("../js/MyApplication.android.js") 40 | // 41 | // A list of extra flags to pass to the 'bundle' commands. 42 | // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle 43 | // extraPackagerArgs = [] 44 | 45 | /* Hermes Commands */ 46 | // The hermes compiler command to run. By default it is 'hermesc' 47 | // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc" 48 | // 49 | // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map" 50 | // hermesFlags = ["-O", "-output-source-map"] 51 | } 52 | 53 | /** 54 | * Set this to true to Run Proguard on Release builds to minify the Java bytecode. 55 | */ 56 | def enableProguardInReleaseBuilds = false 57 | 58 | /** 59 | * The preferred build flavor of JavaScriptCore (JSC) 60 | * 61 | * For example, to use the international variant, you can use: 62 | * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` 63 | * 64 | * The international variant includes ICU i18n library and necessary data 65 | * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that 66 | * give correct results when using with locales other than en-US. Note that 67 | * this variant is about 6MiB larger per architecture than default. 68 | */ 69 | def jscFlavor = 'org.webkit:android-jsc:+' 70 | 71 | android { 72 | ndkVersion rootProject.ext.ndkVersion 73 | 74 | compileSdkVersion rootProject.ext.compileSdkVersion 75 | buildToolsVersion "30.0.3" 76 | 77 | namespace "com.openimsdkrnexample" 78 | defaultConfig { 79 | applicationId "com.openimsdkrnexample" 80 | minSdkVersion rootProject.ext.minSdkVersion 81 | targetSdkVersion rootProject.ext.targetSdkVersion 82 | versionCode 1 83 | versionName "1.0" 84 | } 85 | signingConfigs { 86 | debug { 87 | storeFile file('debug.keystore') 88 | storePassword 'android' 89 | keyAlias 'androiddebugkey' 90 | keyPassword 'android' 91 | } 92 | } 93 | buildTypes { 94 | debug { 95 | signingConfig signingConfigs.debug 96 | } 97 | release { 98 | // Caution! In production, you need to generate your own keystore file. 99 | // see https://reactnative.dev/docs/signed-apk-android. 100 | signingConfig signingConfigs.debug 101 | minifyEnabled enableProguardInReleaseBuilds 102 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 103 | } 104 | } 105 | } 106 | 107 | dependencies { 108 | // The version of react-native is set by the React Native Gradle Plugin 109 | implementation("com.facebook.react:react-android") 110 | 111 | debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") 112 | debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { 113 | exclude group:'com.squareup.okhttp3', module:'okhttp' 114 | } 115 | 116 | debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") 117 | if (hermesEnabled.toBoolean()) { 118 | implementation("com.facebook.react:hermes-android") 119 | } else { 120 | implementation jscFlavor 121 | } 122 | } 123 | 124 | apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) 125 | -------------------------------------------------------------------------------- /example/android/app/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-reactnative/ad4169bed6778c60bf1e887fad9952fdd5288dcc/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/openimsdkrnexample/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.openimsdkrnexample; 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/openimsdkrnexample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.openimsdkrnexample; 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 "OpenImSdkRnExample"; 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()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/openimsdkrnexample/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.openimsdkrnexample; 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 com.openimsdkrn.OpenImSdkRnPackage; 12 | 13 | import java.util.List; 14 | 15 | public class MainApplication extends Application implements ReactApplication { 16 | 17 | private final ReactNativeHost mReactNativeHost = 18 | new DefaultReactNativeHost(this) { 19 | @Override 20 | public boolean getUseDeveloperSupport() { 21 | return BuildConfig.DEBUG; 22 | } 23 | 24 | @Override 25 | protected List getPackages() { 26 | @SuppressWarnings("UnnecessaryLocalVariable") 27 | List packages = new PackageList(this).getPackages(); 28 | // Packages that cannot be autolinked yet can be added manually here, for example: 29 | // packages.add(new OpenImSdkRnPackage()); 30 | return packages; 31 | } 32 | 33 | @Override 34 | protected String getJSMainModuleName() { 35 | return "index"; 36 | } 37 | 38 | @Override 39 | protected boolean isNewArchEnabled() { 40 | return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED; 41 | } 42 | 43 | @Override 44 | protected Boolean isHermesEnabled() { 45 | return BuildConfig.IS_HERMES_ENABLED; 46 | } 47 | }; 48 | 49 | @Override 50 | public ReactNativeHost getReactNativeHost() { 51 | return mReactNativeHost; 52 | } 53 | 54 | @Override 55 | public void onCreate() { 56 | super.onCreate(); 57 | SoLoader.init(this, /* native exopackage */ false); 58 | if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { 59 | // If you opted-in for the New Architecture, we load the native entry point for this app. 60 | DefaultNewArchitectureEntryPoint.load(); 61 | } 62 | ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /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/openimsdk/open-im-sdk-reactnative/ad4169bed6778c60bf1e887fad9952fdd5288dcc/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/openimsdk/open-im-sdk-reactnative/ad4169bed6778c60bf1e887fad9952fdd5288dcc/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/openimsdk/open-im-sdk-reactnative/ad4169bed6778c60bf1e887fad9952fdd5288dcc/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/openimsdk/open-im-sdk-reactnative/ad4169bed6778c60bf1e887fad9952fdd5288dcc/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/openimsdk/open-im-sdk-reactnative/ad4169bed6778c60bf1e887fad9952fdd5288dcc/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/openimsdk/open-im-sdk-reactnative/ad4169bed6778c60bf1e887fad9952fdd5288dcc/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/openimsdk/open-im-sdk-reactnative/ad4169bed6778c60bf1e887fad9952fdd5288dcc/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/openimsdk/open-im-sdk-reactnative/ad4169bed6778c60bf1e887fad9952fdd5288dcc/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/openimsdk/open-im-sdk-reactnative/ad4169bed6778c60bf1e887fad9952fdd5288dcc/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/openimsdk/open-im-sdk-reactnative/ad4169bed6778c60bf1e887fad9952fdd5288dcc/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | OpenImSdkRnExample 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/openimsdkrnexample/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.openimsdkrnexample; 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 = 33 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") 19 | classpath("com.facebook.react:react-native-gradle-plugin") 20 | } 21 | } 22 | allprojects { 23 | repositories { 24 | google() 25 | mavenCentral() 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /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.182.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/openimsdk/open-im-sdk-reactnative/ad4169bed6778c60bf1e887fad9952fdd5288dcc/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-8.0.1-all.zip 4 | networkTimeout=10000 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /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/HEAD/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 | # This is normally unused 84 | # shellcheck disable=SC2034 85 | APP_BASE_NAME=${0##*/} 86 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 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 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 147 | # shellcheck disable=SC3045 148 | MAX_FD=$( ulimit -H -n ) || 149 | warn "Could not query maximum file descriptor limit" 150 | esac 151 | case $MAX_FD in #( 152 | '' | soft) :;; #( 153 | *) 154 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 155 | # shellcheck disable=SC3045 156 | ulimit -n "$MAX_FD" || 157 | warn "Could not set maximum file descriptor limit to $MAX_FD" 158 | esac 159 | fi 160 | 161 | # Collect all arguments for the java command, stacking in reverse order: 162 | # * args from the command line 163 | # * the main class name 164 | # * -classpath 165 | # * -D...appname settings 166 | # * --module-path (only if needed) 167 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 168 | 169 | # For Cygwin or MSYS, switch paths to Windows format before running java 170 | if "$cygwin" || "$msys" ; then 171 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 172 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 173 | 174 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 175 | 176 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 177 | for arg do 178 | if 179 | case $arg in #( 180 | -*) false ;; # don't mess with options #( 181 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 182 | [ -e "$t" ] ;; #( 183 | *) false ;; 184 | esac 185 | then 186 | arg=$( cygpath --path --ignore --mixed "$arg" ) 187 | fi 188 | # Roll the args list around exactly as many times as the number of 189 | # args, so each arg winds up back in the position where it started, but 190 | # possibly modified. 191 | # 192 | # NB: a `for` loop captures its iteration list before it begins, so 193 | # changing the positional parameters here affects neither the number of 194 | # iterations, nor the values presented in `arg`. 195 | shift # remove old arg 196 | set -- "$@" "$arg" # push replacement arg 197 | done 198 | fi 199 | 200 | # Collect all arguments for the java command; 201 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 202 | # shell script including quotes and variable substitutions, so put them in 203 | # double quotes to make sure that they get re-expanded; and 204 | # * put everything else in single quotes, so that it's not re-expanded. 205 | 206 | set -- \ 207 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 208 | -classpath "$CLASSPATH" \ 209 | org.gradle.wrapper.GradleWrapperMain \ 210 | "$@" 211 | 212 | # Stop when "xargs" is not available. 213 | if ! command -v xargs >/dev/null 2>&1 214 | then 215 | die "xargs is not available" 216 | fi 217 | 218 | # Use "xargs" to parse quoted args. 219 | # 220 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 221 | # 222 | # In Bash we could simply go: 223 | # 224 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 225 | # set -- "${ARGS[@]}" "$@" 226 | # 227 | # but POSIX shell has neither arrays nor command substitution, so instead we 228 | # post-process each arg (as a line of input to sed) to backslash-escape any 229 | # character that might be a shell metacharacter, then use eval to reverse 230 | # that process (while maintaining the separation between arguments), and wrap 231 | # the whole thing up as a single "set" statement. 232 | # 233 | # This will of course break if any of these variables contains a newline or 234 | # an unmatched quote. 235 | # 236 | 237 | eval "set -- $( 238 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 239 | xargs -n1 | 240 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 241 | tr '\n' ' ' 242 | )" '"$@"' 243 | 244 | exec "$JAVACMD" "$@" 245 | -------------------------------------------------------------------------------- /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 | @rem This is normally unused 30 | set APP_BASE_NAME=%~n0 31 | set APP_HOME=%DIRNAME% 32 | 33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 35 | 36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 38 | 39 | @rem Find java.exe 40 | if defined JAVA_HOME goto findJavaFromJavaHome 41 | 42 | set JAVA_EXE=java.exe 43 | %JAVA_EXE% -version >NUL 2>&1 44 | if %ERRORLEVEL% equ 0 goto execute 45 | 46 | echo. 47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 48 | echo. 49 | echo Please set the JAVA_HOME variable in your environment to match the 50 | echo location of your Java installation. 51 | 52 | goto fail 53 | 54 | :findJavaFromJavaHome 55 | set JAVA_HOME=%JAVA_HOME:"=% 56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 57 | 58 | if exist "%JAVA_EXE%" goto execute 59 | 60 | echo. 61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 62 | echo. 63 | echo Please set the JAVA_HOME variable in your environment to match the 64 | echo location of your Java installation. 65 | 66 | goto fail 67 | 68 | :execute 69 | @rem Setup the command line 70 | 71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 | 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if %ERRORLEVEL% equ 0 goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | set EXIT_CODE=%ERRORLEVEL% 85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 87 | exit /b %EXIT_CODE% 88 | 89 | :mainEnd 90 | if "%OS%"=="Windows_NT" endlocal 91 | 92 | :omega 93 | -------------------------------------------------------------------------------- /example/android/hs_err_pid20108.log: -------------------------------------------------------------------------------- 1 | # 2 | # There is insufficient memory for the Java Runtime Environment to continue. 3 | # Native memory allocation (mmap) failed to map 260046848 bytes for G1 virtual space 4 | # Possible reasons: 5 | # The system is out of physical RAM or swap space 6 | # The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap 7 | # Possible solutions: 8 | # Reduce memory load on the system 9 | # Increase physical memory or swap space 10 | # Check if swap backing store is full 11 | # Decrease Java heap size (-Xmx/-Xms) 12 | # Decrease number of Java threads 13 | # Decrease Java thread stack sizes (-Xss) 14 | # Set larger code cache with -XX:ReservedCodeCacheSize= 15 | # JVM is running with Zero Based Compressed Oops mode in which the Java heap is 16 | # placed in the first 32GB address space. The Java Heap base address is the 17 | # maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress 18 | # to set the Java Heap base and to place the Java Heap above 32GB virtual address. 19 | # This output file may be truncated or incomplete. 20 | # 21 | # Out of Memory Error (os_windows.cpp:3550), pid=20108, tid=19564 22 | # 23 | # JRE version: (17.0.8+9) (build ) 24 | # Java VM: Java HotSpot(TM) 64-Bit Server VM (17.0.8+9-LTS-211, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, windows-amd64) 25 | # No core dump will be written. Minidumps are not enabled by default on client versions of Windows 26 | # 27 | 28 | --------------- S U M M A R Y ------------ 29 | 30 | Command Line: 31 | 32 | Host: AMD Ryzen 7 5700G with Radeon Graphics , 16 cores, 15G, Windows 11 , 64 bit Build 22621 (10.0.22621.2506) 33 | Time: Tue Dec 26 12:19:44 2023 Windows 11 , 64 bit Build 22621 (10.0.22621.2506) elapsed time: 0.117696 seconds (0d 0h 0m 0s) 34 | 35 | --------------- T H R E A D --------------- 36 | 37 | Current thread (0x0000018f0fbd0b60): JavaThread "Unknown thread" [_thread_in_vm, id=19564, stack(0x0000000d92600000,0x0000000d92700000)] 38 | 39 | Stack: [0x0000000d92600000,0x0000000d92700000] 40 | Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) 41 | V [jvm.dll+0x677d0a] 42 | V [jvm.dll+0x7d8c54] 43 | V [jvm.dll+0x7da3fe] 44 | V [jvm.dll+0x7daa63] 45 | V [jvm.dll+0x245c5f] 46 | V [jvm.dll+0x674bb9] 47 | V [jvm.dll+0x6694f2] 48 | V [jvm.dll+0x3031d6] 49 | V [jvm.dll+0x30a756] 50 | V [jvm.dll+0x359f9e] 51 | V [jvm.dll+0x35a1cf] 52 | V [jvm.dll+0x2da3e8] 53 | V [jvm.dll+0x2db354] 54 | V [jvm.dll+0x7aa711] 55 | V [jvm.dll+0x367b51] 56 | V [jvm.dll+0x789979] 57 | V [jvm.dll+0x3eb05f] 58 | V [jvm.dll+0x3ecae1] 59 | C [jli.dll+0x5297] 60 | C [ucrtbase.dll+0x29363] 61 | C [KERNEL32.DLL+0x1257d] 62 | C [ntdll.dll+0x5aa58] 63 | 64 | 65 | --------------- P R O C E S S --------------- 66 | 67 | Threads class SMR info: 68 | _java_thread_list=0x00007ff8b45759d8, length=0, elements={ 69 | } 70 | 71 | Java Threads: ( => current thread ) 72 | 73 | Other Threads: 74 | 0x0000018f0fc39550 GCTaskThread "GC Thread#0" [stack: 0x0000000d92700000,0x0000000d92800000] [id=18256] 75 | 0x0000018f0fc4a280 ConcurrentGCThread "G1 Main Marker" [stack: 0x0000000d92800000,0x0000000d92900000] [id=19864] 76 | 0x0000018f0fc4cba0 ConcurrentGCThread "G1 Conc#0" [stack: 0x0000000d92900000,0x0000000d92a00000] [id=17636] 77 | 78 | [error occurred during error reporting (printing all threads), id 0xc0000005, EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ff8b3dab047] 79 | 80 | VM state: not at safepoint (not fully initialized) 81 | 82 | VM Mutex/Monitor currently owned by a thread: ([mutex/lock_event]) 83 | [0x0000018f0fbca6c0] Heap_lock - owner thread: 0x0000018f0fbd0b60 84 | 85 | Heap address: 0x0000000709a00000, size: 3942 MB, Compressed Oops mode: Zero based, Oop shift amount: 3 86 | 87 | CDS archive(s) mapped at: [0x0000000000000000-0x0000000000000000-0x0000000000000000), size 0, SharedBaseAddress: 0x0000000800000000, ArchiveRelocationMode: 1. 88 | Narrow klass base: 0x0000000000000000, Narrow klass shift: 0, Narrow klass range: 0x0 89 | 90 | GC Precious Log: 91 | 92 | 93 | Heap: 94 | garbage-first heap total 0K, used 0K [0x0000000709a00000, 0x0000000800000000) 95 | region size 2048K, 0 young (0K), 0 survivors (0K) 96 | 97 | [error occurred during error reporting (printing heap information), id 0xc0000005, EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ff8b4191499] 98 | 99 | GC Heap History (0 events): 100 | No events 101 | 102 | Deoptimization events (0 events): 103 | No events 104 | 105 | Classes unloaded (0 events): 106 | No events 107 | 108 | Classes redefined (0 events): 109 | No events 110 | 111 | Internal exceptions (0 events): 112 | No events 113 | 114 | VM Operations (0 events): 115 | No events 116 | 117 | Events (1 events): 118 | Event: 0.100 Loaded shared library D:\java sdk\jdk-17.0.8\bin\java.dll 119 | 120 | 121 | Dynamic libraries: 122 | 0x00007ff788310000 - 0x00007ff788320000 D:\java sdk\jdk-17.0.8\bin\java.exe 123 | 0x00007ff921c10000 - 0x00007ff921e27000 C:\Windows\SYSTEM32\ntdll.dll 124 | 0x00007ff920960000 - 0x00007ff920a24000 C:\Windows\System32\KERNEL32.DLL 125 | 0x00007ff91f0a0000 - 0x00007ff91f446000 C:\Windows\System32\KERNELBASE.dll 126 | 0x00007ff91f840000 - 0x00007ff91f951000 C:\Windows\System32\ucrtbase.dll 127 | 0x00007ff8b8060000 - 0x00007ff8b8079000 D:\java sdk\jdk-17.0.8\bin\jli.dll 128 | 0x00007ff8b5dd0000 - 0x00007ff8b5deb000 D:\java sdk\jdk-17.0.8\bin\VCRUNTIME140.dll 129 | 0x00007ff9204b0000 - 0x00007ff920561000 C:\Windows\System32\ADVAPI32.dll 130 | 0x00007ff91f960000 - 0x00007ff91fa07000 C:\Windows\System32\msvcrt.dll 131 | 0x00007ff91fc00000 - 0x00007ff91fca5000 C:\Windows\System32\sechost.dll 132 | 0x00007ff920c60000 - 0x00007ff920d77000 C:\Windows\System32\RPCRT4.dll 133 | 0x00007ff920dd0000 - 0x00007ff920f7e000 C:\Windows\System32\USER32.dll 134 | 0x00007ff91f640000 - 0x00007ff91f666000 C:\Windows\System32\win32u.dll 135 | 0x00007ff904f70000 - 0x00007ff905203000 C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.22621.2506_none_270c5ae97388e100\COMCTL32.dll 136 | 0x00007ff920da0000 - 0x00007ff920dc9000 C:\Windows\System32\GDI32.dll 137 | 0x00007ff91ef80000 - 0x00007ff91f098000 C:\Windows\System32\gdi32full.dll 138 | 0x00007ff91f7a0000 - 0x00007ff91f83a000 C:\Windows\System32\msvcp_win.dll 139 | 0x00007ff917050000 - 0x00007ff91705a000 C:\Windows\SYSTEM32\VERSION.dll 140 | 0x00007ff91fcd0000 - 0x00007ff91fd01000 C:\Windows\System32\IMM32.DLL 141 | 0x00007ff9035d0000 - 0x00007ff9035dc000 D:\java sdk\jdk-17.0.8\bin\vcruntime140_1.dll 142 | 0x00007ff8b46a0000 - 0x00007ff8b472e000 D:\java sdk\jdk-17.0.8\bin\msvcp140.dll 143 | 0x00007ff8b3ac0000 - 0x00007ff8b469e000 D:\java sdk\jdk-17.0.8\bin\server\jvm.dll 144 | 0x00007ff9218e0000 - 0x00007ff9218e8000 C:\Windows\System32\PSAPI.DLL 145 | 0x00007ff91c210000 - 0x00007ff91c219000 C:\Windows\SYSTEM32\WSOCK32.dll 146 | 0x00007ff915ce0000 - 0x00007ff915d14000 C:\Windows\SYSTEM32\WINMM.dll 147 | 0x00007ff920ff0000 - 0x00007ff921061000 C:\Windows\System32\WS2_32.dll 148 | 0x00007ff91df60000 - 0x00007ff91df78000 C:\Windows\SYSTEM32\kernel.appcore.dll 149 | 0x00007ff902da0000 - 0x00007ff902daa000 D:\java sdk\jdk-17.0.8\bin\jimage.dll 150 | 0x00007ff9180d0000 - 0x00007ff918303000 C:\Windows\SYSTEM32\DBGHELP.DLL 151 | 0x00007ff9205d0000 - 0x00007ff920959000 C:\Windows\System32\combase.dll 152 | 0x00007ff91fb20000 - 0x00007ff91fbf7000 C:\Windows\System32\OLEAUT32.dll 153 | 0x00007ff909d00000 - 0x00007ff909d32000 C:\Windows\SYSTEM32\dbgcore.DLL 154 | 0x00007ff91f5c0000 - 0x00007ff91f63a000 C:\Windows\System32\bcryptPrimitives.dll 155 | 0x00007ff8b3a90000 - 0x00007ff8b3ab5000 D:\java sdk\jdk-17.0.8\bin\java.dll 156 | 157 | dbghelp: loaded successfully - version: 4.0.5 - missing functions: none 158 | symbol engine: initialized successfully - sym options: 0x614 - pdb path: .;D:\java sdk\jdk-17.0.8\bin;C:\Windows\SYSTEM32;C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.22621.2506_none_270c5ae97388e100;D:\java sdk\jdk-17.0.8\bin\server 159 | 160 | VM Arguments: 161 | java_command: 162 | java_class_path (initial): 163 | Launcher Type: SUN_STANDARD 164 | 165 | [Global flags] 166 | intx CICompilerCount = 12 {product} {ergonomic} 167 | uint ConcGCThreads = 3 {product} {ergonomic} 168 | uint G1ConcRefinementThreads = 13 {product} {ergonomic} 169 | size_t G1HeapRegionSize = 2097152 {product} {ergonomic} 170 | uintx GCDrainStackTargetSize = 64 {product} {ergonomic} 171 | size_t InitialHeapSize = 260046848 {product} {ergonomic} 172 | size_t MarkStackSize = 4194304 {product} {ergonomic} 173 | size_t MaxHeapSize = 4133486592 {product} {ergonomic} 174 | size_t MinHeapDeltaBytes = 2097152 {product} {ergonomic} 175 | size_t MinHeapSize = 8388608 {product} {ergonomic} 176 | uintx NonNMethodCodeHeapSize = 7602480 {pd product} {ergonomic} 177 | uintx NonProfiledCodeHeapSize = 122027880 {pd product} {ergonomic} 178 | uintx ProfiledCodeHeapSize = 122027880 {pd product} {ergonomic} 179 | uintx ReservedCodeCacheSize = 251658240 {pd product} {ergonomic} 180 | bool SegmentedCodeCache = true {product} {ergonomic} 181 | size_t SoftMaxHeapSize = 4133486592 {manageable} {ergonomic} 182 | bool UseCompressedClassPointers = true {product lp64_product} {ergonomic} 183 | bool UseCompressedOops = true {product lp64_product} {ergonomic} 184 | bool UseG1GC = true {product} {ergonomic} 185 | bool UseLargePagesIndividualAllocation = false {pd product} {ergonomic} 186 | 187 | Logging: 188 | Log output configuration: 189 | #0: stdout all=warning uptime,level,tags 190 | #1: stderr all=off uptime,level,tags 191 | 192 | Environment Variables: 193 | PATH=C:\Users\Admin\Desktop\open-im-sdk-reactnative\example\node_modules\.bin;C:\Users\Admin\Desktop\open-im-sdk-reactnative\example\node_modules\.bin;C:\Users\Admin\Desktop\open-im-sdk-reactnative\node_modules\.bin;C:\Users\Admin\Desktop\node_modules\.bin;C:\Users\Admin\node_modules\.bin;C:\Users\node_modules\.bin;C:\node_modules\.bin;C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\run-script\lib\node-gyp-bin;C:\Users\Admin\Desktop\open-im-sdk-reactnative\example\node_modules\.bin;C:\Users\Admin\Desktop\open-im-sdk-reactnative\node_modules\.bin;C:\Users\Admin\Desktop\node_modules\.bin;C:\Users\Admin\node_modules\.bin;C:\Users\node_modules\.bin;C:\node_modules\.bin;C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\run-script\lib\node-gyp-bin;D:\software\vmware\bin\;C:\Windows\system32 w10zj.com;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;D:\go sdk\bin;D:\java sdk\jdk-17.0.8\bin;D:\MySQL\MySQL\bin;D:\go sdk\bin;C:\Windows\System32;C:\windows\System32;D:\software\Git\cmd;D:\software\Git\bin;C:\Program Files\nodejs\;C:\Program Files (x86)\NetSarang\Xshell 7\;C:\Users\Admin\AppData\Local\Programs\Python\Launcher\;C:\Users\Admin\AppData\Local\Microsoft\WindowsApps;D:\software\GoLand 2023.2\bin;;C:\Users\Admin\go\bin;C:\Program Files\RedPanda-Cpp\MinGW64\bin;D:\software\Git\bin;D:\software\GoLand 2023.2\bin;C:\Program Files (x86)\Tencent\QQGameTempest\Hall.57938\;C:\Users\Admin\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Admin\AppData\Roaming\npm;C:\Users\Admin\AppData\Local\GitHubDesktop\bin; 194 | USERNAME=Admin 195 | OS=Windows_NT 196 | PROCESSOR_IDENTIFIER=AMD64 Family 25 Model 80 Stepping 0, AuthenticAMD 197 | 198 | 199 | 200 | --------------- S Y S T E M --------------- 201 | 202 | OS: 203 | Windows 11 , 64 bit Build 22621 (10.0.22621.2506) 204 | OS uptime: 0 days 2:55 hours 205 | 206 | CPU: total 16 (initial active 16) (16 cores per cpu, 2 threads per core) family 25 model 80 stepping 0 microcode 0x0, cx8, cmov, fxsr, ht, mmx, 3dnowpref, sse, sse2, sse3, ssse3, sse4a, sse4.1, sse4.2, popcnt, lzcnt, tsc, tscinvbit, avx, avx2, aes, erms, clmul, bmi1, bmi2, adx, sha, fma, vzeroupper, clflush, clflushopt 207 | 208 | Memory: 4k page, system-wide physical 15763M (617M free) 209 | TotalPageFile size 23946M (AvailPageFile size 146M) 210 | current process WorkingSet (physical memory assigned to process): 11M, peak: 11M 211 | current process commit charge ("private bytes"): 70M, peak: 318M 212 | 213 | vm_info: Java HotSpot(TM) 64-Bit Server VM (17.0.8+9-LTS-211) for windows-amd64 JRE (17.0.8+9-LTS-211), built on Jun 14 2023 10:34:31 by "mach5one" with MS VC++ 17.1 (VS2022) 214 | 215 | END. 216 | -------------------------------------------------------------------------------- /example/android/hs_err_pid22216.log: -------------------------------------------------------------------------------- 1 | # 2 | # There is insufficient memory for the Java Runtime Environment to continue. 3 | # Native memory allocation (mmap) failed to map 260046848 bytes for G1 virtual space 4 | # Possible reasons: 5 | # The system is out of physical RAM or swap space 6 | # The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap 7 | # Possible solutions: 8 | # Reduce memory load on the system 9 | # Increase physical memory or swap space 10 | # Check if swap backing store is full 11 | # Decrease Java heap size (-Xmx/-Xms) 12 | # Decrease number of Java threads 13 | # Decrease Java thread stack sizes (-Xss) 14 | # Set larger code cache with -XX:ReservedCodeCacheSize= 15 | # JVM is running with Zero Based Compressed Oops mode in which the Java heap is 16 | # placed in the first 32GB address space. The Java Heap base address is the 17 | # maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress 18 | # to set the Java Heap base and to place the Java Heap above 32GB virtual address. 19 | # This output file may be truncated or incomplete. 20 | # 21 | # Out of Memory Error (os_windows.cpp:3550), pid=22216, tid=20456 22 | # 23 | # JRE version: (17.0.8+9) (build ) 24 | # Java VM: Java HotSpot(TM) 64-Bit Server VM (17.0.8+9-LTS-211, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, windows-amd64) 25 | # No core dump will be written. Minidumps are not enabled by default on client versions of Windows 26 | # 27 | 28 | --------------- S U M M A R Y ------------ 29 | 30 | Command Line: 31 | 32 | Host: AMD Ryzen 7 5700G with Radeon Graphics , 16 cores, 15G, Windows 11 , 64 bit Build 22621 (10.0.22621.2506) 33 | Time: Tue Dec 26 14:36:39 2023 Windows 11 , 64 bit Build 22621 (10.0.22621.2506) elapsed time: 0.010172 seconds (0d 0h 0m 0s) 34 | 35 | --------------- T H R E A D --------------- 36 | 37 | Current thread (0x000002e7bcc607f0): JavaThread "Unknown thread" [_thread_in_vm, id=20456, stack(0x000000fcfa100000,0x000000fcfa200000)] 38 | 39 | Stack: [0x000000fcfa100000,0x000000fcfa200000] 40 | Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) 41 | V [jvm.dll+0x677d0a] 42 | V [jvm.dll+0x7d8c54] 43 | V [jvm.dll+0x7da3fe] 44 | V [jvm.dll+0x7daa63] 45 | V [jvm.dll+0x245c5f] 46 | V [jvm.dll+0x674bb9] 47 | V [jvm.dll+0x6694f2] 48 | V [jvm.dll+0x3031d6] 49 | V [jvm.dll+0x30a756] 50 | V [jvm.dll+0x359f9e] 51 | V [jvm.dll+0x35a1cf] 52 | V [jvm.dll+0x2da3e8] 53 | V [jvm.dll+0x2db354] 54 | V [jvm.dll+0x7aa711] 55 | V [jvm.dll+0x367b51] 56 | V [jvm.dll+0x789979] 57 | V [jvm.dll+0x3eb05f] 58 | V [jvm.dll+0x3ecae1] 59 | C [jli.dll+0x5297] 60 | C [ucrtbase.dll+0x29363] 61 | C [KERNEL32.DLL+0x1257d] 62 | C [ntdll.dll+0x5aa58] 63 | 64 | 65 | --------------- P R O C E S S --------------- 66 | 67 | Threads class SMR info: 68 | _java_thread_list=0x00007ff87dec59d8, length=0, elements={ 69 | } 70 | 71 | Java Threads: ( => current thread ) 72 | 73 | Other Threads: 74 | 0x000002e7bccc8490 GCTaskThread "GC Thread#0" [stack: 0x000000fcfa200000,0x000000fcfa300000] [id=18572] 75 | 0x000002e7bccd8a20 ConcurrentGCThread "G1 Main Marker" [stack: 0x000000fcfa300000,0x000000fcfa400000] [id=22932] 76 | 0x000002e7bccdbae0 ConcurrentGCThread "G1 Conc#0" [stack: 0x000000fcfa400000,0x000000fcfa500000] [id=460] 77 | 78 | [error occurred during error reporting (printing all threads), id 0xc0000005, EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ff87d6fb047] 79 | 80 | VM state: not at safepoint (not fully initialized) 81 | 82 | VM Mutex/Monitor currently owned by a thread: ([mutex/lock_event]) 83 | [0x000002e7bcc5f900] Heap_lock - owner thread: 0x000002e7bcc607f0 84 | 85 | Heap address: 0x0000000709a00000, size: 3942 MB, Compressed Oops mode: Zero based, Oop shift amount: 3 86 | 87 | CDS archive(s) mapped at: [0x0000000000000000-0x0000000000000000-0x0000000000000000), size 0, SharedBaseAddress: 0x0000000800000000, ArchiveRelocationMode: 1. 88 | Narrow klass base: 0x0000000000000000, Narrow klass shift: 0, Narrow klass range: 0x0 89 | 90 | GC Precious Log: 91 | 92 | 93 | Heap: 94 | garbage-first heap total 0K, used 0K [0x0000000709a00000, 0x0000000800000000) 95 | region size 2048K, 0 young (0K), 0 survivors (0K) 96 | 97 | [error occurred during error reporting (printing heap information), id 0xc0000005, EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ff87dae1499] 98 | 99 | GC Heap History (0 events): 100 | No events 101 | 102 | Deoptimization events (0 events): 103 | No events 104 | 105 | Classes unloaded (0 events): 106 | No events 107 | 108 | Classes redefined (0 events): 109 | No events 110 | 111 | Internal exceptions (0 events): 112 | No events 113 | 114 | VM Operations (0 events): 115 | No events 116 | 117 | Events (1 events): 118 | Event: 0.006 Loaded shared library D:\java sdk\jdk-17.0.8\bin\java.dll 119 | 120 | 121 | Dynamic libraries: 122 | 0x00007ff7b9890000 - 0x00007ff7b98a0000 D:\java sdk\jdk-17.0.8\bin\java.exe 123 | 0x00007ff921c10000 - 0x00007ff921e27000 C:\Windows\SYSTEM32\ntdll.dll 124 | 0x00007ff920960000 - 0x00007ff920a24000 C:\Windows\System32\KERNEL32.DLL 125 | 0x00007ff91f0a0000 - 0x00007ff91f446000 C:\Windows\System32\KERNELBASE.dll 126 | 0x00007ff91f840000 - 0x00007ff91f951000 C:\Windows\System32\ucrtbase.dll 127 | 0x00007ff910a00000 - 0x00007ff910a19000 D:\java sdk\jdk-17.0.8\bin\jli.dll 128 | 0x00007ff9109e0000 - 0x00007ff9109fb000 D:\java sdk\jdk-17.0.8\bin\VCRUNTIME140.dll 129 | 0x00007ff9204b0000 - 0x00007ff920561000 C:\Windows\System32\ADVAPI32.dll 130 | 0x00007ff91f960000 - 0x00007ff91fa07000 C:\Windows\System32\msvcrt.dll 131 | 0x00007ff91fc00000 - 0x00007ff91fca5000 C:\Windows\System32\sechost.dll 132 | 0x00007ff920c60000 - 0x00007ff920d77000 C:\Windows\System32\RPCRT4.dll 133 | 0x00007ff920dd0000 - 0x00007ff920f7e000 C:\Windows\System32\USER32.dll 134 | 0x00007ff91f640000 - 0x00007ff91f666000 C:\Windows\System32\win32u.dll 135 | 0x00007ff920da0000 - 0x00007ff920dc9000 C:\Windows\System32\GDI32.dll 136 | 0x00007ff904f70000 - 0x00007ff905203000 C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.22621.2506_none_270c5ae97388e100\COMCTL32.dll 137 | 0x00007ff91ef80000 - 0x00007ff91f098000 C:\Windows\System32\gdi32full.dll 138 | 0x00007ff91f7a0000 - 0x00007ff91f83a000 C:\Windows\System32\msvcp_win.dll 139 | 0x00007ff917050000 - 0x00007ff91705a000 C:\Windows\SYSTEM32\VERSION.dll 140 | 0x00007ff91fcd0000 - 0x00007ff91fd01000 C:\Windows\System32\IMM32.DLL 141 | 0x00007ff900510000 - 0x00007ff90051c000 D:\java sdk\jdk-17.0.8\bin\vcruntime140_1.dll 142 | 0x00007ff8b34f0000 - 0x00007ff8b357e000 D:\java sdk\jdk-17.0.8\bin\msvcp140.dll 143 | 0x00007ff87d410000 - 0x00007ff87dfee000 D:\java sdk\jdk-17.0.8\bin\server\jvm.dll 144 | 0x00007ff9218e0000 - 0x00007ff9218e8000 C:\Windows\System32\PSAPI.DLL 145 | 0x00007ff915ce0000 - 0x00007ff915d14000 C:\Windows\SYSTEM32\WINMM.dll 146 | 0x00007ff91c210000 - 0x00007ff91c219000 C:\Windows\SYSTEM32\WSOCK32.dll 147 | 0x00007ff920ff0000 - 0x00007ff921061000 C:\Windows\System32\WS2_32.dll 148 | 0x00007ff91df60000 - 0x00007ff91df78000 C:\Windows\SYSTEM32\kernel.appcore.dll 149 | 0x00007ff8ffc10000 - 0x00007ff8ffc1a000 D:\java sdk\jdk-17.0.8\bin\jimage.dll 150 | 0x00007ff9180d0000 - 0x00007ff918303000 C:\Windows\SYSTEM32\DBGHELP.DLL 151 | 0x00007ff9205d0000 - 0x00007ff920959000 C:\Windows\System32\combase.dll 152 | 0x00007ff91fb20000 - 0x00007ff91fbf7000 C:\Windows\System32\OLEAUT32.dll 153 | 0x00007ff909d00000 - 0x00007ff909d32000 C:\Windows\SYSTEM32\dbgcore.DLL 154 | 0x00007ff91f5c0000 - 0x00007ff91f63a000 C:\Windows\System32\bcryptPrimitives.dll 155 | 0x00007ff8e4650000 - 0x00007ff8e4675000 D:\java sdk\jdk-17.0.8\bin\java.dll 156 | 157 | dbghelp: loaded successfully - version: 4.0.5 - missing functions: none 158 | symbol engine: initialized successfully - sym options: 0x614 - pdb path: .;D:\java sdk\jdk-17.0.8\bin;C:\Windows\SYSTEM32;C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.22621.2506_none_270c5ae97388e100;D:\java sdk\jdk-17.0.8\bin\server 159 | 160 | VM Arguments: 161 | java_command: 162 | java_class_path (initial): 163 | Launcher Type: SUN_STANDARD 164 | 165 | [Global flags] 166 | intx CICompilerCount = 12 {product} {ergonomic} 167 | uint ConcGCThreads = 3 {product} {ergonomic} 168 | uint G1ConcRefinementThreads = 13 {product} {ergonomic} 169 | size_t G1HeapRegionSize = 2097152 {product} {ergonomic} 170 | uintx GCDrainStackTargetSize = 64 {product} {ergonomic} 171 | size_t InitialHeapSize = 260046848 {product} {ergonomic} 172 | size_t MarkStackSize = 4194304 {product} {ergonomic} 173 | size_t MaxHeapSize = 4133486592 {product} {ergonomic} 174 | size_t MinHeapDeltaBytes = 2097152 {product} {ergonomic} 175 | size_t MinHeapSize = 8388608 {product} {ergonomic} 176 | uintx NonNMethodCodeHeapSize = 7602480 {pd product} {ergonomic} 177 | uintx NonProfiledCodeHeapSize = 122027880 {pd product} {ergonomic} 178 | uintx ProfiledCodeHeapSize = 122027880 {pd product} {ergonomic} 179 | uintx ReservedCodeCacheSize = 251658240 {pd product} {ergonomic} 180 | bool SegmentedCodeCache = true {product} {ergonomic} 181 | size_t SoftMaxHeapSize = 4133486592 {manageable} {ergonomic} 182 | bool UseCompressedClassPointers = true {product lp64_product} {ergonomic} 183 | bool UseCompressedOops = true {product lp64_product} {ergonomic} 184 | bool UseG1GC = true {product} {ergonomic} 185 | bool UseLargePagesIndividualAllocation = false {pd product} {ergonomic} 186 | 187 | Logging: 188 | Log output configuration: 189 | #0: stdout all=warning uptime,level,tags 190 | #1: stderr all=off uptime,level,tags 191 | 192 | Environment Variables: 193 | PATH=C:\Users\Admin\Desktop\open-im-sdk-reactnative\example\node_modules\.bin;C:\Users\Admin\Desktop\open-im-sdk-reactnative\example\node_modules\.bin;C:\Users\Admin\Desktop\open-im-sdk-reactnative\node_modules\.bin;C:\Users\Admin\Desktop\node_modules\.bin;C:\Users\Admin\node_modules\.bin;C:\Users\node_modules\.bin;C:\node_modules\.bin;C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\run-script\lib\node-gyp-bin;C:\Users\Admin\Desktop\open-im-sdk-reactnative\example\node_modules\.bin;C:\Users\Admin\Desktop\open-im-sdk-reactnative\node_modules\.bin;C:\Users\Admin\Desktop\node_modules\.bin;C:\Users\Admin\node_modules\.bin;C:\Users\node_modules\.bin;C:\node_modules\.bin;C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\run-script\lib\node-gyp-bin;D:\software\vmware\bin\;C:\Windows\system32 w10zj.com;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;D:\go sdk\bin;D:\java sdk\jdk-17.0.8\bin;D:\MySQL\MySQL\bin;D:\go sdk\bin;C:\Windows\System32;C:\windows\System32;D:\software\Git\cmd;D:\software\Git\bin;C:\Program Files\nodejs\;C:\Program Files (x86)\NetSarang\Xshell 7\;C:\Users\Admin\AppData\Local\Programs\Python\Launcher\;C:\Users\Admin\AppData\Local\Microsoft\WindowsApps;D:\software\GoLand 2023.2\bin;;C:\Users\Admin\go\bin;C:\Program Files\RedPanda-Cpp\MinGW64\bin;D:\software\Git\bin;D:\software\GoLand 2023.2\bin;C:\Program Files (x86)\Tencent\QQGameTempest\Hall.57938\;C:\Users\Admin\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Admin\AppData\Roaming\npm;C:\Users\Admin\AppData\Local\GitHubDesktop\bin; 194 | USERNAME=Admin 195 | OS=Windows_NT 196 | PROCESSOR_IDENTIFIER=AMD64 Family 25 Model 80 Stepping 0, AuthenticAMD 197 | 198 | 199 | 200 | --------------- S Y S T E M --------------- 201 | 202 | OS: 203 | Windows 11 , 64 bit Build 22621 (10.0.22621.2506) 204 | OS uptime: 0 days 5:11 hours 205 | 206 | CPU: total 16 (initial active 16) (16 cores per cpu, 2 threads per core) family 25 model 80 stepping 0 microcode 0x0, cx8, cmov, fxsr, ht, mmx, 3dnowpref, sse, sse2, sse3, ssse3, sse4a, sse4.1, sse4.2, popcnt, lzcnt, tsc, tscinvbit, avx, avx2, aes, erms, clmul, bmi1, bmi2, adx, sha, fma, vzeroupper, clflush, clflushopt 207 | 208 | Memory: 4k page, system-wide physical 15763M (471M free) 209 | TotalPageFile size 23940M (AvailPageFile size 74M) 210 | current process WorkingSet (physical memory assigned to process): 11M, peak: 11M 211 | current process commit charge ("private bytes"): 70M, peak: 318M 212 | 213 | vm_info: Java HotSpot(TM) 64-Bit Server VM (17.0.8+9-LTS-211) for windows-amd64 JRE (17.0.8+9-LTS-211), built on Jun 14 2023 10:34:31 by "mach5one" with MS VC++ 17.1 (VS2022) 214 | 215 | END. 216 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'OpenImSdkRnExample' 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": "OpenImSdkRnExample", 3 | "displayName": "OpenImSdkRnExample" 4 | } 5 | -------------------------------------------------------------------------------- /example/babel.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const pak = require('../package.json'); 3 | 4 | module.exports = { 5 | presets: ['module:metro-react-native-babel-preset'], 6 | plugins: [ 7 | [ 8 | 'module-resolver', 9 | { 10 | extensions: ['.tsx', '.ts', '.js', '.json'], 11 | alias: { 12 | [pak.name]: path.join(__dirname, '..', pak.source), 13 | }, 14 | }, 15 | ], 16 | ], 17 | }; 18 | -------------------------------------------------------------------------------- /example/index.js: -------------------------------------------------------------------------------- 1 | import { AppRegistry } from 'react-native'; 2 | import App from './src/App'; 3 | import { name as appName } from './app.json'; 4 | 5 | AppRegistry.registerComponent(appName, () => App); 6 | -------------------------------------------------------------------------------- /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/File.swift: -------------------------------------------------------------------------------- 1 | // 2 | // File.swift 3 | // OpenImSdkRnExample 4 | // 5 | 6 | import Foundation 7 | -------------------------------------------------------------------------------- /example/ios/OpenImSdkRnExample-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | -------------------------------------------------------------------------------- /example/ios/OpenImSdkRnExample.xcodeproj/xcshareddata/xcschemes/OpenImSdkRnExample.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/OpenImSdkRnExample.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/OpenImSdkRnExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/OpenImSdkRnExample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : RCTAppDelegate 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /example/ios/OpenImSdkRnExample/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 = @"OpenImSdkRnExample"; 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 | @end 27 | -------------------------------------------------------------------------------- /example/ios/OpenImSdkRnExample/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/OpenImSdkRnExample/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info": { 3 | "version": 1, 4 | "author": "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /example/ios/OpenImSdkRnExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | OpenImSdkRnExample 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/OpenImSdkRnExample/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/OpenImSdkRnExample/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/OpenImSdkRnExampleTests/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/OpenImSdkRnExampleTests/OpenImSdkRnExampleTests.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 OpenImSdkRnExampleTests : XCTestCase 11 | 12 | @end 13 | 14 | @implementation OpenImSdkRnExampleTests 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/Podfile: -------------------------------------------------------------------------------- 1 | # Resolve react_native_pods.rb with node to allow for hoisting 2 | require Pod::Executable.execute_command('node', ['-p', 3 | 'require.resolve( 4 | "react-native/scripts/react_native_pods.rb", 5 | {paths: [process.argv[1]]}, 6 | )', __dir__]).strip 7 | 8 | platform :ios, min_ios_version_supported 9 | prepare_react_native_project! 10 | 11 | # If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set. 12 | # because `react-native-flipper` depends on (FlipperKit,...) that will be excluded 13 | # 14 | # To fix this you can also exclude `react-native-flipper` using a `react-native.config.js` 15 | # ```js 16 | # module.exports = { 17 | # dependencies: { 18 | # ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}), 19 | # ``` 20 | flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled 21 | 22 | linkage = ENV['USE_FRAMEWORKS'] 23 | if linkage != nil 24 | Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green 25 | use_frameworks! :linkage => linkage.to_sym 26 | end 27 | 28 | target 'OpenImSdkRnExample' do 29 | config = use_native_modules! 30 | 31 | # Flags change depending on the env values. 32 | flags = get_default_flags() 33 | 34 | use_react_native!( 35 | :path => config[:reactNativePath], 36 | # Hermes is now enabled by default. Disable by setting this flag to false. 37 | :hermes_enabled => flags[:hermes_enabled], 38 | :fabric_enabled => flags[:fabric_enabled], 39 | # Enables Flipper. 40 | # 41 | # Note that if you have use_frameworks! enabled, Flipper will not work and 42 | # you should disable the next line. 43 | :flipper_configuration => flipper_config, 44 | # An absolute path to your application root. 45 | :app_path => "#{Pod::Config.instance.installation_root}/.." 46 | ) 47 | pod 'open-im-sdk-rn', :path => '../..' 48 | target 'OpenImSdkRnExampleTests' do 49 | inherit! :complete 50 | # Pods for testing 51 | end 52 | 53 | post_install do |installer| 54 | # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202 55 | react_native_post_install( 56 | installer, 57 | config[:reactNativePath], 58 | :mac_catalyst_enabled => false 59 | ) 60 | __apply_Xcode_12_5_M1_post_install_workaround(installer) 61 | end 62 | end 63 | -------------------------------------------------------------------------------- /example/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'react-native', 3 | }; 4 | -------------------------------------------------------------------------------- /example/metro.config.js: -------------------------------------------------------------------------------- 1 | const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config'); 2 | const path = require('path'); 3 | const escape = require('escape-string-regexp'); 4 | const exclusionList = require('metro-config/src/defaults/exclusionList'); 5 | const pak = require('../package.json'); 6 | 7 | const root = path.resolve(__dirname, '..'); 8 | const modules = Object.keys({ ...pak.peerDependencies }); 9 | 10 | /** 11 | * Metro configuration 12 | * https://facebook.github.io/metro/docs/configuration 13 | * 14 | * @type {import('metro-config').MetroConfig} 15 | */ 16 | const config = { 17 | watchFolders: [root], 18 | 19 | // We need to make sure that only one version is loaded for peerDependencies 20 | // So we block them at the root, and alias them to the versions in example's node_modules 21 | resolver: { 22 | blacklistRE: exclusionList( 23 | modules.map( 24 | (m) => 25 | new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`) 26 | ) 27 | ), 28 | 29 | extraNodeModules: modules.reduce((acc, name) => { 30 | acc[name] = path.join(__dirname, 'node_modules', name); 31 | return acc; 32 | }, {}), 33 | }, 34 | 35 | transformer: { 36 | getTransformOptions: async () => ({ 37 | transform: { 38 | experimentalImportSupport: false, 39 | inlineRequires: true, 40 | }, 41 | }), 42 | }, 43 | }; 44 | 45 | module.exports = mergeConfig(getDefaultConfig(__dirname), config); 46 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "OpenImSdkRnExample", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "android": "react-native run-android", 7 | "ios": "react-native run-ios", 8 | "start": "react-native start", 9 | "pods": "pod-install --quiet" 10 | }, 11 | "dependencies": { 12 | "open-im-sdk-rn": "^3.4.2", 13 | "react": "18.2.0", 14 | "react-native": "0.72.4", 15 | "react-native-fs": "^2.20.0" 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/eslint-config": "^0.72.2", 22 | "@react-native/metro-config": "^0.72.11", 23 | "babel-plugin-module-resolver": "^5.0.0", 24 | "metro-react-native-babel-preset": "0.76.8" 25 | }, 26 | "engines": { 27 | "node": ">=16" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /example/react-native.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const pak = require('../package.json'); 3 | 4 | module.exports = { 5 | dependencies: { 6 | [pak.name]: { 7 | root: path.join(__dirname, '..'), 8 | }, 9 | }, 10 | }; 11 | -------------------------------------------------------------------------------- /example/src/App.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import OpenIMSDKRN, { OpenIMEmitter } from 'open-im-sdk-rn'; 3 | import RNFS from 'react-native-fs'; 4 | import { Button, StyleSheet, View } from 'react-native'; 5 | import { MessageItem } from 'src/types/entity'; 6 | 7 | function App(): React.JSX.Element { 8 | RNFS.mkdir(RNFS.DocumentDirectoryPath + '/tmp'); 9 | const init = async () => { 10 | try { 11 | await OpenIMSDKRN.initSDK( 12 | { 13 | apiAddr: 'http://127.0.0.1:10002', 14 | wsAddr: 'ws://127.0.0.1:10001', 15 | dataDir: RNFS.DocumentDirectoryPath + '/tmp', 16 | logLevel: 5, 17 | isLogStandardOutput: true, 18 | }, 19 | 'hrtyy45t' 20 | ); 21 | console.log('initSDK success'); 22 | } catch (error) { 23 | console.log('initSDK error'); 24 | } 25 | }; 26 | 27 | const iosLogin = async () => { 28 | try { 29 | await OpenIMSDKRN.login( 30 | { 31 | userID: '3742375535', 32 | token: 'xxx', 33 | }, 34 | 'hrtyy45t' 35 | ); 36 | console.log(await OpenIMSDKRN.getLoginStatus('hrtyy45t')); 37 | } catch (error) { 38 | console.error('login error', error); 39 | } 40 | }; 41 | 42 | const androidLogin = async () => { 43 | try { 44 | await OpenIMSDKRN.login( 45 | { 46 | userID: '3742375535', 47 | token: 'xx', 48 | }, 49 | 'hrtyy45t' 50 | ); 51 | console.log(await OpenIMSDKRN.getLoginStatus('hrtyy45t')); 52 | } catch (error) { 53 | console.error('login error', error); 54 | } 55 | }; 56 | 57 | const sendTextMsg = async () => { 58 | try { 59 | const message = await OpenIMSDKRN.createTextMessage( 60 | 'sendTextMsg', 61 | 'hrtyy45t' 62 | ); 63 | console.info('createTextMessage', typeof message, message); 64 | await sendMsg(message); 65 | } catch (error) { 66 | console.error('Error createCardMessage:', error); 67 | } 68 | }; 69 | 70 | const sendCardMsg = async () => { 71 | try { 72 | const message = await OpenIMSDKRN.createCardMessage( 73 | { 74 | userID: '6265276311', 75 | nickname: 'kevin1', 76 | faceURL: '', 77 | ex: '', 78 | }, 79 | 'hrtyy45t' 80 | ); 81 | console.info('createCardMessage', message); 82 | await sendMsg(message); 83 | } catch (error) { 84 | console.error('Error createCardMessage:', error); 85 | } 86 | }; 87 | 88 | const sendLocationMsg = async () => { 89 | try { 90 | const message = await OpenIMSDKRN.createLocationMessage( 91 | { 92 | description: 'location', 93 | longitude: 22.2, 94 | latitude: 33.3, 95 | }, 96 | 'hrtyy45t' 97 | ); 98 | console.info('createLocationMessage', message); 99 | await sendMsg(message); 100 | } catch (error) { 101 | console.error('Error createLocationMessage:', error); 102 | } 103 | }; 104 | 105 | const sendGroupMsg = async (message: MessageItem) => { 106 | try { 107 | const res = await OpenIMSDKRN.sendMessage( 108 | { 109 | recvID: '', 110 | groupID: '1944501993', 111 | message, 112 | }, 113 | 'hrtyy45t' 114 | ); 115 | console.info('sendGroupMsg', typeof res, res); 116 | } catch (error) { 117 | console.error('Error sendGroupMsg:', error); 118 | } 119 | }; 120 | 121 | const sendMsg = async (message: MessageItem) => { 122 | try { 123 | const res = await OpenIMSDKRN.sendMessage( 124 | { 125 | recvID: '6265276311', 126 | groupID: '', 127 | message, 128 | }, 129 | 'hrtyy45t' 130 | ); 131 | console.info('sendMessage', typeof res, res); 132 | } catch (error) { 133 | console.error('Error sendMsg:', error); 134 | } 135 | }; 136 | 137 | const getMessageList = async () => { 138 | const { messageList } = await OpenIMSDKRN.getAdvancedHistoryMessageList( 139 | { 140 | lastMinSeq: 0, 141 | count: 20, 142 | startClientMsgID: '', 143 | conversationID: 'si_3742375535_6265276311', 144 | }, 145 | 'hrtyy45t' 146 | ); 147 | console.info('getAdvancedHistoryMessageList', messageList); 148 | }; 149 | 150 | const getConversationListSplit = async () => { 151 | try { 152 | const res = await OpenIMSDKRN.getConversationListSplit( 153 | { 154 | offset: 0, 155 | count: 10, 156 | }, 157 | 'hrtyy45t' 158 | ); 159 | console.info('getConversationListSplit', res); 160 | } catch (error) { 161 | console.error('Error getConversationListSplit:', error); 162 | } 163 | }; 164 | 165 | const getConversationIDBySessionType = async () => { 166 | try { 167 | const res = await OpenIMSDKRN.getConversationIDBySessionType( 168 | { 169 | sourceID: '3742375535', 170 | sessionType: 3, 171 | }, 172 | 'hrtyy45t' 173 | ); 174 | console.info('getConversationIDBySessionType', res); 175 | } catch (error) { 176 | console.error('Error getConversationIDBySessionType:', error); 177 | } 178 | }; 179 | 180 | const getUserInfo = async () => { 181 | try { 182 | const data = await OpenIMSDKRN.getSelfUserInfo('operationID'); 183 | console.log('getSelfUserInfo', data); 184 | } catch (error) { 185 | console.error('Error getSelfUserInfo', error); 186 | } 187 | }; 188 | 189 | const updateInfo = async () => { 190 | try { 191 | await OpenIMSDKRN.setSelfInfo( 192 | { 193 | nickname: 'k0', 194 | faceURL: '', 195 | ex: '', 196 | }, 197 | 'hrtyy45t' 198 | ); 199 | console.info('setSelfInfo'); 200 | } catch (error) { 201 | console.error('Error getConversationListSplit:', error); 202 | } 203 | }; 204 | 205 | const at = async () => { 206 | try { 207 | const message = await OpenIMSDKRN.createTextAtMessage( 208 | { 209 | text: '123 @6265276311 123', 210 | atUserIDList: ['6265276311'], 211 | atUsersInfo: [ 212 | { 213 | atUserID: '6265276311', 214 | groupNickname: 'kevin1', 215 | }, 216 | ], 217 | }, 218 | 'hrtyy45t' 219 | ); 220 | console.info('createTextAtMessage', typeof message, message); 221 | await sendGroupMsg(message); 222 | } catch (error) { 223 | console.error('Error createTextAtMessage:', error); 224 | } 225 | }; 226 | 227 | const joinGroup = async () => { 228 | try { 229 | await OpenIMSDKRN.joinGroup( 230 | { 231 | groupID: '2602656113', 232 | reqMsg: 'join', 233 | joinSource: 2, 234 | }, 235 | 'hrtyy45t' 236 | ); 237 | console.info('joinGroup'); 238 | } catch (error) { 239 | console.error('Error joinGroup'); 240 | } 241 | }; 242 | 243 | const pinConversation = async (isPinned: boolean) => { 244 | OpenIMSDKRN.setConversationBurnDuration; 245 | try { 246 | await OpenIMSDKRN.pinConversation( 247 | { 248 | conversationID: 'si_3742375535_6265276311', 249 | isPinned, 250 | }, 251 | 'hrtyy45t' 252 | ); 253 | console.info('pinConversation'); 254 | } catch (error) { 255 | console.error('Error pinConversation'); 256 | } 257 | }; 258 | 259 | OpenIMEmitter.addListener('onConnecting', () => { 260 | console.warn('onConnecting'); 261 | }); 262 | 263 | OpenIMEmitter.addListener('onConnectSuccess', () => { 264 | console.warn('onConnectSuccess'); 265 | }); 266 | 267 | OpenIMEmitter.addListener('onConnectFailed', (res) => { 268 | console.warn('onConnectFailed', res); 269 | }); 270 | 271 | OpenIMEmitter.addListener('onUserTokenExpired', () => { 272 | console.warn('onUserTokenExpired'); 273 | }); 274 | 275 | OpenIMEmitter.addListener('onRecvNewMessages', (data: MessageItem[]) => { 276 | console.warn('onRecvNewMessages', data); 277 | }); 278 | 279 | OpenIMEmitter.addListener('onSelfInfoUpdated', (data) => { 280 | console.warn('onSelfInfoUpdated', data); 281 | }); 282 | 283 | OpenIMEmitter.addListener('onConversationChanged', (res) => { 284 | console.warn('onConversationChanged', typeof res, res); 285 | }); 286 | 287 | return ( 288 | 289 |