unipush(一):简单个推

开篇之前先提示一下,魅族手机就不用测了,暂时获取不到clientid,此乃神坑,建议用小米/华为。
实际效果
在这里插入图片描述

一、开通unipush

1、登录DCloud开发者中心,选择你要开通unipush的应用。在这里插入图片描述
2、如下图,填写开通unipush必要内容
android 包名: 为hbuilder云打包时所用的android 包名
android应用签名?

  1. 如果在云打包时使用DCloud公用证书, 请输入 BA:AD:09:3A:82:82:9F:B4:32:A7:B2:8C:B4:CC:F0:E9:F3:7D:AE:58 。更多公用证书信息
  2. 如果使用自有证书, 请使用 jdk 中自带的 keytool 工具,查看证书信息命令: keytool -list -v -keystore {your_app}.keystore
    在这里插入图片描述
    划重点 如果不知道如何查看应用签名?参考博客
    (1)、安装jre
    (2)、找到keytool.exe文件所在目录 用cmd打开
    (3)、keytool -list -v -keystore xxx(keysotre文件所在目录)
    在这里插入图片描述
    如果以上内容填完 点击开通

二、项目文件勾选push模块

manifest.json ---> App模块配置 ---> push
在这里插入图片描述

三、代码编写、打包、测试个推

1、App.vue onLaunch内写入一下代码,打个自定义基座测试。

		let info = plus.push.getClientInfo();
		console.log(info);
			/* 5+  push 消息推送 ps:使用:H5+的方式监听,实现推送*/
		plus.push.addEventListener("click", function(msg) {
			console.log(JSON.stringify(msg));
			console.log(msg.payload);
				//这里可以写跳转业务代码
		}, false);
			// 监听在线消息事件    
		plus.push.addEventListener("receive", function(msg) {
			// plus.ui.alert(2);  
			//这里可以写跳转业务代码
			console.log("recevice:" + JSON.stringify(msg))
		}, false);

2、安装自定义基座后运行,看控制台是否输出如下代码

//info
		{
			"id": "unipush",
			"token": "ed4b5dd********5e167034e3591c940",
			"clientid": "ed4b********86a5e167034e3591c940",
			"appid": "RymQM0********uqYH4anA",
			"appkey": "6Y6m9********hscJquxf6"
		}

如果clientid不为空,则可以去DCloud开发者中心测试推送消息了。

3、测试推送消息
在这里插入图片描述
填写标题、内容 ---> 预览 ---> 确认

在这里插入图片描述
[1]: https://blog.csdn.net/wxzjn1027/article/details/85259689

  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
要在Spring Boot中整合UniPush(个)实现CID批量送,你可以按照以下步骤进行操作: 1. 首先,在你的Spring Boot项目中添加UniPush的依赖。你可以在项目的pom.xml文件中添加以下依赖: ```xml <dependency> <groupId>com.getui</groupId> <artifactId>unipush-spring-boot-starter</artifactId> <version>1.4.0</version> </dependency> ``` 2. 在你的application.properties或application.yml文件中配置UniPush相关的参数,包括appKey、appSecret、masterSecret等信息。例如: ```properties # UniPush配置 unipush.app-id=your_app_id unipush.app-key=your_app_key unipush.app-secret=your_app_secret unipush.master-secret=your_master_secret ``` 3. 创建一个送服务的Bean,在该Bean中注入UniPushService,并编写送方法。例如: ```java import com.getui.unipush.UniPushService; import com.getui.unipush.exception.RequestException; import com.getui.unipush.model.BatchPushResult; import com.getui.unipush.model.PushTarget; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service public class PushService { @Autowired private UniPushService uniPushService; public void pushToCids(List<String> cids, String message) { List<PushTarget> targets = new ArrayList<>(); for (String cid : cids) { targets.add(PushTarget.cid(cid)); } try { BatchPushResult result = uniPushService.pushMessageToList(targets, message); // 处理送结果 // ... } catch (RequestException e) { // 处理送异常 // ... } } } ``` 4. 在需要进行CID批量送的地方,注入PushService并调用pushToCids方法即可实现送。例如: ```java import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; @RestController public class PushController { @Autowired private PushService pushService; @PostMapping("/push") public void pushToCids(@RequestBody List<String> cids, @RequestBody String message) { pushService.pushToCids(cids, message); } } ``` 这样,当你通过发送POST请求到`/push`接口时,将会执行CID批量送操作。 请注意,以上代码只是一个简单示例,实际应用中可能需要根据UniPush提供的API进行更复杂的操作,比如设置送样式、透传消息等。你可以参考UniPush的官方文档来了解更多详细信息:[https://docs.getui.com/unipush/](https://docs.getui.com/unipush/)

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值