我已经使用 WifiWizard 插件来获取 SSID,但它在 iOS 13 上不起作用。它给我 SSID 作为“Wi-Fi”关键字,它没有显示实际连接的 WiFi SSID。
我在 info.plist 中使用时添加了 Location 键,并且还尝试更新 native iOS 代码,但它不起作用。
我尝试过使用 WifiWizard2 插件,但这也不起作用。
getWifiName() {
WifiWizard.getCurrentSSID(ssidHandler => {
console.log(ssidHandler);
ssidHandler = ssidHandler.toString().replace("\"", "");
ssidHandler = ssidHandler.toString().replace("\"", "");
this.connectedTo = ssidHandler;
this.ssidHandler(ssidHandler);
}, fail => {
this.goToSettingsButton = false;
console.log(fail);
});
}
我想要 iOS 13 中的当前 WiFi SSID,比如如果我连接到 ABC Wifi 网络,那么它应该给我 SSID 作为 ABC。
最佳答案
嘿,我遇到了同样的问题,并通过安装 cordova-plugin-geolocation
解决了它. Here's the official site
基本上是->
请注意,我正在安装特定版本,因为我的 ionic 3.20.1 $ ionic cordova plugin add cordova-plugin-geolocation@3
$ npm install @ionic-native/geolocation@4.10
import { Geolocation } from '@ionic-native/geolocation';
...
constructor(private geolocation: Geolocation) {}
...
async yourAwesomeFunction() {
try {
pos = await this.geolocation.getCurrentPosition();
if (pos) WifiWizard.getCurrentSSID((ssid) => {
//your stuff
});
} catch((err) => {
console.error(err);
})
然后将其添加到
config.xml
:<config-file overwrite="true" parent="NSLocationWhenInUseUsageDescription" platform="ios" target="*-Info.plist">
<string>Allow the app to know your location</string>
</config-file>
之后我添加了库
CoreLocation
(General 的 XCODE 选项卡)到项目。
关于ios - 如何使用 Ionic3 获取 iOS 13 WiFi SSID?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58214041/