HomeDocs
Skip to main content

onWifiConnected

Introduction

Listens for Wi-Fi connection events.

Parameters

None

Callback Return Parameters

Object res

ParameterTypeDescription
wifiwifiInfoWi-Fi info

Sample Code

Page({
data: {
wifiStatus: '',
getConnectedWifi: '',
},
onReady() {
this.startWifi().then(() => {
this.onWifiConnected();
});
},
startWifi() {
const _that = this;
return new Promise((resolve, reject) => {
dlt.startWifi({
success: function (res) {
console.log('startWifi success', res);
_that.setData({
wifiStatus: 'startWifi',
});
resolve(res);
},
complete: function (res) {
console.log('startWifi complete', res);
},
fail: function (res) {
console.log('startWifi fail', res);
reject(res);
},
});
});
},
onWifiConnected() {
const _that = this;
dlt.onWifiConnected({
success: function (res) {
console.log('onWifiConnected success', res);
_that.setData({
getConnectedWifi: res,
});
},
complete: function (res) {
console.log('onWifiConnected complete', res);
},
fail: function (res) {
console.log('onWifiConnected fail', res);
_that.setData({
getConnectedWifi: res,
});
},
});
},
});
Privacy agreementDeveloper agreementcontact us: developer_service.mi@transsion.com © 2024 MiniApp. All Rights Reserved.