compile 'com.github.mpusher:mpush-client-java:0.0.2'<dependency> <groupId>com.github.mpusher</groupId> <artifactId>mpush-client-java</artifactId> <version>0.0.2</version> </dependency>
参见 com.mpush.client.MPushClientTest.java
public class MPushClientTest { private static final String publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCghPCWCobG8nTD24juwSVataW7iViRxcTkey/B792VZEhuHjQvA3cAJgx2Lv8GnX8NIoShZtoCg3Cx6ecs+VEPD2fBcg2L4JK7xldGpOJ3ONEAyVsLOttXZtNXvyDZRijiErQALMTorcgi79M5uVX9/jMv2Ggb2XAeZhlLD28fHwIDAQAB";//公钥对应服务端的私钥 private static final String allocServer = "http://127.0.0.1:9999/";//用于获取MPUSH server的ip:port, 用于负载均衡 public static void main(String[] args) throws Exception { Client client = ClientConfig .build() .setPublicKey(publicKey) .setAllotServer(allocServer) .setDeviceId("1111111111") .setOsName("Android") .setOsVersion("6.0") .setClientVersion("2.0") .setUserId("doctor43test") .setSessionStorageDir(MPushClientTest.class.getResource("/").getFile()) .setLogger(new DefaultLogger()) .setLogEnabled(true) .setEnableHttpProxy(false) .setClientListener(new L()) .create(); client.start(); LockSupport.park(); }
allocServer的实现参照AllocServer.java