Open Sumbersss opened 5 years ago
@Sumbersss i'm honestly not sure, what errors or issues are you getting? Please provide specifics so we can look into this for you
I can't see the error because it's at the early launch of my application but i can show you a part of the logic. Also, can I disable the auto ask for activation of the wifi ?
Here is the code.
$ionicPlatform.ready(function () {
try {
if (window.cordova) {
function successGetSSID(ssid) {
if (_.includes(ssid, DISPENSER_CONFIG.SSID_NAME))
live.init();
else {
checkAutoLogin();
}
}
wifiManager.getConnectedSSID().then(successGetSSID, checkAutoLogin);
} else {
checkAutoLogin();
}
} catch (e) {
console.error("error occured : ", e);
}
});
with getConnectedSSID
var getConnectedSSID = function() {
return ($q(function(resolve, reject) {
if (window.cordova) {
if (ionic.Platform.isAndroid()) {
WifiWizard2.requestPermission()
.then(function() {
WifiWizard2.getConnectedSSID()
.then(function(ssid) {
resolve(ssid);
}, function(fail) {
reject(fail);
});
}, function(fail) {
reject();
})
}
else if (ionic.Platform.isIOS()) {
WifiWizard2.getConnectedSSID()
.then(function(ssid) {
resolve(ssid);
}, function(fail) {
reject(fail);
});
}
}
else
reject();
}));
};
First of all, have you ever tried to code properly ??? Wtf is this shit
Check the code after 2min of thinking like a normal human being
var getConnectedSSID = function () {
return $q(function (resolve, reject) {
if (!window.cordova) {
reject();
}
function connectWithWizard() {
WifiWizard2.getConnectedSSID().then(onSuccess, onReject);
}
function onSuccess(ssid) {
resolve(ssid);
}
function onReject(fail) {
reject(fail);
}
if (ionic.Platform.isAndroid()) {
WifiWizard2.requestPermission().then(connectWithWizard, onReject);
} else if (ionic.Platform.isIOS()) {
connectWithWizard();
}
});
};
For the early launch -> chrome://inspect
Under Android versions below 6.0 your WifiWizard2.requestPermission()
will not return a result (when I tried it, the promise kept being stuck on 'pending' indefinitely).
The simple reason for this is that below Android 6 there were no permission dialogues at all. You can mitigate this by only making this call after checking the Android version is 6 or above.
Not sure if this should be considered as a bug worth reporting.
<!--
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
I have a small question, what is the min version of Android supporting this plugin ? On Android 5.0 the plugin doesn't work, that means i don't have the automagic demand to activate the wifi, so my application do not launch (because it's testing at the launch on which wifi i am connected)
Steps to Reproduce
Versions
wifizard2: 3.1.0 Android: 5.0
Additional Information