コード例 #1
0
  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);
            }
          }
        });
  }
コード例 #2
0
  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);
          }
        });
  }
コード例 #3
0
  protected void messageToPeerWithTrigger() {

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

    msg.setMessage(content);

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

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

          @Override
          public void onSuccess(String id) {

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

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

            String fail =
                "Fail to push message:\n"
                    + " content: "
                    + mMessage
                    + "\n"
                    + " errCode: "
                    + errCode
                    + " errMsg: "
                    + errMsg
                    + "\n";
            mResultTextView.setText(fail);
          }
        });
  }