This blog is written to summarize my learning and application of Jiguang Push some time ago! ! !
-------------------------------------------------- ------------------------- I am the dividing line --------------------- -------------------------------------------------- --------------------------
A few days ago, because the project needed to push messages to the Android terminal, I chose Jiguang Push. I have to say that this third-party API is very detailed, so it is very convenient to integrate. That is already done, so I have time to record and summarize. Stop talking nonsense, let's start
First, it is done in two steps. The first part is to become a Jiguang user to create an application and get it ( AppKey , Master Secret ) ; the second part is to get the jar package of the java server or to inject the dependency through maven ; the third part is to integrate Jiguang push message.
first part:
1. Enter the official website of Aurora Aurora official website ;
2. This is the detailed explanation of creating an application provided to developers on the official website to create an application ;
3. After the application is created, you can get an AppKey and Master Secret, this is fine; (mine is that after Android is created, give me AppKey and Master Secret , these two are particularly important, because they need to be used later ) Similar to the picture below
the second part:
1. After entering the official website https://www.jiguang.cn/push , there is a developer service in the navigation bar , and there is a Jiguang push inside . After entering, there is a download of SDK . After entering, there will be a server SDK download, find Download the Java to get the jar package;
2. This is the dependency injection method through maven : this is the official website to add dependencies to the pom file, just follow the step-by-step operation provided, so the official website of Jiguang is too capricious. The steps are super detailed ... ^_^ ) https://docs.jiguang.cn/jpush/server/3rd/java_sdk/ ;
the third part:
1. Download the official source code, https://github.com/jpush/jpush-api-java-client
2. I built a package jpush, and built a class jpush.class under it
3. Write the method you need in the jpush class. I took it directly in the demo to see the type and quantity of the parameters. After all, you are lazy to use other people's things, in fact, I think it depends on personal needs. If some people need to customize, then customize. By the way, if you don’t see the demo clearly, you can look at the API . This provides great convenience for developers https://docs.jiguang.cn/jpush/server /push/rest_api_v3_push/ .
The company has requirements, so you can refer to a piece of code you find:
public class jpu sh { |
|
|
|
|
protected static final String APP_KEY ="d4ee2375846bc30fa51334f5"; |
|
protected static final String MASTER_SECRET = "f3b222f7e0dde430b6d8fa5a"; |
|
|
|
1. JPushClient jpushClient = new JPushClient(masterSecret, appKey); 1. public static PushPayload buildPushObject_all_alias_alert() { 2. return PushPayload.newBuilder() 3. .setPlatform(Platform.all())//设置接受的平台 4. .setAudience(Audience.all())//Audience设置为all,说明采用广播方式推送,所有用户都可以接收到 5. .setNotification(Notification.alert("这是XX推送的消息")) 6. .build(); 7. } |
}
第四部分:自己踩过的坑记录一下
---------------------------------------------------------------暂时想到这些,完------------------------------------------------------------------