protected void update() {

    FrontiaPushUtil.MessageContent msg =
        new FrontiaPushUtil.MessageContent(mMessageId, FrontiaPushUtil.DeployStatus.PRODUCTION);

    msg.setMessage(mUpdateMessage);

    Trigger trigger = new Trigger();
    trigger.setCrontab("*/10 * * * *");

    // 该例子要替换的mId依赖于推送延时消息给个人的message id.请先推送延时消息给个人,才能获取到该mId,当然你也可以把该id替换成别的message id
    mPush.replaceMessage(
        mId,
        mUserId,
        mChannelId,
        trigger,
        msg,
        new CommonMessageListener() {

          @Override
          public void onSuccess() {
            if (null != mResultTextView) {
              mResultTextView.setText("update message success.");
            }
          }

          @Override
          public void onFailure(int errCode, String errMsg) {
            if (null != mResultTextView) {
              mResultTextView.setText(
                  "Fail to update message:\nerrCode:" + errCode + ", errMsg:" + errMsg);
            }
          }
        });
  }
  protected void Describe() {
    mPush.describeMessage(
        mId,
        new DescribeMessageListener() {

          @Override
          public void onSuccess(DescribeMessageResult result) {
            String id = result.getId();
            String userId = result.getUserId();
            String channelId = result.getChannelId();
            MessageContent messageContent = result.getMessage();
            String tag = result.getTag();
            Trigger trigger = result.getTrigger();
            JSONObject extras = result.getExtras();

            if (null != mResultTextView) {
              mResultTextView.setText(
                  "id:" + id + ", userId:" + userId + ", channelId:" + channelId);
            }
          }

          @Override
          public void onFailure(int errCode, String errMsg) {
            if (null != mResultTextView) {
              mResultTextView.setText("errCode:" + errCode + ", errMsg:" + errMsg);
            }
          }
        });
  }
  protected void notificationToPeerWithTrigger() {
    final String content = "发送延时通知给个人";
    NotificationContent notification = new NotificationContent(mTitle, content);

    FrontiaPushUtil.MessageContent msg =
        new FrontiaPushUtil.MessageContent(mMessageId, FrontiaPushUtil.DeployStatus.PRODUCTION);

    msg.setNotification(notification);

    Trigger trigger = new Trigger();
    trigger.setCrontab("*/2 * * * *");

    mPush.pushMessage(
        mUserId,
        null,
        trigger,
        msg,
        new PushMessageListener() {

          @Override
          public void onSuccess(String id) {
            mId = id;
            String msg =
                "push notification:\n"
                    + "    id: "
                    + id
                    + "\n"
                    + "    title: "
                    + mTitle
                    + "\n"
                    + "    content: "
                    + content
                    + "\n";
            mResultTextView.setText(msg);
          }

          @Override
          public void onFailure(int errCode, String errMsg) {

            String fail =
                "Fail to push notification:\n"
                    + " title: "
                    + mTitle
                    + "\n"
                    + " content: "
                    + mMessage
                    + "\n"
                    + " errCode: "
                    + errCode
                    + " errMsg: "
                    + errMsg
                    + "\n";
            mResultTextView.setText(fail);
          }
        });
  }
 protected void isPush() {
   boolean result = mPush.isPushWorking();
   Log.d(TAG, "push is running?" + result);
   if (null != mResultTextView) {
     if (result) {
       mResultTextView.setText("Push is working.");
     } else {
       mResultTextView.setText("Push is not working.");
     }
   }
 }
  protected void notificationToGroup() {
    final String content = "发送通知给群组";
    NotificationContent notification = new NotificationContent(mTitle, content);

    FrontiaPushUtil.MessageContent msg =
        new FrontiaPushUtil.MessageContent(mMessageId, FrontiaPushUtil.DeployStatus.PRODUCTION);

    msg.setNotification(notification);

    mPush.pushMessage(
        mTag,
        msg,
        new PushMessageListener() {

          @Override
          public void onSuccess(String id) {

            String msg =
                "push notification:\n"
                    + "    id: "
                    + id
                    + "\n"
                    + "    title: "
                    + mTitle
                    + "\n"
                    + "    content: "
                    + content
                    + "\n";
            mResultTextView.setText(msg);
          }

          @Override
          public void onFailure(int errCode, String errMsg) {

            String fail =
                "Fail to push notification:\n"
                    + " title: "
                    + mTitle
                    + "\n"
                    + " content: "
                    + mMessage
                    + "\n"
                    + " errCode: "
                    + errCode
                    + " errMsg: "
                    + errMsg
                    + "\n";
            mResultTextView.setText(fail);
          }
        });
  }
  protected void messageToPeer() {

    final String content = "发送消息给个人";
    FrontiaPushUtil.MessageContent msg =
        new FrontiaPushUtil.MessageContent(mMessageId, FrontiaPushUtil.DeployStatus.PRODUCTION);

    msg.setMessage(content);

    mPush.pushMessage(
        mUserId,
        mChannelId,
        msg,
        new PushMessageListener() {

          @Override
          public void onSuccess(String id) {

            String msg =
                "push message to peer:\n"
                    + "    id: "
                    + id
                    + "\n"
                    + "    content: "
                    + content
                    + "\n";
            mResultTextView.setText(msg);
          }

          @Override
          public void onFailure(int errCode, String errMsg) {

            String fail =
                "Fail to push message to peer:\n"
                    + " content: "
                    + mMessage
                    + "\n"
                    + " errCode: "
                    + errCode
                    + " errMsg: "
                    + errMsg
                    + "\n";
            mResultTextView.setText(fail);
          }
        });
  }
  protected void list() {
    FrontiaQuery query = new FrontiaQuery();

    mPush.listMessage(
        query,
        new ListMessageListener() {

          @Override
          public void onSuccess(List<DescribeMessageResult> results) {
            String resultShow = "";
            for (DescribeMessageResult result : results) {
              String id = result.getId();
              String userId = result.getUserId();
              String channelId = result.getChannelId();
              MessageContent messageContent = result.getMessage();
              String tag = result.getTag();
              Trigger trigger = result.getTrigger();
              JSONObject extras = result.getExtras();
              resultShow =
                  resultShow
                      + "id:"
                      + id
                      + ", userId:"
                      + userId
                      + ", channelId:"
                      + channelId
                      + "\n";
            }

            if (null != mResultTextView) {
              mResultTextView.setText(resultShow);
            }
          }

          @Override
          public void onFailure(int errCode, String errMsg) {
            if (null != mResultTextView) {
              mResultTextView.setText("errCode:" + errCode + ", errMsg:" + errMsg);
            }
          }
        });
  }
  protected void delete() {
    mPush.removeMessage(
        mId,
        new CommonMessageListener() {

          @Override
          public void onSuccess() {
            if (null != mResultTextView) {
              mResultTextView.setText("remove message success.");
            }
          }

          @Override
          public void onFailure(int errCode, String errMsg) {
            if (null != mResultTextView) {
              mResultTextView.setText("errCode:" + errCode + ", errMsg:" + errMsg);
            }
          }
        });
  }
 private void stopDebug() {
   mPush.setDebugModeEnabled(false);
   mResultTextView.setText("stop debug mode.");
 }
 private void startDebug() {
   mPush.setDebugModeEnabled(true);
   mResultTextView.setText("start debug mode.");
 }
  protected void delTags() {

    List<String> tags = createTags();
    mPush.deleteTags(tags);
  }
  protected void setTags() {

    List<String> tags = createTags();
    mPush.setTags(tags);
  }
 protected void resume() {
   mPush.resume();
 }
 protected void stop() {
   mPush.stop();
 }
 protected void start() {
   mPush.start(mAccessToken);
 }