Class PushClient


  • public class PushClient
    extends java.lang.Object
    Entrance for sending Push. For the following parameters, you can set them by instance creation. This action will override setting in PushPayload Optional. * apnsProduction If not present, the default is true. * timeToLive If not present, the default is 86400(s) (one day). Can be used directly.
    • Constructor Summary

      Constructors 
      Constructor Description
      PushClient​(java.lang.String masterSecret, java.lang.String appKey)
      Create a Push Client.
      PushClient​(java.lang.String masterSecret, java.lang.String appKey, boolean apnsProduction, long timeToLive)
      Deprecated.
      PushClient​(java.lang.String masterSecret, java.lang.String appKey, int maxRetryTimes)
      Deprecated.
      PushClient​(java.lang.String masterSecret, java.lang.String appKey, int maxRetryTimes, cn.jiguang.common.connection.HttpProxy proxy)
      Deprecated.
      PushClient​(java.lang.String masterSecret, java.lang.String appKey, cn.jiguang.common.connection.HttpProxy proxy, cn.jiguang.common.ClientConfig conf)  
    • Constructor Detail

      • PushClient

        public PushClient​(java.lang.String masterSecret,
                          java.lang.String appKey)
        Create a Push Client.
        Parameters:
        masterSecret - API access secret of the appKey.
        appKey - The KEY of one application on JPush.
      • PushClient

        @Deprecated
        public PushClient​(java.lang.String masterSecret,
                          java.lang.String appKey,
                          int maxRetryTimes)
        Deprecated.
        This will be removed in the future. Please use ClientConfig{jiguang-common cn.jiguang.common.ClientConfig} instead of this constructor.
        Parameters:
        masterSecret - API access secret of the appKey.
        appKey - The KEY of one application on JPush.
        maxRetryTimes - The max retry times.
      • PushClient

        @Deprecated
        public PushClient​(java.lang.String masterSecret,
                          java.lang.String appKey,
                          int maxRetryTimes,
                          cn.jiguang.common.connection.HttpProxy proxy)
        Deprecated.
        Create a Push Client with max retry times. This will be removed in the future. Please use ClientConfig{jiguang-common cn.jiguang.common.ClientConfig} instead of this constructor.
        Parameters:
        masterSecret - API access secret of the appKey.
        appKey - The KEY of one application on JPush.
        maxRetryTimes - max retry times
        proxy - The max retry times.
      • PushClient

        public PushClient​(java.lang.String masterSecret,
                          java.lang.String appKey,
                          cn.jiguang.common.connection.HttpProxy proxy,
                          cn.jiguang.common.ClientConfig conf)
      • PushClient

        @Deprecated
        public PushClient​(java.lang.String masterSecret,
                          java.lang.String appKey,
                          boolean apnsProduction,
                          long timeToLive)
        Deprecated.
        Create a Push Client with global settings. If you want different settings from default globally, this constructor is what you needed. This will be removed in the future. Please use ClientConfig{jiguang-common cn.jiguang.common.ClientConfig} instead of this constructor.
        Parameters:
        masterSecret - API access secret of the appKey.
        appKey - The KEY of one application on JPush.
        apnsProduction - Global APNs environment setting. It will override PushPayload Options.
        timeToLive - Global time_to_live setting. It will override PushPayload Options.
    • Method Detail

      • setDefaults

        @Deprecated
        public void setDefaults​(boolean apnsProduction,
                                long timeToLive)
        Deprecated.
        This will be removed in the future. Please use ClientConfig{jiguang-common cn.jiguang.common.ClientConfig#setGlobalPushSetting} instead of this method.
        Parameters:
        apnsProduction - Global APNs environment setting. It will override PushPayload Options.
        timeToLive - Global time_to_live setting. It will override PushPayload Options.
      • setBaseUrl

        public void setBaseUrl​(java.lang.String baseUrl)
      • sendPush

        public PushResult sendPush​(PushPayload pushPayload)
                            throws cn.jiguang.common.resp.APIConnectionException,
                                   cn.jiguang.common.resp.APIRequestException
        Throws:
        cn.jiguang.common.resp.APIConnectionException
        cn.jiguang.common.resp.APIRequestException
      • sendPushValidate

        public PushResult sendPushValidate​(PushPayload pushPayload)
                                    throws cn.jiguang.common.resp.APIConnectionException,
                                           cn.jiguang.common.resp.APIRequestException
        Throws:
        cn.jiguang.common.resp.APIConnectionException
        cn.jiguang.common.resp.APIRequestException
      • sendPush

        public PushResult sendPush​(java.lang.String payloadString)
                            throws cn.jiguang.common.resp.APIConnectionException,
                                   cn.jiguang.common.resp.APIRequestException
        Throws:
        cn.jiguang.common.resp.APIConnectionException
        cn.jiguang.common.resp.APIRequestException
      • sendPushValidate

        public PushResult sendPushValidate​(java.lang.String payloadString)
                                    throws cn.jiguang.common.resp.APIConnectionException,
                                           cn.jiguang.common.resp.APIRequestException
        Throws:
        cn.jiguang.common.resp.APIConnectionException
        cn.jiguang.common.resp.APIRequestException
      • getCidList

        public CIDResult getCidList​(int count,
                                    java.lang.String type)
                             throws cn.jiguang.common.resp.APIConnectionException,
                                    cn.jiguang.common.resp.APIRequestException
        Get cid list, the data form of cid is appKey-uuid.
        Parameters:
        count - the count of cid list, from 1 to 1000. default is 1.
        type - default is "push", option: "schedule"
        Returns:
        CIDResult, an array of cid
        Throws:
        cn.jiguang.common.resp.APIConnectionException - connect exception
        cn.jiguang.common.resp.APIRequestException - request exception
      • setHttpClient

        public void setHttpClient​(cn.jiguang.common.connection.IHttpClient client)
      • close

        public void close()