unipush+个推实现消息推送

1.注册个推平台的帐号个推,专业的数据智能服务商-为垂直领域提供数据智能解决方案

2.应用列表中选择新增应用/服务

3.填写下应用信息4.创建好应用后在manifest.json中的sdkConfigs配置上写入appid、appkey、appsecret

复制代码
           "sdkConfigs" : {
                "ad" : {},
                "push" : {
                    "igexin" : {
                        "appid" : "你的appid",
                        "appkey" : "你的appkey",
                        "appsecret" : "你的appsecret"
                    }
                }
            },

配置好后,在manifest.json中勾选Push模块(不勾选uniPush1.0和uniPush2.0)

5.登录方法中,写入获取cid的方法

复制代码
let userCid = ''
let pinf = plus.push.getClientInfo();
userCid = pinf.clientid;
console.log(userCid ,'userCid');

6.在app中写入监听推送方法

复制代码
	uni.onPushMessage(res=>{
                    //接收消息
					if(res.type=='receive'){
						uni.createPushMessage({
							title:res.data.payload.title,
							content:res.data.payload.body,
							payload:res.data.payload
						})
                    //这里我们使用了自定义的提示音
						const innerAudioContext = uni.createInnerAudioContext();
							innerAudioContext.autoplay = true;
							const filePath = '音频地址';
							innerAudioContext.src = filePath;
							innerAudioContext.onPlay(() => {
								console.log('开始播放');
							});
						innerAudioContext.play();
                    //点击后
					}else if(res.type=='click'){
                        跳转到首页
						uni.navigateTo({
							url:'/pages/index/index'
						})
					}
					
	
				});

前端部分 仅供参考,欢迎各位大佬指导!后续会补充离线推送

相关推荐
Meaauf10 分钟前
VMware安装中科方德服务器操作系统
运维·服务器·中科方德
mftang27 分钟前
现代互联网安全的基石: SSL/TLS技术介绍
服务器·网络·ssl
坐怀不乱杯魂30 分钟前
Linux网络 - 网络层
linux·服务器·网络
j_xxx404_31 分钟前
Linux:命令行参数与环境变量
linux·运维·服务器
j_xxx404_40 分钟前
Linux:进程虚拟地址空间|虚拟内存管理
linux·运维·服务器
德尔塔大雨淋1 小时前
VLLM 中的module PASS 和FUN PASS
linux·服务器·vllm
天人合一peng1 小时前
Unity中button 和toggle监听事件函数有无参数
前端·unity·游戏引擎
沐芊屿1 小时前
华为交换机配置M-LAG
服务器·网络·华为
枷锁—sha2 小时前
【SRC】越权漏洞检测
运维·服务器·网络·安全·网络安全·系统安全
UP_Continue2 小时前
Linux--进程控制
linux·运维·服务器