简体   繁体   中英

How to receive notification in XMPP Group Chat in IOS

My Apologies if this question was asked before. I have created group chat i am able to send the messages but I don't receive any notification when other person sends a message to me. To get the message i have leave & rejoin the room to get all messages.

Have you set the room's delegate to take care of the receiving room message?

try to set the room delegate :

[#XMPPRoom# addDelegate:]

This is how you can create a MUC Room; Click Link Here

And this how you invite participants in MUC and send messages to them: Click Link Here

If you are in background mode then you will surely get notification. But for this you have to create Local Notification. You have to create Local Notification in below method.

- (void)xmppStream:(XMPPStream *)sender didReceiveMessage:(XMPPMessage *)message
{
        UILocalNotification *localNotification = [[UILocalNotification alloc] init];
        localNotification.alertAction = @"OK";
        localNotification.fireDate = [NSDate date];
        localNotification.alertBody = xmppmessage;
        localNotification.soundName = UILocalNotificationDefaultSoundName;
        [[UIApplication sharedApplication] presentLocalNotificationNow:localNotification];

}

If you are not online while another user send you message, so at this stage you have to use PushNotification.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM