uniapp的app端推送功能,不使用unipush

1:推送功能使用htmlPlus实现:地址HTML5+ API Reference (html5plus.org)

效果图:

代码实现:

javascript 复制代码
<template>
	<view class="content">
		<view class="text-area">
			<button @click="createMsg">本地消息</button>
		</view>
		<button @click="openquanxian">跳转系统授权管理页</button>
        <button @click="getquanxian">获取 APP 授权设置</button>
	</view>
</template>

<script setup>
	import {
		ref,
		onMounted,
		nextTick
	} from 'vue';
	onMounted(() => {

	})
	const openquanxian = () => {
		uni.openAppAuthorizeSetting({
			success(res) {
				console.log(res)
			}
		})

	}
	const getquanxian = () => {
		let info = uni.getAppAuthorizeSetting()
		console.log('log', info);
	}
	// #ifdef APP-PLUS
	let ClientInfo = ref()
	let AllMessage = ref()
	const createMsg = () => {
		plus.push.createMessage('我是一条本地消息', '', {
			title: 'xxx科技',
		})
		ClientInfo.value = plus.push.getClientInfo()
		console.log('log', ClientInfo.value);
		AllMessage.value = plus.push.getAllMessage()
		console.log('log', AllMessage.value);
		// plus.push.setAutoNotification(true);

	}
	plus.push.addEventListener('click', function(success) {
		console.log('logsss', success);
	});
	// #endif
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>

请注意要实现消息推送功能,前提是应用的通知权限要打开

以上代码已实现从应用内跳到应用权限页,在实际工作中用户刚打开应用就要判断应用的通知权限是否打开,uniapp中有相关方法,如果获取到的值是没有打开的状态就要显示弹框询问是否打开通知权限,点击确定就跳转到应用权限页

相关推荐
PedroQue9911 小时前
Vue Router 4.x风格导航守卫全面升级
前端·uni-app
Haibakeji13 小时前
APP小程序定制开发项目频繁延期?前期规避方法与落地避坑指南
小程序·uni-app·软件需求
anyup14 小时前
迁移uni-app x,我是如何让 AI 把我一步步搞崩溃的...
前端·uni-app·trae
2501_9160074715 小时前
申请 iOS 推送证书并配置 APNs 群发推送教程
android·ios·小程序·https·uni-app·iphone·webview
博客zhu虎康16 小时前
uni-app云打包显示编译成功,但是一直没有进入打包队列,后面也一直没反应
uni-app
JavaDog程序狗2 天前
【指南】uni-app微信小程序多环境CI-CD完全指南
ci/cd·uni-app·jenkins
PedroQue992 天前
uni-router v2.1.0 升级:导航守卫全面支持返回值模式
前端·uni-app
2501_915909062 天前
iOS test 测试怎么做?功能、性能、兼容、稳定与安全五类测试指南
android·ios·小程序·https·uni-app·iphone·webview
游戏开发爱好者84 天前
App Store 上传 IPA 自动化,.p8 密钥认证与 CI/CD 接入实战
android·运维·ci/cd·小程序·uni-app·自动化·iphone
游戏开发爱好者84 天前
iOS 推送怎么配置,APNs 推送证书、设备库与群发
android·ios·小程序·https·uni-app·iphone·webview