当前位置:   article > 正文

uni做微信小程序订阅消息提醒_uni-app使用微信小程序开发者消息提醒在哪配置

uni-app使用微信小程序开发者消息提醒在哪配置

1,微信开放平台申请 模板ID
在这里插入图片描述
2, 前端uni,uni.requestSubscribeMessage 必须是手动点击触发
微信官方文档

第一步 :  uni.getSetting 查询下 订阅消息的总开关 有没有打开 res.subscriptionsSetting.mainSwitch 为 true 是打开了
第二步: 如果打开了,直接调用  uni.requestSubscribeMessage 
		 如果没打开,申请打开进入设置页,让客户手动打开 uni.openSetting
  • 1
  • 2
  • 3
 changeAgree() {
				uni.getSetting({
				     withSubscriptions:true,
				      success(res) {
				         if(!res.subscriptionsSetting.mainSwitch) { 
														uni.showModal({
															title: '温馨提示',
															content: '您没有开启订阅消息的权限,是否去设置?',
															success: function(resdata) {
																if (resdata.cancel) {
																	uni.showToast({
																		title: '拒绝',
																		icon: 'none',
																		duration: 1000
																	})
																} else if (resdata.confirm) {
																	uni.openSetting({
																		withSubscriptions: true,
																		success: function(dataAu) {
																			console.log(dataAu, '打开设置页')
																			
																		}
																	})
																}
															}
														})
				         }else { 
				            // var templateid = that.setting.templateid.map(item => item.tempid)
				            uni.requestSubscribeMessage({
				              tmplIds: ['lr1yIFt8wA_g2LBqPWj-ZMSjB8ihsfgB-uHNXrD7ABo'],
				              success (resres) {
				                 console.log(resres,'成功成功')
				              },
				              fail(fail) {
				                 console.log(fail,'失败失败失败')
				              }
				            }) 
				         }
				      }
				   })
			}
  },
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42

第二种

// 订阅消息推送
	showModelTip() {
		let that = this;
		uni.showModal({
			title: '提示',
			content: '为了及时的接收消息,小程序需要向您发送消息',
			success: function(res) {
				if (res.confirm) {
					uni.requestSubscribeMessage({
						tmplIds: [
							// '6PomzR3yaFxaH56Zk76Ukp6cnKisN0',
							// 'pKOyYC1-6OuEXqewHrfDtBbB6mCGBh4',
							// 'Ow14vl-SJyMPnck4O96s_Q5DSRO2Q'
						],
						success(res) {
						},
						fail(err) {
							console.log(err)
						}
					})
				} else if (res.cancel) {
					uni.showModal({
						title: '提示',
						content: '拒绝后您将无法接收消息',
						confirmText: "知道了",
						showCancel: false,
						success: function(res) {
							
						}
					});
				}
			}
		});
	},
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小惠珠哦/article/detail/963505
推荐阅读
相关标签
  

闽ICP备14008679号