arsenal942 / cordova-network-manager Goto Github PK
View Code? Open in Web Editor NEWCordova Network Manager enables Wifi management for both Android and iOS applications within Cordova/Phonegap projects.
License: Other
Cordova Network Manager enables Wifi management for both Android and iOS applications within Cordova/Phonegap projects.
License: Other
Check all boxes if you have done the following:
Select all that apply
First of all: Great plugin! Very handy and useful!
The IOS call to connect() breaks the IOS app whenever the user inserts a WIFI password shorter than 8 characters.
It's well know that the WPA/WPA2 password length should be at least 8 character long and the app developer can easily prohibit the user for attempting such a connection.
But it would be nice to have a fail callback so the app won't break in case the developer forgets to verify the password length.
On an IOS device try to connect on an WIFI network with a password shorter than 8 characters.
Expected behavior: [What you expect to happen]
Connect to a WIFI network.
Actual behavior: [What actually happens]
2018-04-23 17:18:31.209909-0300 EasyKey[3954:1944346] [] -[NEHotspotConfiguration valid:726 NEHotspotConfiguration invalid WPA/WPA2 passphrase length.
(lldb)
Reproduces how often: [What percentage of the time does it reproduce?]
Everytime.
Test were made on IONIC built app running on an iPhone (IOS 11).
I am currently using IOS 11.2.2 and Xcode 9.2, when trying to connect to the wifi it does not return an error but it does not connect either.
I tried with the wifi on and with the wifi off
Any reason for not having code in the functions/methods that require WiFi to be enabled, to automatically enable it?
I get that it's possible to do, but right now, I have to first check if WiFi is not enabled, and then Enable it, and then I can call something like addNetwork
... why not just have code in the addNetwork
and other functions that require wifi to be enabled, to automatically enable it if it's not already enabled?
show the error
cordovanetworkmanager\cordovaNetworkManager.java:66: Error: The WIFI_SERVICE must be looked up on the Application context or memory will leak on devices < Android N. Try changing cordova.getActivity() to cordova.getActivity().getApplicationContext() [WifiManagerLeak]
hope update the plugin to Arduino N
Check all boxes if you have done the following:
Select all that apply
Is it possible to list available networks on iOS? I would like to see the networks around the user device and offer him to connect if any network name matches a specific pattern (for instance starts with 'mydevice').
After pulling out my hair for hours, the error I kept getting was:
Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
Which I tracked down to this bit of code:
List<WifiConfiguration> currentNetworks = wifiManager.getConfiguredNetworks();
int networkId = -1;
// For each network in the list, compare the SSID with the given one
for (WifiConfiguration test : currentNetworks) {
if ( test.SSID.equals(ssid) ) {
networkId = test.networkId;
}
}
Which I ended up figuring out the issue was related to some null WiFi object (or one missing data) that was added by the Cerberus Android app (https://www.cerberusapp.com/), and only after I removed that entry did I no longer receive this error.
Maybe a good idea to just check if test.SSID
is available and not null before checking .equals
? I honestly don't know how that got added, but just in case of instances where some erroneous wifi config exists, would be good to check first to prevent these errors.
Thanks for the great plugin though!
Check all boxes if you have done the following:
Select all that apply
getScanResults function doesn't work without androids ACCESS_COARSE_LOCATION permission set in the manifest. I believe this permission is missing in the plugin.xml file.
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
Try and request ACCESS_COARSE_LOCATION using "cordova-plugin-android-permissions" v1.0.0. This returns {"hasPermission":false}
Try and run getScanResults on an android device running android version 8.1.0. This will return an empty array, and the ADB link states "WifiPermissionsUtil: Denied: no location permission".
To solve, add to the android manifest.
Android version: 8.1.0
Ionic version: 3.19.1
cordovanetworkmanager version: 2.3.0,
There is a task for myself to improve the documentation so that every function is adequately explained. This will include code examples that will give users an in depth insight into how a function operates.
Seems that getCurrentSSID
returns an SSID even when it's not connected to that network, which calls the getConnectedSSID
see: https://stackoverflow.com/questions/41366481/android-why-wifimanager-getconnectioninfo-getssid-return-disconnected-ssid
https://developer.android.com/reference/android/net/wifi/WifiInfo.html#getSSID()
Trying to use this to handle the ssidToDisconnect
Reading the docs it seems that getCurrentBSSID
would work (as it should return null if not connected), but even though that method is available, it does not exist in main java file (which I found is actually related to the WiFiWizard, not your edits)
Check all boxes if you have done the following:
Select all that apply
Ios buidl faild in ionic3 when run "ionic cordova build ios".Then I get the following error.
(truncated) ... cd /Users/emcoo-13/www/hr-api/src/client/frontend-mobile/platforms/ios/CordovaLib
export
PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Users/emcoo-13/www/hr-api/src/client/frontend-mobile/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/emcoo-13/Library/Android/sdk:/Users/emcoo-13/Library/Android/sdk/tools:/Users/emcoo-13/Library/Android/sdk/platform-tools"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -static
/Users/emcoo-13/Library/Developer/Xcode/DerivedData/OA-cpypdogdzjpnuehebhzrcrhdubeu/Build/Intermediates/ArchiveIntermediates/OA/IntermediateBuildFilesPath/CordovaLib.build/Debug-iphoneos/CordovaLib.build/Objects-normal/armv7/libCordova.a
/Users/emcoo-13/Library/Developer/Xcode/DerivedData/OA-cpypdogdzjpnuehebhzrcrhdubeu/Build/Intermediates/ArchiveIntermediates/OA/IntermediateBuildFilesPath/CordovaLib.build/Debug-iphoneos/CordovaLib.build/Objects-normal/arm64/libCordova.a
-o
/Users/emcoo-13/Library/Developer/Xcode/DerivedData/OA-cpypdogdzjpnuehebhzrcrhdubeu/Build/Intermediates/ArchiveIntermediates/OA/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/libCordova.a
Strip
/Users/emcoo-13/Library/Developer/Xcode/DerivedData/OA-cpypdogdzjpnuehebhzrcrhdubeu/Build/Intermediates/ArchiveIntermediates/OA/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/libCordova.a
cd /Users/emcoo-13/www/hr-api/src/client/frontend-mobile/platforms/ios/CordovaLib
export
PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Users/emcoo-13/www/hr-api/src/client/frontend-mobile/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/emcoo-13/Library/Android/sdk:/Users/emcoo-13/Library/Android/sdk/tools:/Users/emcoo-13/Library/Android/sdk/platform-tools"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip -S
/Users/emcoo-13/Library/Developer/Xcode/DerivedData/OA-cpypdogdzjpnuehebhzrcrhdubeu/Build/Intermediates/ArchiveIntermediates/OA/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/libCordova.a
SetOwnerAndGroup emcoo-13:staff
/Users/emcoo-13/Library/Developer/Xcode/DerivedData/OA-cpypdogdzjpnuehebhzrcrhdubeu/Build/Intermediates/ArchiveIntermediates/OA/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/libCordova.a
cd /Users/emcoo-13/www/hr-api/src/client/frontend-mobile/platforms/ios/CordovaLib
export
PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Users/emcoo-13/www/hr-api/src/client/frontend-mobile/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/emcoo-13/Library/Android/sdk:/Users/emcoo-13/Library/Android/sdk/tools:/Users/emcoo-13/Library/Android/sdk/platform-tools"
/usr/sbin/chown -RH emcoo-13:staff
/Users/emcoo-13/Library/Developer/Xcode/DerivedData/OA-cpypdogdzjpnuehebhzrcrhdubeu/Build/Intermediates/ArchiveIntermediates/OA/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/libCordova.a
SetMode u+w,go-w,a+rX
/Users/emcoo-13/Library/Developer/Xcode/DerivedData/OA-cpypdogdzjpnuehebhzrcrhdubeu/Build/Intermediates/ArchiveIntermediates/OA/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/libCordova.a
cd /Users/emcoo-13/www/hr-api/src/client/frontend-mobile/platforms/ios/CordovaLib
export
PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Users/emcoo-13/www/hr-api/src/client/frontend-mobile/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/emcoo-13/Library/Android/sdk:/Users/emcoo-13/Library/Android/sdk/tools:/Users/emcoo-13/Library/Android/sdk/platform-tools"
/bin/chmod -RH u+w,go-w,a+rX
/Users/emcoo-13/Library/Developer/Xcode/DerivedData/OA-cpypdogdzjpnuehebhzrcrhdubeu/Build/Intermediates/ArchiveIntermediates/OA/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/libCordova.a
=== BUILD TARGET OA OF PROJECT OA WITH CONFIGURATION Debug ===
Check dependencies
Signing for "OA" requires a development team. Select a development team in the project editor.
Code signing is required for product type 'Application' in SDK 'iOS 10.3'
** ARCHIVE FAILED **
The following build commands failed:
Check dependencies
(1 failure)
Error: Error code 65 for command: xcodebuild with args:
-xcconfig,/Users/emcoo-13/www/hr-api/src/client/frontend-mobile/platforms/ios/cordova/build-debug.xcconfig,-workspace,OA.xcworkspace,-scheme,OA,-configuration,Debug,-destination,generic/platform=iOS,-archivePath,OA.xcarchive,archive,CONFIGURATION_BUILD_DIR=/Users/emcoo-13/www/hr-api/src/client/frontend-mobile/platforms/ios/build/device,SHARED_PRECOMPS_DIR=/Users/emcoo-13/www/hr-api/src/client/frontend-mobile/platforms/ios/build/sharedpch
Expected behavior: [What you expect to happen]
Actual behavior: [What actually happens]
Reproduces how often: [What percentage of the time does it reproduce?]
cli packages:
@ionic/cli-utils : 1.12.0
ionic (Ionic CLI) : 3.12.0
global packages:
cordova (Cordova CLI) : 7.1.0
local packages:
@ionic/app-scripts : 3.1.0
Cordova Platforms : android 6.3.0 ios 4.5.4
Ionic Framework : ionic-angular 3.9.2
System:
Android SDK Tools : 26.1.1
ios-deploy : 1.9.2
Node : v8.6.0
npm : 5.7.1
OS : macOS Sierra
Xcode : Xcode 8.3.3 Build version 8E3004b
Misc:
backend : legacy
I signed this application in my developer account.
Select all that apply
Since the OG WifiWizard is outdated and a bit rubbish, I will begin a rewrite of the Android platform and the various functions.
I will start with a modularity based approach whereby a user has to chain together multiple methods to perform certain functionality before creating larger methods which automatically do this chaining. =
This will most likely be a v3 release of the plugin as it is a major revision change.
Check all boxes if you have done the following:
Select all that apply
just looking for documentation...
I can't find any documentation on how to use this function. Any help would be appreciated.
Select all that apply
On Some Android Phones (Samsung J2 2016) addNetwork API fails while trying to connect to open network
Run Following coode
var config = cordovaNetworkManager.formatWifiConfig('se3110000312');
cordovaNetworkManager.addNetwork(config, function win() {}, function fail() {console.log('Failed to add WiFi Network: ');}
Expected behavior:
function win should have been called
Actual behavior:
function fail is called.
Reproduces how often:
Consistently on specific phone model.
Plugin version: 2.5.0
LOGS
07-25 11:56:05.539 10689 10754 D cordovaNetworkManager: cordovaNetworkManager: addNetwork entered.
07-25 11:56:05.780 10689 10754 E JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 68)
07-25 11:56:05.790 10689 10754 W WifiManager: Caught RemoteException trying to get configured networks: android.os.DeadObjectException: Transaction failed on small parcel; remote process probably died
07-25 11:56:05.790 10689 10754 D cordovaNetworkManager: Attempt to invoke interface method 'java.util.Iterator java.util.List.iterator()' on a null object reference
07-25 11:56:05.790 10689 10754 W PluginManager: THREAD WARNING: exec() call to cordovaNetworkManager.addNetwork blocked the main thread for 244ms. Plugin should use CordovaInterface.getThreadPool().
07-25 11:56:05.790 10689 10754 W CordovaPlugin: Attempted to send a second callback for ID: cordovaNetworkManager258703579
07-25 11:56:05.790 10689 10754 W CordovaPlugin: Result was: "Invalid action"
07-25 11:56:05.800 10689 10689 D SystemWebChromeClient: file:///android_asset/www/build/main.js: Line 1 : Failed to add WiFi Network: se3110000312
07-25 11:56:05.800 10689 10689 I chromium: [INFO:CONSOLE(1)] "Failed to add WiFi Network: se3110000312", source: file:///android_asset/www/build/main.js (1)
07-25 11:58:55.695 1202 1540 I InputDispatcher: Delivering touch to (10689): action: 0x0, toolType: 1
07-25 11:58:55.695 10689 10689 D ViewRootImpl: ViewPostImeInputStage processPointer 0
07-25 11:58:55.835 1202 1540 I InputDispatcher: Delivering touch to (10689): action: 0x1, toolType: 1
07-25 11:58:55.835 10689 10689 D ViewRootImpl: ViewPostImeInputStage processPointer 1
Select all that apply
This will not run in the xCode simulator and requires a physical iOS device to be connected to the machine when building. If you don't attach a physical device, the build will fail. It seems the problem from wifiwizard is still here ..
Is there any way we can get past this ? Won't this get blocked in the iOS app store ?
Regarding the androidConnectToNetwork
though, it looks like an SSID to disconnect from MUST be passed otherwise it will error out, so from what I can tell, that's not an "optional" argument, which shouldn't it be?
My thought on this would be to check if WiFi is already connected, and if so, get the current SSID, and use that for the currentNetworkId
... right?
private boolean androidConnectNetwork(CallbackContext callbackContext, JSONArray data) {
Log.d(TAG, "cordovaNetworkManager: connectNetwork entered.");
if(!validateData(data)) {
callbackContext.error("cordovaNetworkManager: connectNetwork invalid data");
Log.d(TAG, "cordovaNetworkManager: connectNetwork invalid data.");
return false;
}
String ssidToConnect = "";
String currentSSID = "";
try {
ssidToConnect = data.getString(0);
currentSSID = data.getString(1);
}
catch (Exception e) {
callbackContext.error(e.getMessage());
Log.d(TAG, e.getMessage());
return false;
}
int networkIdToConnect = ssidToNetworkId(ssidToConnect);
int currentNetworkId = ssidToNetworkId(currentSSID);
if (networkIdToConnect >= 0 && currentNetworkId >= 0) {
// We disable the network before connecting, because if this was the last connection before
// a disconnect(), this will not reconnect.
wifiManager.disableNetwork(currentNetworkId);
wifiManager.enableNetwork(networkIdToConnect, true);
SupplicantState supState;
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
supState = wifiInfo.getSupplicantState();
callbackContext.success(supState.toString());
return true;
}else{
callbackContext.error("cordovaNetworkManager: Cannot connect to network");
return false;
}
}
The connectNetwork success callback should only fire when we have successfully connected to the specified network. Rather than the client having to implement a timeout function, the plugin should handle this itself.
Will implement shortly.
Select all that apply
App crashes on iPhone 5 when 'getCurrentSSID' is called. The crash message I get in hockeyApp is
objc_msgSend() selector name: isProxy
On iPhone 6s or X works well.
Plugin version: 2.5.0
Ionic info:
cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
global packages:
cordova (Cordova CLI) : 8.0.0
Gulp CLI : not installed globally
local packages:
@ionic/app-scripts : 3.0.0
Cordova Platforms : ios 4.5.4
Ionic Framework : ionic-angular 3.9.2
System:
ios-deploy : 1.9.2
Node : v10.4.0
npm : 6.1.0
OS : macOS High Sierra
Xcode : Xcode 9.4 Build version 9F1027a
Bug
Hello, first thank you for your work.
When compiling for IOS with ionic cordova run ios
, the compilation returns an error of the plugin:
Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_NEHotspotConfigurationManager", referenced from: objc-class-ref in cordovaNetworkManager.o "_OBJC_CLASS_$_NEHotspotConfiguration", referenced from: objc-class-ref in cordovaNetworkManager.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
ionic -v -> 3.19.0
cordova -v -> 7.1.0
Another question I have is: how do I import the plugin into ionic 3 with typescript?
Thank you very much for your help and your great work.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.