Follow these steps to send your first message
1、Import the AgoraChat Framework
1).Import ‘AgoraChat’ in your podfile
pod 'AgoraChat'
2).Install dependencies.
pod install
2、 Initialize the Chat SDK
AgoraOptions *options = [AgoraOptions optionsWithAppkey:@"your applyed key"];
// AgoraChat cert keys
[options setApnsCertName:"your certificate"];
[options setEnableConsoleLog:YES];
[options setIsDeleteMessagesWhenExitGroup:NO];
[options setIsDeleteMessagesWhenExitChatRoom:NO];
[options setUsingHttpsOnly:YES];
[[AgoraChatClient sharedClient] initializeSDKWithOptions:options];
3、Login chat server
[[AgoraChatClient sharedClient] loginWithUsername:@"username"
password:@"password"
completion:^(NSString *aUsername, AgoraError *aError) {
[MBProgressHUD hideAllHUDsForView:self.view animated:YES];
if (!aError) {
[[AgoraChatClient sharedClient].options setIsAutoLogin:YES];
[[NSNotificationCenter defaultCenter] postNotificationName:KNOTIFICATION_LOGINCHANGE object:@YES];
} else {
NSString *alertStr = NSLocalizedString(@"login.failure", @"Login failure");
}
}];
4、Construct and send the message
// create a message
Message *message = [[Message alloc] initWithConversationID:receiver
from:sender
to:receiver
body:body
ext:messageExt];
// send message
[[AgoraChatClient sharedClient].chatManager sendMessage:message progress:nil completion:^(Message *message, AgoraError *error) {
}];