1.极光对接,首先需要注册用户,和创建应用

2,。Java对接需要依赖包

<dependency>
<groupId>cn.jpush.api</groupId>
<artifactId>jpush-client</artifactId>
<version>3.3.8</version>
</dependency> 3,对所有的ios和Android开发者推送
package com.qualityshop.jiguang;

import cn.jpush.api.JPushClient;
import cn.jpush.api.push.PushResult;
import cn.jpush.api.push.model.Message;
import cn.jpush.api.push.model.Platform;
import cn.jpush.api.push.model.PushPayload;
import cn.jpush.api.push.model.audience.Audience;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; /**
* 极光推送
*
* @author huojg
*/
public class Jdpush {
private static final Logger logger = LoggerFactory.getLogger(Jdpush.class);
public static final String APPKEY = "*******";
public static final String MASTERSECRET = "******";
public static JPushClient jpushClient = null; public static void sendPush(String title,String msg) {
JPushClient jpushClient = new JPushClient(MASTERSECRET, APPKEY);
PushPayload payload = buildPushObjectByMessage(title,msg);
try {
PushResult result = jpushClient.sendPush(payload);
} catch (Exception e) {
e.printStackTrace();
}
} public static PushPayload buildPushObjectByMessage(String title,String msg) {
return PushPayload.newBuilder().setPlatform(Platform.all())// 设置接受的平台
.setAudience(Audience.all())// Audience设置为all,说明采用广播方式推送,所有用户都可以接收到
.setMessage(Message.newBuilder()
.setTitle(title)
.setMsgContent(msg)
.build())
.build();
}
}

4就会在app开发者收到信息。

05-08 15:35