Commit e00ffa1d authored by 张大伟's avatar 张大伟

增加个推推送服务

parent dec6dc50
This diff is collapsed.
...@@ -255,6 +255,43 @@ ...@@ -255,6 +255,43 @@
<artifactId>netty-all</artifactId> <artifactId>netty-all</artifactId>
<version>4.1.22.Final</version> <version>4.1.22.Final</version>
</dependency> </dependency>
<dependency>
<groupId>com.gexin.platform</groupId>
<artifactId>gexin-rp-sdk-http</artifactId>
<version>4.1.00</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/lib/gexin-rp-sdk-http-4.1.0.0.jar</systemPath>
</dependency>
<dependency>
<groupId>com.gexin.platform</groupId>
<artifactId>gexin-rp-fastjson</artifactId>
<version>1.0.0.1</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/lib/gexin-rp-fastjson-1.0.0.1.jar</systemPath>
</dependency>
<dependency>
<groupId>com.gexin.platform</groupId>
<artifactId>gexin-rp-sdk-base</artifactId>
<version>4.0.0.25</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/lib/gexin-rp-sdk-base-4.0.0.25.jar</systemPath>
</dependency>
<dependency>
<groupId>com.gexin.platform</groupId>
<artifactId>gexin-rp-sdk-template</artifactId>
<version>4.0.0.19</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/lib/gexin-rp-sdk-template-4.0.0.19.jar</systemPath>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>2.5.0</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/lib/protobuf-java-2.5.0.jar</systemPath>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
......
package com.adc.da.znks.util;
import com.gexin.rp.sdk.base.IPushResult;
import com.gexin.rp.sdk.base.impl.AppMessage;
import com.gexin.rp.sdk.http.IGtPush;
import com.gexin.rp.sdk.template.LinkTemplate;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* 个推推送服务工具类
* @author David
*/
public class AppPushUtils {
private static String appId = "";
private static String appKey = "";
private static String masterSecret = "";
private static String url = "http://sdk.open.api.igexin.com/apiex.htm";
public static void push(String msg) throws IOException {
IGtPush push = new IGtPush(url, appKey, masterSecret);
// 定义"点击链接打开通知模板",并设置标题、内容、链接
LinkTemplate template = new LinkTemplate();
template.setAppId(appId);
template.setAppkey(appKey);
template.setTitle("智能家居提示");
template.setText(msg);
List<String> appIds = new ArrayList<String>();
appIds.add(appId);
// 定义"AppMessage"类型消息对象,设置消息内容模板、发送的目标App列表、是否支持离线发送、以及离线消息有效期(单位毫秒)
AppMessage message = new AppMessage();
message.setData(template);
message.setAppIdList(appIds);
message.setOffline(true);
message.setOfflineExpireTime(1000 * 600);
IPushResult ret = push.pushMessageToApp(message);
System.out.println(ret.getResponse().toString());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment