jeudi 13 août 2015

Getting XMPP client chat history between two users

I have created a XMPP Swift Messenger with the eJabbered, but it doesn't save the history.

I searched a lot and could found just answers written in ObjC, in Stack.

For instance:

- (void)loadChatHistoryWithUserName:(NSString *)userName {
    NSString *userJid = [NSString stringWithFormat:@"%@@%@",userName,self.hostName];
    NSManagedObjectContext *moc = [_xmppMsgStorage mainThreadManagedObjectContext];
    NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@"XMPPMessageArchiving_Message_CoreDataObject"
                                                     inManagedObjectContext:moc];
    NSFetchRequest *request = [[NSFetchRequest alloc]init];
[request setEntity:entityDescription];
    NSError *error;
    NSString *predicateFrmt = @"bareJidStr == %@";
    NSPredicate *predicate = [NSPredicate predicateWithFormat:predicateFrmt, userJid];
request.predicate = predicate;
    NSArray *messages = [moc executeFetchRequest:request error:&error];
}

But I use XMPP Swift Framework with the XMPP ObjC Framework inside. Look at this Git: GitHub

How can I use those snippet in Swift for getting chat history?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire