I am using the XMPP Framework for chatting between the users , Chatting is happening perfectly .Now I need to show the message is delivered perfectly to both devices like (What's app messenger). I am not getting any tutorial to follow. Below code represents while we send message to the other user.
//Sending the message to the other user
NSXMLElement *body = [NSXMLElement elementWithName:@"body"];
[body setStringValue:txtChat.text];
NSXMLElement *message = [NSXMLElement elementWithName:@"message"];
[message addAttributeWithName:@"type" stringValue:@"chat"];
[message addAttributeWithName:@"to" stringValue:self.userjid];
[message addChild:body];
[[APPDELEGATE xmppStream] sendElement:message];
While reterving the message by using XMPP Framework i was getting the data by using below code
- (void)loadarchivemsg
{
XMPPMessageArchivingCoreDataStorage *storage = [XMPPMessageArchivingCoreDataStorage sharedInstance];
NSManagedObjectContext *moc = [storage mainThreadManagedObjectContext];
NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@"XMPPMessageArchiving_Message_CoreDataObject"
inManagedObjectContext:moc];
NSFetchRequest *request = [[NSFetchRequest alloc]init];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(bareJidStr like %@) && (streamBareJidStr like %@)", self.userjid,[[NSUserDefaults standardUserDefaults] stringForKey:@"kXMPPmyJID"]];
request.predicate = predicate;
NSLog(@"%@",[[NSUserDefaults standardUserDefaults] stringForKey:@"kXMPPmyJID"]);
[request setEntity:entityDescription];
NSError *error;
NSArray *messages_arc = [moc executeFetchRequest:request error:&error];
[self print:[[NSMutableArray alloc]initWithArray:messages_arc]];
}
- (void)print:(NSMutableArray*)messages_arc{
@autoreleasepool {
for (XMPPMessageArchiving_Message_CoreDataObject *message in messages_arc) {
NSXMLElement *element = [[NSXMLElement alloc] initWithXMLString:message.messageStr error:nil];
XMPPMessage *message12=[[XMPPMessage alloc]init];
message12 = [message message];
}
}
In this why I was sending the message and retrieving the message,can you help me how to retrieve the delivery status of the message . Waiting for your valuable answers.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…