- Android
- iOS
- JavaScript
- Flutter
- ReactNative
- HarmonyOS
Connection callbacks let the developer server participate in login authorization when a client starts a connection. Before the connection is established, the IM server calls back to the developer server. The connection is allowed when the developer server returns pass; otherwise, it is rejected. Custom Header values are supported for validation.
Default SDK Header values:
Basic information:
x-appkey,x-token,x-platform,x-version,x-device,x-device_id
Authentication and encryption:
x-nonce,x-timestamp,x-signature
After init and before connect.
Parameters
| Parameter | Type | Required | Description | Minimum version |
|---|---|---|---|---|
| signKey | String | Yes | Dynamically issued signing key. | 1.8.47 |
| headers | Map<String, String> | Yes | Custom headers. | 1.8.47 |
Example
String signKey = "xxxxxxxx";
Map<String, String> m = new HashMap<>();
m.put("key1", "value1");
m.put("key2", "value2");
JIM.getInstance().getConnectionManager().setConnectParams(signKey, m);
// call connect to establish a connection
Connection callbacks let the developer server participate in login authorization when a client starts a connection. Before the connection is established, the IM server calls back to the developer server. The connection is allowed when the developer server returns pass; otherwise, it is rejected. Custom Header values are supported for validation.
Default Header Values Included by the SDK:
Basic information:
x-appkey,x-token,x-platform,x-version,x-device,x-device_id
Authentication and encryption:
x-nonce,x-timestamp,x-signature
After init and before connect.
Parameters
| Parameter | Type | Required | Description | Minimum Version |
|---|---|---|---|---|
| signKey | NSString | Yes | Dynamically issued signing key | 1.8.47 |
| headers | NSDictionary <NSString , NSString > * | Yes | Custom header | 1.8.47 |
Code Example
NSString *signKey = @"xxxxxxx";
NSDictionary *dic = @{@"key1": @"value1", @"key2" : @"value2"};
[JIM.shared.connectionManager setConnectParams:signKey headers:dic];
// call connect to establish a connection
Connection callbacks let the developer server participate in login authorization when a client starts a WebSocket connection. Before the connection is established, the IM server calls back to the developer server. The connection is allowed when the developer server returns pass; otherwise, it is rejected. Custom Header values are supported for validation.
Default Header Values Included by the SDK:
Basic information:
x-appkey,x-token,x-platform,x-version,x-device,x-device_id
Authentication and encryption:
x-nonce,x-timestamp,x-signature
After init and before connect.
Parameters
| Parameter | Type | Required | Description | Minimum Version |
|---|---|---|---|---|
| signKey | String | Yes | Dynamically issued signing key. | 1.9.12 |
| headers | Object | Yes | Custom headers. | 1.9.12 |
Callback
| Property | Type | Description | Version |
|---|---|---|---|
| error | Object | Connection result. | 1.0.0 |
| error.code | Number | Connection-result status code. See connection status codes for details. | 1.9.12 |
| error.msg | String | Connection-result description. See connection status codes for details. | 1.9.12 |
Code Example
let { ErrorType } = JIM;
let jim = JIM.init({ appkey: 'Your AppKey' });
let signKey = 'xxxxx';
let headers = {
customKey: 'customValue'
};
jim.setConnectParams(signKey, headers);
// call connect to establish a connection
Not supported.
Not supported.
Not supported.