uniapp使用uni-push模拟推送

第一步先去uniapp开发者中心添加开通uni-push功能
在这里插入图片描述
这里的Android 应用签名可以先用测试的官网有,可以先用这个测试
官方测试链接文档地址
在这里插入图片描述

在项目中的配置文件勾选
在这里插入图片描述
组件中使用 如果要实时可以去做全局ws

//消息推送模版
 uni.createPushMessage({
 	title: '您有新的待办事项!', //标题
 	content: `待办事项内容为:测试测试`, //内容
 	icon: '/static/images/login/login.png', //icon
 	sound: 'system', //提示音
    cover: false, //覆盖
 	success: e => {},
 });
 
//语音
// async function voice() {
// 	await nextTick();
// 	const innerAudioContext = uni.createInnerAudioContext(); //初始化
// 	innerAudioContext.autoplay = true; //自动播放
// 	innerAudioContext.src = '../../static/massage.wav'; //播放音频
// 	innerAudioContext.onPlay(() => {
// 		console.log('开始播放');
// 	});
// }

感谢!

更多推荐