XMPP has an attribute called "unread messages" in "XMPPUserCoreDataStorageObject". Pass the "jid" FROM to get the corresponding user object, and add the value "unreadMessages" below in the Appdelegate application.
- (void)xmppStream:(XMPPStream *)sender didReceiveMessage:(XMPPMessage *)message
and update it again in the same db.Like,
XMPPUserCoreDataStorageObject *user = [self.xmppRosterStorage userForJID:[XMPPJID jidWithString:[NSString stringWithFormat:@"%@", [[[message fromStr] componentsSeparatedByString:@"/"]objectAtIndex:0] ]]
xmppStream:self.xmppStream
managedObjectContext:[self managedObjectContext_roster]];
NSNumber *number = user.unreadMessages;
int value = [number intValue];
number = [NSNumber numberWithInt:value + 1];
user.unreadMessages = number;
Then use the code above in any view manager to get an unread number of messages.
source
share