Skip to main content

Prerequisites​

  1. Create an application in the Admin Console to obtain an AppKey and Secret.

  1. Call the server API to obtain tokens, or in the Admin Console select Application > Developer Tools > API > Users, then call the user-registration API to obtain two test tokens.

  1. Complete the integration by following the documentation.

Workflow​

Example​

[JIM.shared setServerUrls:@[@"wss://ws.im.com"]];// "wss://ws.im.com" replace with the deployed server URL
[JIM.shared initWithAppKey:@"appkey"];
[JIM.shared.connectionManager connectWithToken:@"token1"];
[JIM.shared.connectionManager addDelegate:self];
- (void)connectionStatusDidChange:(JConnectionStatus)status errorCode:(JErrorCode)code extra:(NSString *)extra {
if (JConnectionStatusConnected == status) {
// Text message
JConversation *conversation = [[JConversation alloc] initWithConversationType:JConversationTypePrivate conversationId:@"userid2"];
JTextMessage *text = [[JTextMessage alloc] initWithContent:@"test text message"];
JMessage *m = [JIM.shared.messageManager sendMessage:text
inConversation:conversation
success:^(JMessage *message) {
NSLog(@"sendMessage success");
} error:^(JErrorCode errorCode, JMessage *message) {
NSLog(@"sendMessage error");
}];
NSLog(@"after send, m.clientMsgNo is %lld", m.clientMsgNo);
}
}