Developers can open Official Account articles in the app via a webview. However, some Official Account articles contain embedded Official Account cards, Mini Program cards, and Channels cards. To provide a better user experience, the cross-platform framework now supports these card types within Official Account articles. When users click on these cards, they are redirected to the corresponding Mini Program page, allowing them to perform further actions by clicking the relevant cards.
Prerequisites
-
The current cross-platform app is already bound to a mobile app account, and the development information for the mobile app has been configured.
-
The Mini Program bound to the cross-platform app has been published and is live, and the related Mini Program Page has configured onShareAppMessage.
-
The SDK must be the latest version: Android SDK must be ≥ 1.2.9; iOS SDK must be ≥ 1.2.13.
Adaptation Principle
- The essence of this adaptation is to trigger the
onShareAppMessagecallback of the current page to obtain the target Mini Program page path and Mini Program type, and then initiate the redirect. Developers can determine the final destination page and Mini Program type for the redirect based on their business logic.
Response Parameters
| Attribute | Type | Default | Required | Description |
|---|---|---|---|---|
| path | string | Yes | The path of the page to open when navigating to a Mini Program | |
| miniprogramType | number | 0 | No | The type of the Mini Program to navigate to |
Sample Code
let IS_SAAASDK = false
Page({
onLoad() {
wx.getSystemInfoAsync({
success: (res) => {
IS_SAAASDK = res.host.env === "SAAASDK"
}
})
},
onShareAppMessage() {
// In multi-platform scenarios, return the page path and Mini Program type
if (IS_SAAASDK) {
return {
path: '/pages/webview/index?url=https://mp.weixin.qq.com?fromSAAASDK=1', // The page path to open when jumping to Mini Program
miniprogramType: 1, // Jump to the development version
}
}
// Custom share card in Mini Program scenarios
return {
title: 'Custom forward title',
path: '/pages/webview/index?url=https://mp.weixin.qq.com',
}
},
})
Interaction Diagram
