PushManager

http://suchandalex.googlecode.com/svn/trunk/beOui/beWe/client/Classes/PushNotificationManager.m

转载于:https://www.cnblogs.com/vincent-lu/archive/2012/01/18/2325740.html

集成个推可以让我们在SpringBoot应用中使用个推的推送服务,下面是基本的集成步骤: 1. 首先在个推官网上注册账号,创建应用并获取AppID和AppKey。 2. 在pom.xml文件中添加个推相关依赖: ```xml <dependency> <groupId>com.gexin</groupId> <artifactId>gexin-sdk-push</artifactId> <version>4.0.9.0</version> </dependency> ``` 3. 创建个推配置类,配置相关参数: ```java @Configuration public class GetuiConfig { @Value("${getui.appId}") private String appId; @Value("${getui.appKey}") private String appKey; @Value("${getui.masterSecret}") private String masterSecret; @Bean public PushManager pushManager() { IGtPush push = new IGtPush(appKey, masterSecret); push.connect(); PushManager pushManager = new PushManager(push, appId); return pushManager; } } ``` 4. 在application.properties或者application.yml中添加个推相关配置参数: ```yaml getui: appId: your_app_id appKey: your_app_key masterSecret: your_master_secret ``` 5. 在需要推送的地方注入PushManager并调用相关方法即可: ```java @Autowired private PushManager pushManager; public void pushMessage() { // 构造消息 NotificationTemplate template = new NotificationTemplate(); template.setAppId(appId); template.setAppkey(appKey); template.setTitle("Title"); template.setText("Text"); // 推送消息 List<String> clientIdList = Arrays.asList("client_id_1", "client_id_2"); pushManager.pushMessageToSingle(template, "client_id", 0); pushManager.pushMessageToList(template, clientIdList, 0); } ``` 以上就是在SpringBoot应用中集成个推的基本步骤。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值