Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //final String REGISTRATIONS_ID = "APA91bGgs7g-iF1kEfo_Y5v-iU3IZRW5dODsRLL3nx7YrRy-Y46oUreSMDzUV8KEs61lBjA_GlaEwAN6Mr-kfH_N2kdLtsP2OQsLKr4r9mfweVelaM0u7LC_HsMyRce-F2JaO2wtxFAGXZMlD76pHZ9XEywdIdKhUCvjB5ErO-8Y67lGVICiZb8";
- final String REGISTRATIONS_ID = "APA91bH6pvkDTKnkIw6RvKjjJYk5cV3l7tvGOE8Mkiq8sCoGbOMXSVjs8Kyn40dv8zTzovQuDv4Ub-0xhRavTguqOWxyZCm0nk4Nn1wIfL5nP-xq1cT3j-jbHmKgzjE49KP7Cd0lQ3-mIVHhRPGRukOljOQySCITxXYMyROLbYd8mEM_929aG1I";
- // create JSON request
- // reference: https://developer.android.com/google/gcm/http.html#request
- JSONObject jsonRequest = new JSONObject();
- try {
- // JSON Array of registrations ids (patient's devices)
- // we get registration IDs from database
- JSONArray regIds = new JSONArray();
- regIds.put(REGISTRATIONS_ID);
- // JSON message
- JSONObject message = new JSONObject();
- message.put("notification", "1");
- message.put("action", "out_of_bounds");
- // put into JSON request
- jsonRequest.put("registration_ids", regIds);
- jsonRequest.put("data", message);
- } catch (JSONException e) {
- e.printStackTrace();
- }
- System.out.println(jsonRequest.toString());
- System.out.println();
- // Send
- GCMSender gcm = new GCMSender();
- String response = gcm.send(jsonRequest);
- System.out.println(gcm.getStatusCode());
- System.out.println(response);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement