Skip to content

Commit

Permalink
add handling in JS for iOS to connect to open network #30
Browse files Browse the repository at this point in the history
  • Loading branch information
tripflex committed Aug 29, 2018
1 parent 8016cbd commit 94dc9d0
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions www/WifiWizard2.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,43 @@

var WifiWizard2 = {

iOSConnectNetwork: function (ssid, ssidPassword) {
/**
* Connect to network on iOS device
* @param ssid
* @param ssidPassword Password if connecting to WPA/WPA2 network (omit or use false to connect to open network)
* @returns {Promise}
*/
iOSConnectNetwork: function (ssid, ssidPassword) {

return new Promise(function (resolve, reject) {
if( ssidPassword === undefined || ! ssidPassword || ssidPassword.length < 1 ){
// iOS connect open network
cordova.exec(resolve, reject, "WifiWizard2", "iOSConnectOpenNetwork", [{ "Ssid": ssid }]);

if( ssidPassword !== undefined && ssidPassword.length > 0 && ssidPassword.length < 8 ){
} else if( ssidPassword !== undefined && ssidPassword.length > 0 && ssidPassword.length < 8 ){
// iOS pass length does not meet requirements (min 8 chars for WPA/WPA2)
reject("WPA/WPA2 password length must be at least 8 characters in length!");
return;
}

cordova.exec(resolve, reject, "WifiWizard2", "iOSConnectNetwork", [
} else {
// iOS connect to WPA/WPA2 network
cordova.exec(resolve, reject, "WifiWizard2", "iOSConnectNetwork", [
{
"Ssid": ssid,
"Password": ssidPassword
"Ssid": ssid,
"Password": ssidPassword
}]
);
);
}

});

},

iOSDisconnectNetwork: function (ssid) {
/**
* Disconnect from SSID on iOS device
* @param ssid
* @returns {Promise}
*/
iOSDisconnectNetwork: function (ssid) {
return new Promise(function (resolve, reject) {

cordova.exec(resolve, reject, "WifiWizard2", "iOSDisconnectNetwork", [
Expand Down

0 comments on commit 94dc9d0

Please sign in to comment.