Exemple #1
0
  @Override
  @Action(value = "iospush")
  public String execute() {

    logger.info(
        "[IOSPUSH] push request: user: "******" , alert: "
            + alert
            + " , language: "
            + language
            + " , badge: "
            + badge
            + ", body: \n"
            + body);

    try {
      if (language.equals("zh_CN")) {
        keystore = "pushkey_cn.p12";
        keystore_dev = "pushkey_cn_dev.p12";
        logger.info("[IOSPUSH] use pushkey_cn.p12 ");
      } else if (language.equals("en_US")) {
        keystore = "pushkey_en.p12";
        keystore_dev = "pushkey_en_dev.p12";
        logger.info("[IOSPUSH] use pushkey_en.p12 ");
      } else {
        keystore = "pushkey.p12";
        keystore_dev = "pushkey_dev.p12";
        logger.info("[IOSPUSH] use pushkey.p12 ");
      }

      PushNotificationPayload sendDate = new PushNotificationPayload();
      sendDate.addAlert(alert);
      sendDate.addBadge(Integer.parseInt(badge));
      sendDate.addCustomDictionary("acb", body);

      // NOTE: just test for dev!!! some day, it will be removed.
      pushAlert_test(sendDate, keystore_dev, password, uid);

      pushAlert(sendDate, keystore, password, uid);

    } catch (JSONException e) {
      e.printStackTrace();
      message = "iospush failed!";
    } catch (Exception e) {
      e.printStackTrace();
      message = "iospush failed!";
    }
    logger.info("[IOSPUSH] push response: user: "******", message: " + message);
    return SUCCESS;
  }
 public void post() {
   TradingRecordVO trv = new TradingRecordVO();
   trv.setPost(1); // 查询没有发送过的新销售记录
   trv.setDate(null);
   List<TradingRecord> trList = tradingRecordService.findAll(trv);
   for (TradingRecord tr : trList) {
     // 更新数据库状态
     tradingRecordService.updatePost(tr);
     try {
       payload.addCustomAlertBody(alertBody(tr));
       payload.addSound("default");
       payload.addBadge(10);
       Push.payload(payload, filePath, "2w3e4r5t", false, tk);
     } catch (Exception e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   }
 }