I have added below code but now works for me, I when I'm try to get recent chat list then not getting any messages
static loginUserUid = ''
static agoraInit = async(strEmail, strChatToken) => {
arrChatMessages = []
engine = new RtmEngine();
loginUserUid = strEmail
engine.on('error', evt => {
console.log(evt);
});
//4.Received Observer
engine.on('messageReceived', evt => {
let {text, ts, peerId} = evt;
let dictMessage = { user_id: peerId, message: text, msgTimeStamp: ts}
console.log("Message recievied =>", dictMessage);
EventRegister.emit('RECEIVE_NEW_MESSAGE', dictMessage)
});
//1. Create Client
await engine.createClient(APP_ID).catch(e => console.log(e));
//2. Login in agora
await engine.login({uid: loginUserUid, token: strChatToken})
}
static sendMessage = async (dictAgoraPeerMessage) => {
await engine.sendMessageToPeer(dictAgoraPeerMessage).then((data) => {
console.log("Send Message With Response =>",data)
}).catch((err) => {
console.log("Message Error =>",error)
})
}
static endChat = async () => {
await engine.logout().catch(e => console.log(e));
await engine.destroyClient().catch(e => console.log(e));
};
AgoraRtmSendMessageOptions *options = [AgoraRtmSendMessageOptions new];
**[options setEnableHistoricalMessaging:true];**
[options setEnableOfflineMessaging:offline];
AgoraRtmMessage *message = [[AgoraRtmMessage new] initWithText:text];
[[self rtmKit] sendMessage:message toPeer:peerId sendMessageOptions:options completion:^(AgoraRtmSendPeerMessageErrorCode errorCode) {
if (errorCode == AgoraRtmSendPeerMessageErrorOk) {
resolve(nil);
} else {
reject(@(errorCode).stringValue, @"", nil);
}
}];
Please suggest me any solution for this.