You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+67-14Lines changed: 67 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,26 +1,28 @@
1
1
# React Native Client SDK for OpenIM 👨💻💬
2
2
3
-
> **📢 Important Notice:** Starting from version 3.8.3-patch.10, the package name has been changed from `open-im-sdk-rn` to `@openim/rn-client-sdk`. Please update your dependency installation and import statements.
4
-
5
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.
6
4
7
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).
8
6
9
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).
10
8
11
-
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.
9
+
The React Native Client SDK uses the [NativeModule](https://reactnative.dev/docs/native-modules-intro) system to expose instances of Java/Objective-C classes to JavaScript (JS) as JS objects, thereby allowing you to execute arbitrary native code from within JS.
12
10
13
11
## Tips 🔔
14
12
15
-
1. The [email protected] has contains ***significant disruptive updates***. If you need to upgrade, please check the incoming data and the returned data. **Note: Package name has been changed to `@openim/rn-client-sdk` starting from version 3.8.3-patch.10.**
13
+
1. Starting from `v3.8.3-patch.10`, the package name has been changed from `open-im-sdk-rn` to `@openim/rn-client-sdk`.
14
+
15
+
2.**operationID Parameter:** This parameter is used for backend log querying. Starting from `v3.8.3-patch.10.2`, the `operationID` parameter is optional for all APIs (the SDK will auto-generate one if not provided). For earlier versions, this parameter is required and must be passed explicitly.
16
+
17
+
3.**Event Binding API:** Starting from `v3.8.3-patch.10.2`, you can use `OpenIMSDK.on()` to listen for events with better TypeScript type hints. Earlier versions must use the `OpenIMEmitter` object. Both approaches remain compatible with the latest version.
16
18
17
-
2. Unlike other SDKS, React Native SDK operationID is not optional, but required.
19
+
4. The `v3.5.1` contains ***significant disruptive updates***. If you need to upgrade, please check the incoming data and the returned data.
18
20
19
21
## Documentation 📚
20
22
21
-
Visit [https://doc.rentsoft.cn](https://doc.rentsoft.cn) for detailed documentation and guides.
23
+
Visit [https://docs.openim.io](https://docs.openim.io) for detailed documentation and guides.
22
24
23
-
For the SDK reference, see [https://doc.rentsoft.cn/sdks/quickstart/reactnative](https://doc.rentsoft.cn/sdks/quickstart/reactnative).
25
+
For the SDK reference, see [https://docs.openim.io/sdks/quickstart/reactNative](https://docs.openim.io/sdks/quickstart/reactNative).
24
26
25
27
## Installation 💻
26
28
@@ -37,23 +39,47 @@ The following examples demonstrate how to use the SDK. TypeScript is used, provi
37
39
### Importing the SDK and init
38
40
39
41
```typescript
40
-
importOpenIMSDKRNfrom'@openim/rn-client-sdk';
42
+
importOpenIMSDKfrom'@openim/rn-client-sdk';
41
43
importRNFSfrom'react-native-fs';
42
44
43
45
RNFS.mkdir(RNFS.DocumentDirectoryPath+'/tmp');
44
46
45
-
OpenIMSDKRN.initSDK({
47
+
OpenIMSDK.initSDK({
46
48
platformID: 2, // 1: ios, 2: android
47
49
apiAddr: 'http://your-server-ip:10002',
48
50
wsAddr: 'ws://your-server-ip:10001',
49
51
dataDir: RNFS.DocumentDirectoryPath+'/tmp',
52
+
logFilePath: RNFS.DocumentDirectoryPath+'/tmp',
50
53
logLevel: 5,
51
54
isLogStandardOutput: true,
52
-
}, 'opid');
55
+
});
53
56
```
54
57
55
58
### Logging In and Listening for Connection Status
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.
104
+
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://docs.openim.io/restapi/apis/usermanagement/userregister) for details.
79
105
80
106
### Receiving and Sending Messages 💬
81
107
82
108
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.
> **Note for iOS:** When running the iOS example project, you may encounter dependency installation errors or build failures. Please refer to [iOS Example Project Running Notes](./docs/IOS-EXAMPLE-WARN.md) for detailed solutions.
0 commit comments