tripflex / WifiWizard2

A Cordova plugin for managing Wifi networks (new version of WiFiWizard) - Latest is version 3+
https://www.npmjs.com/package/cordova-plugin-wifiwizard2
Apache License 2.0
123 stars 146 forks source link

this plugin seems to be broken in IOS 13.0 beta (getCurrentSSID returns unknown) #88

Open nielsoo opened 5 years ago

nielsoo commented 5 years ago

same functionality works flawless in the latest IOS 12

tripflex commented 5 years ago

Thanks for reporting this, does anybody have any insight into why this may be in iOS 13.0+?

ConPor commented 5 years ago

same issue, Xcode debugs logs:

[6077:1095709] Supported interfaces: ( en0 ) [6077:1095709] [] nehelper sent invalid result code [1] for Wi-Fi information request [6077:1095709] en0 => (null) [6077:1095709] THREAD WARNING: ['WifiWizard2'] took '41.750977' ms. Plugin should use a background thread. [6077:1095709] ERROR: Unable to get connected wifi ssid Not available

I think it's a permission issue on iOS 13:

Check out WWDC 19 session 713, Advances in Networking, Part 2 (maybe 75% of the way through the presentation). CNCopyCurrentNetworkInfo is now only available to your app in three cases:

Apps with permission to access location Your app is the currently enabled VPN app Your app configured the WiFi network the device is currently using via NEHotspotConfiguration

source

nielsoo commented 5 years ago

Hi, I added the location permission manually by installing another plugin that needs the location (cordova-plugin-geolocation) and that fixed it!

almadomus commented 5 years ago

Just received from apple:

Dear $firstName,

As we announced at WWDC19, we're making changes to further protect user privacy and prevent unauthorized location tracking. Starting with iOS 13, the CNCopyCurrentNetworkInfo API will no longer return valid Wi-Fi SSID and BSSID information. Instead, the information returned by default will be:

SSID: “Wi-Fi” or “WLAN” (“WLAN" will be returned for the China SKU) BSSID: "00:00:00:00:00:00"

If your app is using this API, we encourage you to adopt alternative approaches that don’t require Wi-Fi or network information. Valid SSID and BSSID information from CNCopyCurrentNetworkInfo will still be provided to VPN apps, apps that have used NEHotspotConfiguration to configure the current Wi-Fi network, and apps that have obtained permission to access user location through Location Services.

Test your app on the latest iOS 13 beta to make sure it works properly. If your app requires valid Wi-Fi SSID and BSSID information to function, you can do the following: For accessory setup apps, use the NEHotSpotConfiguration API, which now has the option to pass a prefix of the SSID hotspot your app expects to connect to. For other types of apps, use the CoreLocation API to request the user’s consent to access location information.

Learn more by reading the updated documentation or viewing the the Advances in Networking session video from WWDC19. You can also submit a TSI for code-level support.

arsenal942 commented 5 years ago

Apple really don’t help developers out here. I will update the plugin with a fix shortly otherwise it will require you as the user to implement a polling mechanism which checks if you’re still connected to your IoT device. I imagine this would involve polling a local endpoint on the connected device and checking if that resolves or not.

almadomus commented 5 years ago

Thanks. For most iot device maybe the solution suggested by Apple is OK (passing a prefix of ssid created by device) but different from what currently your plugin is doing.

awaism551 commented 5 years ago

@arsenal942 Please let us know in which version of this plugin this ios13 issue is resolved, I also received the same email from apple regarding their policy change as shown by @almadomus. Yes there is an option of using some external plugin to grant access but it would be great if this thing will be included in this awesome plugin aswell

Giaco90 commented 5 years ago

I had the same problem and found this solution working for me:

https://juejin.im/post/5d4d1478f265da03e921b7de (google translate it)

The solution seems to be to check and force the permission request by means of the CoreLocationManager in the "fetchSSIDInfo".

studiostart commented 5 years ago

Hello, I had the same problem in my home automation app, which needed the SSID string. In IOS 13, getCurrentSSID method stopped working. I resolved installing the cordova-plugin-geolocation and using its getCurrentPosition method just to rise the ios authorization alert. After confirmed the authorization, wifiwizard started to work as espected.

VijayVaveHealth commented 5 years ago

I was on iOS 13.0 and installed the cordova-plugin-geolocation and called getCurrentPosition to ask for location permission seems to have worked for like a week, but then it stopped working. Anyone else run into this issue on iOS 13.1.2.

angelofan commented 4 years ago

Is it possible to do something in order to be compatible with devices with version numbers ios13+ and android 8.1+?

If you don't do this, everyone needs to make this judgment in their code when using the plugin.

digaus commented 4 years ago

Is it possible to do something in order to be compatible with devices with version numbers ios13+ and android 8.1+?

  • Check if the permission to call the location is obtained
  • If not, a prompt box will pop up for the user to authorize

If you don't do this, everyone needs to make this judgment in their code when using the plugin.

Here is a fix if anyone wants to test it:

https://github.com/digaus/WifiWizard2/commit/061b681c43129f9abe54e6eaa705930362e1bb55

Just add "cordova-plugin-wifiwizard2": "git+ssh://git@github.com/digaus/WifiWizard2.git#master" to package.json and run npm install

ttthub commented 4 years ago

Is it possible to do something in order to be compatible with devices with version numbers ios13+ and android 8.1+?

  • Check if the permission to call the location is obtained
  • If not, a prompt box will pop up for the user to authorize

If you don't do this, everyone needs to make this judgment in their code when using the plugin.

Here is a fix if anyone wants to test it:

digaus@061b681

Just add "cordova-plugin-wifiwizard2": "git+ssh://git@github.com/digaus/WifiWizard2.git#master" to package.json and run npm install

Tried this on iphone 11, and the app fails to launch with this error:

This app has attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an “NSLocationWhenInUseUsageDescription” key with a string value explaining to the user how the app uses this data.

angelofan commented 4 years ago

@ttthub @digaus iOS Quirks Since iOS 10 it's mandatory to provide an usage description in the info.plist if trying to access privacy-sensitive data. When the system prompts the user to allow access, this usage description string will displayed as part of the permission dialog box, but if you didn't provide the usage description, the app will crash before showing the dialog. Also, Apple will reject apps that access private data but don't provide an usage description.

This plugins requires the following usage description:

NSLocationWhenInUseUsageDescription describes the reason that the app accesses the user's location. To add this entry into the info.plist, you can use the edit-config tag in the config.xml like this:

<edit-config target="NSLocationWhenInUseUsageDescription" file="*-Info.plist" mode="merge">
    <string>need location access to find things nearby</string>
</edit-config>

Just like other plugins that auto-write config.xml to be automatically added to info.plist at compile time, this plugin should automatically write this code to config.xml during installation.

Here are some references: https://errorsandmore.wordpress.com/2018/01/04/ionic-3-geolocation-not-working-on-ios-error/ https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-geolocation/#ios-quirks

digaus commented 4 years ago

Yes should have mentioned that. I switched to capacitor and created a WiFi plugin there.

ttthub commented 4 years ago

I can confirm that it has worked for me on iOS 13.3 after adding the config manually.

However, it does not detect the wifi details on iOS 13.2.3 (dont know about other versions)

angelofan commented 4 years ago

I can confirm that it has worked for me on iOS 13.3 after adding the config manually.

However, it does not detect the wifi details on iOS 13.2.3 (dont know about other versions)

@ttthub Seems to be a bug in iOS: #95

arsenal942 commented 4 years ago

Is it possible to do something in order to be compatible with devices with version numbers ios13+ and android 8.1+?

  • Check if the permission to call the location is obtained
  • If not, a prompt box will pop up for the user to authorize

If you don't do this, everyone needs to make this judgment in their code when using the plugin.

Here is a fix if anyone wants to test it:

digaus@061b681

Just add "cordova-plugin-wifiwizard2": "git+ssh://git@github.com/digaus/WifiWizard2.git#master" to package.json and run npm install

What changes did you make and if you can, submit a PR and I will review it.

digaus commented 4 years ago

Is it possible to do something in order to be compatible with devices with version numbers ios13+ and android 8.1+?

  • Check if the permission to call the location is obtained
  • If not, a prompt box will pop up for the user to authorize

If you don't do this, everyone needs to make this judgment in their code when using the plugin.

Here is a fix if anyone wants to test it: digaus@061b681 Just add "cordova-plugin-wifiwizard2": "git+ssh://git@github.com/digaus/WifiWizard2.git#master" to package.json and run npm install

What changes did you make and if you can, submit a PR and I will review it.

You can see the changes in the link. :) Currently busy with my application. Created my own Ionic Capacitor WiFi Plugin for better integration in my project.

If I find the time I can make a PR

angelofan commented 4 years ago

Any progress?