コード例 #1
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);
          }
        });
  }
コード例 #2
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);
          }
        });
  }
コード例 #3
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);
          }
        });
  }