我在 Quickblox 中创建了一个聊天室,当我向聊天室发送消息时,它的离线用户没有收到任何推送通知。
发送消息:
[[QBChat instance] sendMessage:@"Hey! Did you see last Liverpool match?" toRoom:liverpoolFansRoom];
有什么我做错了,或者没有在 Quickbolx 服务器上启用以向聊天室的离线用户发送通知。
谢谢
推送消息不会自动发送。如果您知道收件人用户的 ID,您可以手动发送推送消息 - 您应该调用下面提供的方法:
[QBMessages TSendPushWithText:@"text"
toUsers:(int)userId
delegate:nil];
斯威夫特 3:
您可以使用以下代码为与对话框连接的所有用户发送推送通知:
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)
}