工作中遇到了在PC端使用极光推送,索性写下来为以后做些记录
在我们调用别人接口时,会提到鉴权:
鉴权(authentication)是指验证用户是否拥有访问系统的权利。
看样子应该和我们说的shiro异曲同工了
em,怎么说呢,github还是需要网速的
依赖公司如果架构师配过一次了,那就导入前两个
<!--极光推送-->
<dependency>
<groupId>cn.jpush.api</groupId>
<artifactId>jiguang-common</artifactId>
<version>1.1.11</version>
</dependency>
<dependency>
<groupId>cn.jpush.api</groupId>
<artifactId>jpush-client</artifactId>
<version>3.3.8</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.6.Final</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.7</version>
</dependency>
<!-- For log4j -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.7</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
在你的module下编写PushUtils类,
public class PushUtils {
private static String appKey = "你的appkey";
private static String masterSecret = "你的masterSecret ";
private static final int RESPONSE_OK = 200;
private static long jpushTime = 86400L;
private static final Logger logger = LoggerFactory.getLogger(PushUtils.class);
JPushClient jpushClient = new JPushClient(masterSecret, appKey, null, ClientConfig.getInstance());
/*
*进行推送的关键在于构建一个 PushPayload 对象。以下示例一般的构建对象的用法。
*快捷地构建推送对象:所有平台,所有设备,内容为 1433223 的通知。
*/
public static PushPayload buildPushObject_all_all_alert() {
return PushPayload.alertAll("1433223");
}
}
剩下的在jpush-api-java-client-master/README.md下面找自己需要的推送对象.
十年磨一剑,霜刃未曾试.今日把示君,谁有不平事?