QuickBlox未向订阅的设备提供GCM通知。我也尝试从管理面板发送通知消息,但它没有发送到设备,但仍然在管理面板中显示为“已发送”。但没有历史。
还有什么可能是这个原因?如何缓解这种情况?
如何查看已发送的GCM通知。
答案 0 :(得分:0)
管理面板不够好 - 它有时会说成功发送'但它永远不会到达另一端。 尝试使用文档中提供的代码段发送GCM通知。它始终有效。
public void sendMessageOnClick() {
// Send Push: create QuickBlox Push Notification Event
QBEvent qbEvent = new QBEvent();
qbEvent.setNotificationType(QBNotificationType.PUSH);
qbEvent.setEnvironment(QBEnvironment.DEVELOPMENT);
// generic push - will be delivered to all platforms (Android, iOS, WP, Blackberry..)
qbEvent.setMessage("how are you doing");
StringifyArrayList<Integer> userIds = new StringifyArrayList<Integer>();
userIds.add(6132691);
qbEvent.setUserIds(userIds);
QBMessages.createEvent(qbEvent, new QBEntityCallbackImpl<QBEvent>() {
@Override
public void onSuccess(QBEvent qbEvent, Bundle bundle) {
}
@Override
public void onError(List<String> strings) {
// errors
}
});
}
//或以下: -
private void sendPushNotifications(){
// recipients
StringifyArrayList<Integer> userIds = new StringifyArrayList<Integer>();
userIds.add(6114793);
//userIds.add(960);
QBEvent event = new QBEvent();
event.setUserIds(userIds);
event.setEnvironment(QBEnvironment.DEVELOPMENT);
event.setNotificationType(QBNotificationType.PUSH);
event.setPushType(QBPushType.GCM);
HashMap<String, String> data = new HashMap<String, String>();
data.put("data.message", "Hello");
data.put("data.type", "welcome message");
event.setMessage(data);
QBMessages.createEvent(event, new QBEntityCallbackImpl<QBEvent>() {
@Override
public void onSuccess(QBEvent qbEvent, Bundle args) {
// sent
}
@Override
public void onError(List<String> errors) {
}
});
}