jpush java sdk下载_JPush java_sdk 的使用

1 maven配置文件

cn.jpush.api

jpush-client

3.2.7

cn.jpush.api

jiguang-common

1.1.1

io.netty

netty-all

4.1.6.Final

compile

com.google.code.gson

gson

2 极光推送工具类

package com.zjxnjz.mall.restfulapi.common.util;

import cn.jpush.api.JPushClient;

import cn.jpush.api.common.resp.APIConnectionException;

import cn.jpush.api.common.resp.APIRequestException;

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 cn.jpush.api.push.model.notification.Notification;

/**

* 极光推送 Jpush 工具类

* @author SHF

* @version 创建时间:2018年6月15日 下午4:33:46

*/

public class JPushUtil {

private static String AppKey = "06947ff1ce4a86f1b0b1f2c1";

private static String Maste_Secret = "9b23669ef51f984c6ad17f8c";

public static PushResult push(Notification notification,Message message) {

//创建jpush对象

JPushClient jPushClient=new JPushClient(Maste_Secret,AppKey);

PushPayload payload = PushPayload.newBuilder()

.setPlatform(Platform.all())

.setAudience(Audience.all())

.setNotification(notification)

.setMessage(message)

.build();

try {

PushResult result = jPushClient.sendPush(payload);

System.out.println("success");

System.out.println("消息id为:"+result.msg_id);

System.out.println("发送id为:"+result.sendno);

return result;

} catch (APIConnectionException e) {

e.printStackTrace();

} catch (APIRequestException e) {

e.printStackTrace();

}

return null;

}

}

转载至链接:https://my.oschina.net/u/3677987/blog/1831104

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值