[英]How to receive notification in XMPP Group Chat in IOS
抱歉,如果有人问过这个问题。 我已经创建了群聊,可以发送消息,但是当其他人向我发送消息时,我没有收到任何通知。 要获取消息,我要离开并重新加入房间以获取所有消息。
您是否设置了房间的代表来处理接收房间的消息?
尝试设置房间代表:
[#XMPPRoom# addDelegate:]
如果您处于后台模式,那么您一定会收到通知。 但是为此,您必须创建本地通知。 您必须使用以下方法创建本地通知。
- (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];
}
如果在另一个用户向您发送消息时您不在线,那么在此阶段您必须使用PushNotification。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.