public static String SendNotification(String regId, String email) { Sender s = new Sender(Constants.Project_key); Message m = new Message.Builder() .collapseKey("Update reminders") .timeToLive(2419200) .delayWhileIdle(true) .dryRun(false) .addData("Email", email) .build(); Result r = s.sendNoRetry(m, regId); String errorcode = r.getErrorCodeName(); return errorcode; }
public ActionResult SendReminders(String User) { GenericIdentity idd = (GenericIdentity)System.Web.HttpContext.Current.User.Identity; String name = idd.Name; String reg_id = PictogramsDb.getRegisteredId(User, name); if (reg_id == String.Empty) return new HttpStatusCodeResult(HttpStatusCode.BadRequest, "User is not registered in GCM"); int id = PictogramsDb.getContactId(User, name); IEnumerable<Reminder> list = PictogramsDb.getAllReminders(id, name); if (!list.Any()) return new HttpStatusCodeResult(HttpStatusCode.MethodNotAllowed); Sender s = new Sender(Constants.Project_key); Message m = new Message.Builder() .collapseKey("Update reminders") .timeToLive(2419200) .delayWhileIdle(true) .dryRun(false) .addData("Email", name) .build(); Result r = s.sendNoRetry(m, reg_id); String errorcode = r.getErrorCodeName(); if (errorcode != null) { if (errorcode == Constants.ERROR_INVALID_REGISTRATION) { //return View("UnregisterUser", (object)User); } else if (errorcode == Constants.ERROR_NOT_REGISTERED) { //return View("RefreshToken", (object)User); } else if (errorcode == Constants.ERROR_MESSAGE_RATE_EXCEEDED) { //return View("Wait", (object)User); } } return new HttpStatusCodeResult(HttpStatusCode.OK); }