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中有相关方法,如果获取到的值是没有打开的状态就要显示弹框询问是否打开通知权限,点击确定就跳转到应用权限页

相关推荐
00后程序员张15 小时前
苹果App Store上架指南:费用、原理与步骤详解
android·ios·小程序·https·uni-app·iphone·webview
特创数字科技1 天前
【uni-app x】告别系统相机限制!三端通用自定义相机组件:任意布局、静默拍照、录像、水印叠加、连拍回图一次搞定
前端·数码相机·uni-app
Martin -Tang1 天前
uniapp app嵌套webview 弹窗方式
android·ios·uni-app
郑州光合科技余经理1 天前
同城电商系统:库存变更怎么同步到订单
java·开发语言·前端·后端·uni-app·php·ai编程
CHB2 天前
一文讲透原生渲染和自渲染
flutter·react native·uni-app
码兄科技8 天前
24小时自助健身房系统软件开发实战指南:功能设计与部署方案
java·spring boot·uni-app
2501_916007478 天前
苹果商店iOS应用上架费用全面解析:开发者计划与审核费用计算
android·ios·小程序·https·uni-app·iphone·webview
2501_916008898 天前
如何实现iOS App代码混淆:SwiftShield使用指南
android·ios·小程序·https·uni-app·iphone·webview
2501_916008898 天前
怎么用 Godot 导出 iOS 应用并上架 App Store?签名字段该填什么?
android·ios·小程序·https·uni-app·iphone·webview
郑州光合科技余经理9 天前
同城外卖小程序开发:下单成功后,后台导出能不能对上用户端状态
开发语言·前端·git·后端·uni-app·php·ai编程