Coder Social home page Coder Social logo

arsenal942 / cordova-network-manager Goto Github PK

View Code? Open in Web Editor NEW
16.0 16.0 8.0 258 KB

Cordova Network Manager enables Wifi management for both Android and iOS applications within Cordova/Phonegap projects.

License: Other

Objective-C 27.11% Java 72.89%

cordova-network-manager's People

Contributors

arsenal942 avatar coloz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cordova-network-manager's Issues

IOS app breaks when WIFI password is shorter than 8 characters

Prerequisites

Check all boxes if you have done the following:

Issue type

Select all that apply

  • Bug
  • Enhancement
  • Task
  • Question
  • Other

Description

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.

Steps to Reproduce

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.

Versions

Test were made on IONIC built app running on an iPhone (IOS 11).

It does not work in IOS

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

Enable WiFi when calling funcs that require WiFi enabled

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?

Is it possible to list available networks on iOS

Check all boxes if you have done the following:

Issue type

Select all that apply

  • Bug
  • Enhancement
  • Task
  • Question
  • Other

Description

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').

ssidToNetworkId - check test.SSID before test.SSID.equals

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!

Missing ACCESS_COARSE_LOCATION permission

Prerequisites

Check all boxes if you have done the following:

Issue type

Select all that apply

  • [ y] Bug
  • Enhancement
  • Task
  • Question
  • Other

Description

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" />

Steps to Reproduce

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.

Versions

Android version: 8.1.0
Ionic version: 3.19.1
cordovanetworkmanager version: 2.3.0,

Improve documentation

Issue type

  • Task

Description

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.

getCurrentSSID() returns SSID even when not connected (getCurrentBSSID does not exist)

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)

Ios buidl faild in ionic3 when run "ionic cordova build ios".

Prerequisites

Check all boxes if you have done the following:

Issue type

Select all that apply

  • Bug
  • Enhancement
  • Task
  • Question
  • Other

Description

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

Steps to Reproduce

  1. ionic cordova plugin add [email protected]
  2. ionic cordova platform add ios
  3. ionic cordova build ios

Expected behavior: [What you expect to happen]

Actual behavior: [What actually happens]

Reproduces how often: [What percentage of the time does it reproduce?]

Versions

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

Additional Information

I signed this application in my developer account.

Rewrite Android Platform

Issue type

Select all that apply

  • Bug
  • Enhancement
  • Task
  • Question
  • Other

Description

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. =

Versions

This will most likely be a v3 release of the plugin as it is a major revision change.

How do I use getConnectedSSID

Prerequisites

Check all boxes if you have done the following:

Issue type

Select all that apply

  • Bug
  • Enhancement
  • Task
  • Question
  • Other

Description

just looking for documentation...

  1. [First Step]
    I'm using this to successfully add and connect to networks on android and IOS, but don't know how to add this particular function (getConnectedSSID) to test if I'm already connected to the SSID that I want.

I can't find any documentation on how to use this function. Any help would be appreciated.

addNetwork API fails

Issue type

Select all that apply

  • [x ] Bug
  • Enhancement
  • Task
  • Question
  • Other

Description

On Some Android Phones (Samsung J2 2016) addNetwork API fails while trying to connect to open network

Steps to Reproduce

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

Additional Information

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

xCode simulator fail

Issue type

Select all that apply

  • Bug
  • Enhancement
  • Task
  • Question
  • Other

Description

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 ?

androidConnectNetwork requires ssidToDisable

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;
        }
    }

App crashes on iPhone 5 when 'getCurrentSSID' is called

Issue type

Select all that apply

  • Bug
  • Enhancement
  • Task
  • Question
  • Other

Description

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.

Versions

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 

Error compile in IOS

Issue type

Bug

Description

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.