[英]How to get iOS 13 WiFi SSID using Ionic3?
我已經使用 WifiWizard 插件來獲取 SSID,但它在 iOS 13 上不起作用。它給我 SSID 作為“Wi-Fi”關鍵字,它沒有顯示實際連接的 WiFi SSID。
我在 info.plist 中使用時添加了 Location 鍵,並且還嘗試更新本機 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
解決了它。 這里是官方網站
基本上是->
請注意,由於我的 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 選項卡)添加到項目中。
我試過這個但沒有給我 WiFi SSID,它進入失敗 state 並給我一個“不可用”的響應。 我對 iPhone 11 (iOS 13.1.3) 有疑問。 但是當我在 iPhone XS MAX (iOS 13.1.3) 上運行它時,它會給我 SSID。 請幫我解決這個問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.