Watch Page - Logout
This document applies to scenarios where the live streaming watch page is embedded via a WeChat Mini Program webview.
Background
When a user logs out of the Mini Program, the authorization information in the watch page needs to be cleared to protect user privacy.
Technical Implementation
After authorization is completed, the watch page supports sending a message to the Mini Program via wx.miniProgram.postMessage to notify it to clear the authorization information.
// 观看页代码
wx.miniProgram.postMessage({
event: "live-watch-export-xAuthToken",
data: {
xAuthToken: "",
channelId: "",
},
});
After the Mini Program receives the message, it can deduplicate based on channelId, store the authentication data locally, and call Polyv's logout API when the user logs out. For the specific API documentation, please refer to: Channel Watch Page Viewer Logout
Since the watch page needs to use
wx.miniProgram.postMessageto send messages to the Mini Program, you must configure the JS-API Security Domain in the WeChat Official Account backend. Please consult your Polyv after-sales colleague for the WeChat Official Account configuration corresponding to your current Polyv account, and then configure the JS-API Security Domain in the specific official account backend.
Note: Calling the API requires signing with
appSecret, so it is recommended to call this API on the server side rather than directly from the Mini Program.
Integration Reference Example
For the quick integration base code, please click to download the WeChat Mini Program example. Please refer to the README.md in the example project for integration guidance.
