unipush的使用及注意事项

传送门 >> ​​​​​​cunipush的使用及注意事项 - huihuihero - 博客园 (cnblogs.com)

onLaunch() {
	// console.log('初始化完成了(只触发一次)');
	// #ifdef APP-PLUS  
	const _self = this;  
	const _handlePush = function(message) {
		// console.log(message)
		if(message.payload){
			uni.navigateTo({
				url: message.payload
			});
		}
	};  
        const _handleRemind = function(message) {
		if(message.content){
			uni.showModal({
				title: '温馨提示',
				content: message.content,
				success: function (res) {
					if (res.confirm) {
						if(message.payload){
							uni.navigateTo({
								url: message.payload
							});
						}
					} else if (res.cancel) {
							
					}
				}
			});
		}
	};  
	plus.push.addEventListener('click', _handlePush);  //用户点击推送消息事件:一般在App后台运行时(消息通过厂商方式以通知形式在通知栏送达),然后用户点击消息后触发此事件
	plus.push.addEventListener('receive', _handleRemind);  //用户接收到推送消息事件:一般在用户正在使用App时(消息通过个推方式送达),用户直接在App内接收到消息并触发此事件
	// #endif  
},

猜你喜欢

转载自blog.csdn.net/qq285679784/article/details/125504521