ad
Feature description:Banner ad.
Parameter and description:The prerequisite for using the mini program ad feature is that commercialization permissions have been enabled. |
unit-id | string | - | Ad unit ID, which can be created in the ad module of the console. Required. |
bindload | eventhandler | - | Callback for successful ad load. |
binderror | eventhandler | - | Callback for ad load failure, event.detail = {errCode: 1002} |
Error code
Error codes are obtained from the error information. During debugging, you can capture error details via exception returns. You can add appropriate monitoring information to assist in troubleshooting issues in the live environment.
|
1000 | Failed to call the backend API | This error is not caused by the developer. |
1001 | Parameter error | Incorrect usage. |
1002 | Invalid ad unit | Incorrect ad unit ID spelling or accidental use of another app's ad unit ID. |
1003 | Internal error | This error is not caused by the developer. |
1004 | No suitable ad | Ads do not appear every time; this time it might not appear because there are no ads that match the user's preferences. |
1010 | Ad feature disabled | The ad feature has been disabled. |
web-view
Feature description:A container that hosts the HTML5-based web pages. It will automatically fill the mini program page.
Parameter and description:
|
src | string | - | The URL of the HTML5-based web page that the web-view component points to. Configure the HTML5-based web page domain in the mini program management backend. When loading an offline HTML5-based web page, the src should start with file:// or / (pointing to an HTML page, e.g., file://xxx/index.html). You need to configure the staticPath property (an array of strings) in app.json, e.g. ["xxx"]. |
bindmessage | eventhandler | - | Triggered when the HTML5-based web page uses the wx.miniProgram.postMessage to send a message to the mini program. This occurs during back navigation, component destruction, or sharing. e.detail = { data }, where data is an array of parameters from multiple postMessage calls. |
bindload | eventhandler | - | Triggered when the HTML5-based web page is loaded successfully. e.detail = { src } |
binderror | eventhandler | - | Triggered when the HTML5-based web page fails to load. e.detail = { url, fullUrl }, where fullUrl is the complete URL that failed to load. |
bindevent | eventhandler | - | Triggered when the HTML5-based web page uses the wx.miniProgram.sendWebviewEvent to send a message to the mini program. e.detail = { data }, where data is the parameter from sendWebviewEvent. |
Notes:
The iframe domain within the HTML5-based web page must also be configured as the allowed domain.
you can click the debug button on the <web-view> component to open debugging for the <web-view> component in the mini program IDE.
Each HTML5-based web page can only have one <web-view>. It will automatically fill the entire page and cover other components.
Communication between the web page in <web-view> and the mini program is not supported except for the APIs provided by JSSDK.
Avoid using special characters (except a-z,A-Z, 0-9) in the URL, as it may cause a white screen issue on iOS. It is recommended to use encodeURIComponent to escape the URL parameters.
The priority of the navigation bar title on the page containing the <web-view> component is as follows:<title></title>
(HTML5-based web page) > wx.navigationBarTitleText
(miniprogram) > navigationBarTitleText
(page.json)> navigationBarTitleText
(app.json)
When specifying the static resource address for src, it must start with file:// or / and point to a specific HTML page. The static resources must be located in the root directory of the mini program. Additionally, you need to configure the staticPath property in app.json (an array of strings representing the directory names of the static resources). Multiple static resources can be configured, but they are only supported within the main package. When uploading the mini program, all static resources are uploaded together with the mini program, and the total size must not exceed the size limit for the entire package.
Authorization
Some APIs require user consent before they can be called. These APIs are divided into multiple scopes based on their usage range. Users can choose to authorize a specific scope, and once authorized, all APIs within that scope can be used directly.
When calling such APIs:
If the user has neither accepted nor declined this permission, a pop-up will appear asking for their consent. The API can only be called if the user agrees.
If the user has already granted permission, the APIs can be called directly.
If the user has rejected authorization, no pop-up will appear, and the API will immediately trigger the fail callback.Developers should ensure their applications handle scenarios where the user has denied permission.
Get user authorization status
Developers can get the user's current authorization status using wx.getSetting.
Open the settings page
Users can control the authorization status of the mini program in the settings page (accessible via the "..." menu in the top right corner).
Developers can call wx.openSetting to open the settings page and guide users to enable the authorization.
Initiate an authorization request in advance
Developers can use wx.authorize to initiate authorization requests to users before calling the APIs that require authorization.
Scope list
|
scope.userinfo | wx.getUserInfo | User information. |
scope.userLocation | wx.getLocation、wx.startLocationUpdate、wx.startLocationUpdateBackground | Gets geographic location information. |
scope.userFuzzyLocation | wx.getFuzzyLocation | Gets approximate geographic location information. |
scope.record | live-pusher component or wx.startRecord, wx.operateRecorder | Live streaming or recording. |
scope.camera | Camera component | Camera component. |
scope.addPhoneCalendar | wx.addPhoneCalendar | Adds logs. |
scope.writePhotosAlbum | wx.saveImageToPhotosAlbum | Saves images to an album. |
scope.bluetooth | wx.openBluetoothAdapter | Bluetooth. |
scope.chooseImage | wx.chooseImage | Selects images in the album. |
scope.chooseVideo | wx.chooseVideo | Selects videos in the album. |
scope.chooseMedia | wx.chooseMedia | Selects images or videos from the album. |
scope.makeMedia | wx.makeMedia | Takes photos or videos. |
scope.addPhoneContact | wx.addPhoneContact、wx.chooseContact | Adds/selects contacts. |
Authorization validity
Once a user explicitly agrees to or rejects an authorization, the authorization status is recorded locally on the client until the mini program is deleted.
Practice guide
Request authorization from the user only when you actually need to use the authorized API. Clearly explain the reason for needing the functionality in the authorization request.