如何使用 Ionic3 获取 iOS 13 WiFi SSID?
How to get iOS 13 WiFi SSID using Ionic3?
我已经使用 WifiWizard 插件获取 SSID,但它在 iOS 13 上不起作用。它给我 SSID 作为 "Wi-Fi" 关键字,它没有显示实际连接的 WiFi SSID。
我在 info.plist 中添加了 Location when in use key 并且还尝试更新本机 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 选项卡)添加到项目中。
我已经使用 WifiWizard 插件获取 SSID,但它在 iOS 13 上不起作用。它给我 SSID 作为 "Wi-Fi" 关键字,它没有显示实际连接的 WiFi SSID。
我在 info.plist 中添加了 Location when in use key 并且还尝试更新本机 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 选项卡)添加到项目中。