Reputation: 155
QBEvent is class that Quickblox provides to support push notification.
On Android platform, I must set qbEvent.setPushType(QBPushType.GCM)
to push message between multiple Android devices.
The problem is I want to push message for both Android and iOS, but I can set those lines together. qbEvent.setPushType(QBPushType.GCM)
and qbEvent.setPushType(QBPushType.APNS)
. Any solutions for that, please help?
Upvotes: 1
Views: 628
Reputation: 18346
You don't need to pass a push type param if you want to send a push to all platforms
Solution N1 (only text):
QBEvent event = new QBEvent();
event.setUserIds(userIds);
event.setType(QBEventType.ONE_SHOT);
event.setEnvironment(QBEnvironment.DEVELOPMENT);
event.setNotificationType(QBNotificationType.PUSH);
//
event.setMessage("This is simple generic push notification!");
Solution N2 (with custom parameters):
QBEvent event = new QBEvent();
event.setUserIds(userIds);
event.setType(QBEventType.ONE_SHOT);
event.setEnvironment(QBEnvironment.DEVELOPMENT);
event.setNotificationType(QBNotificationType.PUSH);
//
// generic push with custom parameters - http://quickblox.com/developers/Messages#Use_custom_parameters
JSONObject json = new JSONObject();
try {
json.put("message", "This is generic push notification with custom params!");
json.put("param1", "value1");
json.put("ios_badge", "4"); // iOS badge value
} catch (Exception e) {
e.printStackTrace();
}
event.setMessage(json.toString());
More examples in our push notifications snippets https://github.com/QuickBlox/quickblox-android-sdk/blob/master/snippets/src/main/java/com/sdk/snippets/modules/SnippetsPushNotifications.java#L217
and in documentation http://quickblox.com/developers/SimpleSample-messages_users-android#Universal_push_notifications
Upvotes: 4