简体   繁体   English

Quickblox,聊天室不发送推送通知

[英]Quickblox, chat room does not sends push notification

I created a chat room in Quickblox, when i sends message to chatroom its offline users does not get any push notification. 我在Quickblox中创建了一个聊天室,当我向聊天室发送消息时,其离线用户不会收到任何推送通知。

To send message : 发送消息:

[[QBChat instance] sendMessage:@"Hey! Did you see last Liverpool match?" toRoom:liverpoolFansRoom];

Is there anything that i am doing wrong or its not enabled on Quickbolx server to sends notification on chatroom's offline users. 有什么我做错的事情或Quickbolx服务器上未启用它的功能,无法向聊天室的脱机用户发送通知。

Thanx 感谢名单

Push messages does not sends automatically. 推送消息不会自动发送。 If you know your recipient user's ID you can send push message manually - you should call method provided below: 如果您知道收件人用户的ID,则可以手动发送推送消息-您应调用以下提供的方法:

[QBMessages TSendPushWithText:@"text"
toUsers:(int)userId
delegate:nil];

Swift 3 : 迅捷3

You can send push notifications for all user connected with the dialog using following code: 您可以使用以下代码为与该对话框连接的所有用户发送推送通知:

var payload = [String:String]()
payload["message"] = message.text!
payload["dialog_id"] = self.dialog.id!

do {
    let data = try JSONSerialization.data(withJSONObject: payload, options: .prettyPrinted)
    let message = NSString(data: data, encoding: String.Encoding.utf8.rawValue)

    var opponentIDs: [String] = []
        for userId in self.dialog.occupantIDs! {
            // Discard currently logged in user
            if userId.uintValue != _user.id {
                opponentIDs.append(String(describing: userId))
            }
        }    
        let event = QBMEvent()
        event.message = message
        event.usersIDs = opponentIDs.joined(separator: ",")
        event.notificationType = QBMNotificationType.push
        event.type = QBMEventType.oneShot

        QBRequest.createEvent(event, successBlock: { (response, arrEvents) in
            kprint(items: event.name ?? "")
        }, errorBlock: { (errRes) in
                kprint(items: errRes.error?.description ?? "")
            })    
        } catch {
            print(error.localizedDescription)
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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