Package cn.jpush.api

Examples of cn.jpush.api.JPushClient


 
 
  public static void testSendPush() {
      // HttpProxy proxy = new HttpProxy("localhost", 3128);
      // Can use this https proxy: https://github.com/Exa-Networks/exaproxy
        JPushClient jpushClient = new JPushClient(masterSecret, appKey, 3);
       
        // For push, all you need do is to build PushPayload object.
        PushPayload payload = buildPushObject_all_all_alert();
       
        try {
            PushResult result = jpushClient.sendPush(payload);
            LOG.info("Got result - " + result);
           
        } catch (APIConnectionException e) {
            LOG.error("Connection error. Should retry later. ", e);
           
View Full Code Here


    testSend();
    testGetReport();
  }

  private static void testSend() {
        JPushClient jpushClient = new JPushClient(masterSecret, appKey, 0, DeviceEnum.Android, false);
    CustomMessageParams params = new CustomMessageParams();
    //params.setReceiverType(ReceiverTypeEnum.REGISTRATION_ID);
    //params.setReceiverValue(registrationID);
    params.setReceiverType(ReceiverTypeEnum.TAG);
    params.setReceiverValue(tag);
   
    MessageResult msgResult = jpushClient.sendCustomMessage(msgTitle, msgContent, params, null);
        LOG.debug("responseContent - " + msgResult.responseResult.responseContent);
    if (msgResult.isResultOK()) {
          LOG.info("msgResult - " + msgResult);
          LOG.info("messageId - " + msgResult.getMessageId());
    } else {
View Full Code Here

        }
    }
  }
 
  public static void testGetReport() {
        JPushClient jpushClient = new JPushClient(masterSecret, appKey);
    ReceivedsResult receivedsResult = jpushClient.getReportReceiveds("1708010723,1774452771");
        LOG.debug("responseContent - " + receivedsResult.responseResult.responseContent);
    if (receivedsResult.isResultOK()) {
        LOG.info("Receiveds - " + receivedsResult);
    } else {
            if (receivedsResult.getErrorCode() > 0) {
View Full Code Here

      testSendPush();
  }
 
 
  public static void testSendPush() {
        JPushClient jpushClient = new JPushClient(masterSecret, appKey);
       
        // For push, all you need do is to build PushPayload object.
        PushPayload payload = buildPushObject_all_all_alert();
        LOG.info("Paylaod JSON - " + payload.toString());
       
        PushResult result = jpushClient.sendPush(payload);
        if (result.isResultOK()) {
            LOG.debug(result.toString());
        } else {
            if (result.getErrorCode() > 0) {
                LOG.warn(result.getOriginalContent());
View Full Code Here

    testGetReport();
  }
 
   
  public static void testGetReport() {
        JPushClient jpushClient = new JPushClient(masterSecret, appKey);
    ReceivedsResult receivedsResult = jpushClient.getReportReceiveds("1708010723,1774452771");
        LOG.debug("responseContent - " + receivedsResult.getOriginalContent());
    if (receivedsResult.isResultOK()) {
        LOG.info("Receiveds - " + receivedsResult);
    } else {
            if (receivedsResult.getErrorCode() > 0) {
View Full Code Here

     * Example4: 只发送给android,同时设置离线消息存活时间
     * jpush = new JPushClient(masterSecret, appKey, timeToLive, DeviceEnum.Android);
     */


    jpush = new JPushClient(masterSecret, appKey, timeToLive);

    /*
     * 是否启用ssl安全连接, 可选
     * 参数:启用true, 禁用false,默认为非ssl连接
     */
 
View Full Code Here

  private static final String masterSecret = "57c45646c772983eb0e7c455";//"13ac09b17715bd117163d8a1";//必填
 
 
  public static void main(String[] args) {
    JPushClient JPushClient = new JPushClient(masterSecret, appKey);
   
    String msgId = "1236722141";
   
    String[] msgIds = {"1236722141","910981248","911034889"};
   
    //获取一条
    ReceiveResult receiveResult =  JPushClient.getReceived(msgId);
    if(receiveResult == null){
      System.out.println("获取receive 数据失败!"+receiveResult);
    }else{
      //gson toJson 之后,NULL值的字段会被过滤掉
      System.out.println("received result:"+receiveResult.toString());
    }
 
 
    // 获取多条
    List<ReceiveResult> receiveResults = JPushClient.getReceiveds(msgIds);
    if(receiveResults == null ){
      System.out.println("获取receive 数据失败!");
    }else{
      System.out.println("成功获取了:"+receiveResults);
    }
View Full Code Here

     * Example4: 只发送给android,同时设置离线消息存活时间
     * jpush = new JPushClient(masterSecret, appKey, timeToLive, DeviceEnum.Android);
     */


    jpush = new JPushClient(masterSecret, appKey, timeToLive);

    /*
     * 是否启用ssl安全连接, 可选
     * 参数:启用true, 禁用false,默认为非ssl连接
     */
 
View Full Code Here

TOP

Related Classes of cn.jpush.api.JPushClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.