Examples of PushNotificationMessage


Examples of org.luke.ct.model.PushNotificationMessage

      throw new Error("提供的訊息內容物件格式不正確");

    JSONObject rowdata = json.getJSONObject("rowdata");

    // 正確的儲存push notification
    PushNotificationMessage pnm = new PushNotificationMessage();
    pnm.setAddTime(CTCommon.getNowTime());
    pnm.setTitle(title);
    pnm.setMessage(message);
    if (null != rowdata)
      pnm.setRowdata(rowdata.toJSONString());
    pnm_service.add(pnm);

    retJson = new JSONObject();
    retJson.put("messageID", pnm.getEncodedKey());
    for (CarPhoneRelation o : cpr_list) {
      CarPhonePushNotification cppn = new CarPhonePushNotification();
      cppn.setAddTime(CTCommon.getNowTime());
      cppn.setCarID(carID);
      cppn.setPhoneID(o.getPhoneID());
      cppn.setIsSend(false);
      cppn.setMessageID(pnm.getEncodedKey());
      cppn_service.add(cppn);

      JSONArray phoneArray = retJson.getJSONArray("phoneArray");
      if (null == phoneArray)
        phoneArray = new JSONArray();
View Full Code Here

Examples of org.luke.ct.model.PushNotificationMessage

      throw new Error("提供的訊息內容物件格式不正確");

    JSONObject rowdata = json.getJSONObject("rowdata");

    // 正確的儲存push notification
    PushNotificationMessage pnm = new PushNotificationMessage();
    pnm.setAddTime(CTCommon.getNowTime());
    pnm.setTitle(title);
    pnm.setMessage(message);
    if (null != rowdata)
      pnm.setRowdata(rowdata.toJSONString());
    pnm_service.add(pnm);

    retJson = new JSONObject();
    retJson.put("messageID", pnm.getEncodedKey());
    for (CarPhoneRelation o : cpr_list) {
      if (o.getCarID().equals(carID)) {
        PhoneCarPushNotification pcpn = new PhoneCarPushNotification();
        pcpn.setAddTime(CTCommon.getNowTime());
        pcpn.setCarID(carID);
        pcpn.setPhoneID(phoneID);
        pcpn.setIsSend(false);
        pcpn.setMessageID(pnm.getEncodedKey());
        pcpn_service.add(pcpn);

        JSONArray carArray = retJson.getJSONArray("carArray");
        if (null == carArray)
          carArray = new JSONArray();
View Full Code Here

Examples of org.luke.ct.model.PushNotificationMessage

    List<PhoneCarPushNotification> pcpn_list = pcpn_service.getPaginationData(filter).getResultList();

    if (null == pcpn_list || pcpn_list.size() == 0)
      throw new Error("該messageID無法與phoneID對應");

    PushNotificationMessage pnm = pnm_service.getDataByID(messageID);
    if (null == pnm)
      throw new Error("該messageID不合法");

    // 產生carRegIDList
    List<String> devices = new ArrayList<String>();
    for (PhoneCarPushNotification o : pcpn_list) {
      // 判斷是否傳送過
      if (!o.getIsSend()) {
        CarReg cr = cr_service.getDataByID(o.getCarID());
        devices.add(cr.getRegisterID());
        o.setIsSend(true);
        o.setSendTime(CTCommon.getNowTime());
        pcpn_service.modify(o);
      }
    }

    if (devices.size() == 0) {
      throw new Error("該phoneID的所有的message都已傳送過");
    }

    // 取得message的內容
    String title = pnm.getTitle();
    String message = pnm.getMessage();
    String rowdata = pnm.getRowdata();
    Map<String, String> extraMap = new HashMap<String, String>();
    extraMap.put("rowdata", rowdata);

    // Create a GCM sender
    MulticastResult result = sendMessageToDevice(CTCommon.API_KEY, devices, title, message, extraMap);
View Full Code Here

Examples of org.luke.ct.model.PushNotificationMessage

    String filter = String.format("carID=='%s' && messageID=='%s'", carID, messageID);
    List<CarPhonePushNotification> cppn_list = cppn_service.getPaginationData(filter).getResultList();
    if (null == cppn_list || cppn_list.size() == 0)
      throw new Error("該messageID無法與carID對應");

    PushNotificationMessage pnm = pnm_service.getDataByID(messageID);
    if (null == pnm)
      throw new Error("該messageID不合法");

    // 產生phoneRegIDList
    List<String> devices = new ArrayList<String>();
    for (CarPhonePushNotification o : cppn_list) {
      // 判斷是否傳送過
      if (!o.getIsSend()) {
        PhoneReg pr = pr_service.getDataByID(o.getPhoneID());
        devices.add(pr.getRegisterID());
        o.setIsSend(true);
        o.setSendTime(CTCommon.getNowTime());
        cppn_service.modify(o);
      }
    }

    if (devices.size() == 0) {
      throw new Error("該carID的所有的message都已傳送過");
    }

    // 取得message的內容
    String title = pnm.getTitle();
    String message = pnm.getMessage();
    String rowdata = pnm.getRowdata();
    Map<String, String> extraMap = new HashMap<String, String>();
    extraMap.put("rowdata", rowdata);

    // Create a GCM sender
    MulticastResult result = sendMessageToDevice(CTCommon.API_KEY, devices, title, message, extraMap);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.