예제 #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 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);
            }
          }
        });
  }
예제 #3
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);
          }
        });
  }
예제 #4
0
 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.");
     }
   }
 }
예제 #5
0
  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);
          }
        });
  }
예제 #6
0
  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);
          }
        });
  }
예제 #7
0
  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);
            }
          }
        });
  }
예제 #8
0
  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);
            }
          }
        });
  }
예제 #9
0
 private void stopDebug() {
   mPush.setDebugModeEnabled(false);
   mResultTextView.setText("stop debug mode.");
 }
예제 #10
0
 private void startDebug() {
   mPush.setDebugModeEnabled(true);
   mResultTextView.setText("start debug mode.");
 }
예제 #11
0
  protected void delTags() {

    List<String> tags = createTags();
    mPush.deleteTags(tags);
  }
예제 #12
0
  protected void setTags() {

    List<String> tags = createTags();
    mPush.setTags(tags);
  }
예제 #13
0
 protected void resume() {
   mPush.resume();
 }
예제 #14
0
 protected void stop() {
   mPush.stop();
 }
예제 #15
0
 protected void start() {
   mPush.start(mAccessToken);
 }