tencent cloud

Feedback

Last updated: 2024-03-04 23:07:38

    onNetworkStatusChange

    This API is used via wx.onNetworkStatusChange(function callback).
    Feature Description: Monitors network status change events.
    Parameter and Description: Function callback.
    Callback function parameters for network status change events: Object res.
    Attribute
    Type
    Description
    isConnected
    boolean
    Current Network Connection Status
    networkType
    string
    Network type
    Legitimate Values of Legitimate
    Value
    Description
    wifi
    Wi-Fi Network
    2g
    2G Network
    3g
    3G Network
    4g
    4G Network
    unknown
    Uncommon Network Types on Android
    none
    No network
    Sample Code
    wx.onNetworkStatusChange(function (res) {
    console.log(res.isConnected)
    console.log(res.networkType)
    })

    getNetworkType

    This API is used via wx.getNetworkType(Object object).
    Feature Description: Gets the network type.
    Parameter and Description: Object.
    Attribute
    Type
    Default value
    Required
    Description
    success
    function
    -
    No
    Callback Function of Successful Interface Call
    fail
    function
    -
    No
    Callback Function of Failing Interface Call
    complete
    function
    -
    No
    Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations)
    Object.success callback function: Object res.
    Attribute
    Type
    Description
    networkType
    string
    Network type
    Valid values of res.networkType
    Value
    Description
    wifi
    Wi-Fi Network
    2g
    2G Network
    3g
    3G Network
    4g
    4G Network
    unknown
    Uncommon Network Types on Android
    none
    No network
    Sample Code
    wx.getNetworkType({
    success(res) {
    const networkType = res.networkType
    }
    })

    offNetworkStatusChange

    This API is used via wx.offNetworkStatusChange(function listener).
    Feature Description: Removes the listener function for network status change events.
    Parameter and Description: function listener, the listener function passed in by onNetworkStatusChange. If this parameter is not passed in, all listener functions will be removed.
    Sample Code
    const listener = function (res) { console.log(res) }
    
    wx.onNetworkStatusChange(listener)
    wx.offNetworkStatusChange(listener) // The same function object as the listener must be passed in.
    
    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