小程序私密消息功能是这样一种能力:当分享者分享小程序卡片给其他用户或者微信群后,其他用户点击此小程序卡片时,开发者可以鉴别出点击卡片的用户是否被分享者分享过小程序卡片。
也就是说私密消息不可以被二次转发,即:A转发给B的消息,只有B能看;如果B再转发给他人,别的人是看不到的(验证失败)。
开发步骤
1. 通过后台接口 createActivityId 创建activityId,可参考文档:https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/mp-message-management/updatable-message/createActivityId.html
2. 通过 wx.updateShareMenu 接口声明本次分享的消息为私密消息。
wx.updateShareMenu({
withShareTicket: true,
isPrivateMessage: true,
activityId: 'xxx',
})
3. 通过 wx.authPrivateMessage 接口可以验证当前用户是否是私密消息的接收者
wx.authPrivateMessage({
shareTicket: 'xxxxxx',
success(res) {
console.log('authPrivateMessage success', res)
// res
// {
// errMsg: 'authPrivateMessage:ok'
// valid: true
// iv: 'xxxx',
// encryptedData: 'xxxxxx'
// }
},
fail(res) {
console.log('authPrivateMessage fail', res)
}
})
-
微信小程序打开任意公众号文章 wx.openOfficialAccountArticlewx.openOfficialAccountArticle是微信小程序通过小程序打开任意公众号文章api,不包括临时链接等异常状态下的公众号文章,必须有点击行为才能调用成功。
-
wx.onBatteryInfoChange 监听电池信息变化事件 APIwx.onBatteryInfoChange 为微信小程序监听电池信息变化事件 API,,目前只支持监听省电模式的切换,目前仅 iOS 端支持。
-
live-pusher 实时音视频录制媒体组件live-pusher 微信小程序实时音视频录制媒体组件,v2.9.1 起支持同层渲染。需要用户授权 scope.camera、scope.record。
-
open-container容器转场动画组件open-container为微信小程序容器转场动画组件。
-
wx.setStorage 将数据存储在本地缓存中指定的 key 中微信小程序wx.setStorage 将数据存储在本地缓存中指定的 key 中。会覆盖掉原来该 key 对应的内容。除非用户主动删除或因存储空间原因被系统清理,否则数据都一直可用。单个 key 允许存储的最大数据长度为 1MB,所有数据存储上限为 10MB。
-
微信小程序wx.getExtConfig 的同步版本 APIwx.getExtConfig 为微信小程序的同步版本 API。
暂无评论,抢个沙发...