tencent cloud

Feedback

API description

Last updated: 2024-07-12 16:45:48

    Relevant APIs

    API
    Description
    wx.miniProgram.navigateTo
    The parameters are the same as those of the corresponding mini program API
    wx.miniProgram.navigateBack
    The parameters are the same as those of the corresponding mini program API
    wx.miniProgram.switchTab
    The parameters are the same as those of the corresponding mini program API
    wx.miniProgram.reLaunch
    The parameters are the same as those of the corresponding mini program API
    wx.miniProgram.redirectTo
    The parameters are the same as those of the corresponding mini program API
    wx.miniProgram.postMessage
    Sends a message to the mini program, triggering the component's message event in specific scenarios such as returning to a mini program page, terminating or sharing a component and copying links
    wx.miniProgram.getEnv
    Gets the current environment information

    Relevant APIs

    API Module
    API description
    Specific APIs
    Image APIs
    Take a photo or upload an image
    chooseImage
    Preview an image
    previewImage
    Upload an image
    uploadImage
    Download an image
    downloadImage
    Get local images
    getLocalImgData
    Audio APIs
    Start recording
    startRecord
    Stop recording
    stopRecord
    Recording listening stops automatically
    onVoiceRecordEnd
    Play audio
    playVoice
    Pause
    pauseVoice
    Stop playback
    stopVoice
    Audio playback listening ends
    onVoicePlayEnd
    Device information
    Get network status
    getNetworkType
    Geographical location
    Display location in built-in map
    openLocation
    Gets the geographical location
    getLocation
    Sample code
    <!-- html -->
    <script type="text/javascript" src="https://raw.githubusercontent.com/TencentCloud/tcmpp-demo-miniprogram/main/index.js"></script>
    wx.miniProgram.navigateTo({url: '/path/to/page'})
    wx.miniProgram.postMessage({ data: 'foo' })
    wx.miniProgram.postMessage({ data: {foo: 'bar'} })
    wx.miniProgram.getEnv(function(res) { console.log(res.miniprogram) })

    Relevant APIs

    When users share, the current WebView URL can be obtained in the onShareAppMessage callback via the webViewUrl parameter.
    Sample code
    Page({
    onShareAppMessage(options) {
    console.log(options.webViewUrl)
    }
    })

    Relevant APIs

    In the web page, you can determine if you are in a mini program environment using the window.__wxjs_environment variable. It is recommended to use this in the WeixinJSBridgeReady callback, or you can use the getEnv interface provided by the JS SDK.
    Sample code
    // Inside the WebView page
    function ready() {
    console.log(window.__wxjs_environment === 'miniprogram') // true
    }
    if (!window.WeixinJSBridge || !WeixinJSBridge.invoke) {
    document.addEventListener('WeixinJSBridgeReady', ready, false)
    } else {
    ready()
    }
    
    // O
    wx.miniProgram.getEnv(function(res) {
    console.log(res.miniprogram) // true
    })

    Tips

    The domain of the iframe within the web page also needs to be configured in the domain whitelist;
    In the developer tools, you can open the WebView debugging interface in the WebView component preview;
    Each page can only have one WebView, which will automatically fill the entire page and cover other components;
    Communication between the WebView page and the mini program is only supported through the APIs provided by the JS SDK;
    Avoid using Chinese characters in the link, as it may cause a white screen issue on iOS. It is recommended to use encodeURIComponent.
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support