2013-07-31 110 views
1

我在Quickblox中創建了一個聊天室,當我向聊天室發送消息時,其離線用戶不會收到任何推送通知。Quickblox,聊天室不發送推送通知

要發送消息:

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

有什麼,我做錯了或者其Quickbolx服務器上未啓用將在聊天室的脫機用戶通知。

謝謝

回答

2

推送消息不會自動發送。如果你知道你的目標用戶的ID,您可以手動發送推送消息 - 你應該調用方法提供如下:

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

對於羣組聊天,我是否需要發送推送給所有用戶的天氣,他們在線或離線。 –

0

斯威夫特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) 
     }