@Override public void executeAsync() { QBEvent event = buildEvent(); QBEvent createdEvent = null; try { createdEvent = QBPushNotifications.createEvent(event); } catch (QBResponseException e) { setException(e); } if (createdEvent != null) { Log.i(TAG, ">>> Event: " + createdEvent.toString()); } }
@Override public void executeAsync() { QBEvent event = new QBEvent(); event.setId(1454326); event.setActive(true); // send it again QBEvent updatedEvent = null; try { updatedEvent = QBPushNotifications.updateEvent(event); } catch (QBResponseException e) { setException(e); } if (updatedEvent != null) { Log.i(TAG, ">>> Event: " + updatedEvent.toString()); } }
@Override public void execute() { QBEvent event = new QBEvent(); event.setId(1470629); event.setActive(true); // send it again QBPushNotifications.updateEvent( event, new QBEntityCallback<QBEvent>() { @Override public void onSuccess(QBEvent qbEvent, Bundle args) { Log.i(TAG, ">>> event: " + qbEvent.toString()); } @Override public void onError(QBResponseException errors) { handleErrors(errors); } }); }
@Override public void executeAsync() { try { event = QBPushNotifications.getEvent(1454324); } catch (QBResponseException e) { setException(e); } if (event != null) { Log.i(TAG, ">>> event: " + event.toString()); } }
protected QBEvent buildEvent() { // recipient StringifyArrayList<Integer> userIds = new StringifyArrayList<>(); userIds.add(ApplicationConfig.getInstance().getTestUserId1()); userIds.add(ApplicationConfig.getInstance().getTestUserId2()); userIds.add(5179218); userIds.add(301); QBEvent event = new QBEvent(); event.setUserIds(userIds); event.setType(QBEventType.ONE_SHOT); event.setEnvironment(QBEnvironment.DEVELOPMENT); event.setNotificationType(QBNotificationType.PUSH); // // generic push - will be delivered to all platforms (Android, iOS, WP, // Blackberry..) // // // event.setMessage("This is simple generic push notification!"); // // 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()); // // Android based push // // // event.setPushType(QBPushType.GCM); // HashMap<String, Object> data = new HashMap<>(); // data.put("data.message", "This is Android based push notification!"); // data.put("data.param1", "value1"); // // // event.setMessage(data); // iOS based push // event.setPushType(QBPushType.APNS); HashMap<String, Object> data = new HashMap<>(); Map<String, String> aps = new HashMap<>(); aps.put("alert", "You have 3 new messages"); aps.put("badge", "3"); data.put("aps", aps); // event.setMessage(data); return event; }