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

iOSConnectNetwork connects network but gets into fail callback - iOS 12+ #62

Open gdeiorio opened 5 years ago

gdeiorio commented 5 years ago

<!--

Have you read the plugins' Code of Conduct? By creating an Issue, you are expected to comply with it, including treating everyone with respect: https://github.com/tripflex/wifiwizard2/blob/master/CODE_OF_CONDUCT.md

-->

Prerequisites

Check all boxes if you have done the following:

Issue type

Select all that apply

Description

When connecting a network, open or protected, with a DISTRIBUTION PROFILE on iOS 12+, it connects correctly, but then it gets into the fail callback and a native dialog of connection failure is shown, although the net stays connected. This doesn't happen with a development profile.

Steps to Reproduce

  1. Pass to function the params of an open or protected network
  2. Build with a Distribution profile
  3. Connect network

Expected behavior: Connect network and go on OR get a failure dialog and don't connect

Actual behavior: The network is connected and a failure dialog is shown

Reproduces how often: 100% of times

Versions

WifiWizard 3.1.0; iPhone 6s; iOS 12+; Distribution profile

dpinter commented 5 years ago

I have the same problem with WifiWizard2.getConnectedSSID(). It works in development mode, but when I build it with Enterprise certificate, I get a failure callback with NOT AVAILABLE error. Can you help me?

Cordova > 8, iOS > 12, tested on Ipad

tripflex commented 5 years ago

@gdeiorio @dpinter unfortunately i don't have any ios devices to test with, have you tried this:

iOS 12 and later, enable the Access WiFi Information capability for your app in Xcode. When you enable this capability, Xcode automatically adds the Access WiFi Information entitlement to your entitlements file and App ID.

luisAzcuaga commented 5 years ago

Hey guys, I solved this issue stated here https://github.com/tripflex/WifiWizard2/issues/60; the fix is to enable Access Wifi Information under Capabilities.

gdeiorio commented 5 years ago

I had already enabled the Access Wifi Information capability, but the trick worked only in development environment.

Anyway, I solved the issue when I noticed that two different capabilities files were created for development and production: while the development one was created with all the correct capabilities, the production one lacked of almost all of them, so I got to add them manually.

tripflex commented 5 years ago

@luisAzcuaga @gdeiorio thanks for your comments, now that i have an iphone i can start testing with, I can start working on checking if maybe this is a specific issue related to Cordova not setting up the dev & production capability files

kelter-antunes commented 5 years ago

Managed to get it working by adding: mode="add" to all the <config-file entries.

sarpherviz commented 5 years ago

IOS12+ Distribution Certificate Not Available problem solved.

When i run the app in development certificate or adhoc certificate the application is working but when i sign the app with "Distribution Certificate" getConnectedSSID and getConnectedBSSID methods return "Not Available" error.

After this problem platforms->ios-> "ProjectName"->Entitlements-Release.plist and Entitlements-Debug.plist files are different. I fix Entitlements-Release.plist manually and test again , i got same error.

After that i search Entitlements setting in XCODE.

[SOLUTION]: In XCode, at Build Settings tab -> Code Signing Entitlements-> Change Release section to Entitlements-Debug.plist

Build and archive project. screen shot 2019-03-05 at 10 26 57

tripflex commented 5 years ago

@kelter-antunes thanks for reporting this .. i don't see any configuration for that in the Cordova docs, i'm wondering if we should be using edit-config instead of config-file https://cordova.apache.org/docs/en/latest/plugin_ref/spec.html#edit-config

Will need to do a little bit more research into this, as the config-file docs state:

If the specified file does not exist, the tool ignores the configuration change and continues installation.

Other possible method using script hack workaround: https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking/issues/357

also: https://geeklearning.io/how-to-add-specific-configuration-parameters-to-ios-p-list-and-android-manifest/

I do see the mode feature in PhoneGap docs though: http://docs.phonegap.com/phonegap-build/configuring/config-file-element/

So may just add this for now just to test and see if it works

tripflex commented 5 years ago

I do see some issue on cordova-ios regarding the new build system, which may have some affect on this if using older version of cordova-ios prior to 5.0.0: https://github.com/apache/cordova-ios/issues/407

I guess we could try setting min version of cordova-ios to >= 5.0.0 but not sure if that would have any negative affects

57

awaism551 commented 5 years ago

Make sure Entitlements-Debug.plist and Entitlements-Release.plist files have network capabilities like I had to manually add this in release file. `

com.apple.developer.networking.networkextension com.apple.developer.networking.wifi-info

`

tripflex commented 5 years ago

@awaism551 yeah just wondering if this is specific to a version of cordova or something else because in my tests this is my generated Entitlements-Release.plist and Entitlements-Debug.plist:

<plist version="1.0">
  <dict>
    <key>com.apple.developer.networking.HotspotConfiguration</key>
    <true/>
    <key>com.apple.developer.networking.networkextension</key>
    <array/>
    <key>com.apple.developer.networking.wifi-info</key>
    <true/>
  </dict>
</plist>
tripflex commented 5 years ago

@gdeiorio @dpinter @awaism551 @kelter-antunes @luisAzcuaga @sarpherviz Can you guys please run cordova platform version ios and report back the result.

Here's mine: Installed platforms: android 6.2.3 ios 4.5.1

awaism551 commented 5 years ago

Thats my versions: Installed platforms: android 6.2.3 ios 4.3.1 Actually after I updated my xcode to 10.1 from 9.2, I started having issue with this plugin. For debug, I had to go to capabilities section and turn ON Access wifi info and Network Extensions. This updated my Entitlements-Debug.plist file but Entitlements-release.plist was not updating though I also made a release build with xcode. After manually adding in last, I got success

sarpherviz commented 5 years ago

android 7.1.4 ios 4.5.5

dpinter commented 5 years ago

android 7.1.4 ios 4.5.5

Xcode 10.2

angelofan commented 5 years ago

IOS12 +分发证书不可用问题解决了。

当我在开发证书或adhoc证书中运行应用程序时,应用程序正在运行,但是当我使用“分发证书”签署应用程序时,getConnectedSSID和getConnectedBSSID方法返回“Not Available”错误。

在此问题平台 - > ios->“ProjectName” - > Entitlements-Release.plist和Entitlements-Debug.plist文件不同之后。我手动修复了Entitlements-Release.plist并再次测试,我得到了同样的错误。

之后,我在XCODE中搜索Entitlements设置。

[解决方案]:在XCode中,在Build Settings选项卡 - > Code Signing Entitlements-> Change Release部分到Entitlements-Debug.plist

构建和归档项目。 屏幕截图2019-03-05 at 10 26 57

@sarpherviz But why do I reproduce this error in a few days, I have to check this error every time I package it, and I have to use this method to fix it. Is there any permanent solution?