Ons Notification Yes no
-
That’s interesting, looks like
script
tag makes that effect.@Leonardo-Augusto If you are using beta.7 you can use promises for
ons.notification
. I think it’s much easier.
-
@munsterlander checking internet
-
@Fran-Diox Yes it’s easy ! Onsen is cool . I guess my problem was here: index==0
But now , I found a problem with my code to check internet. Lol. i can’t to write my .js lol but i have made effects here
-
@Leonardo-Augusto After actually reading the docs (HA!), I saw what the issue is. I have updated the code last posted. Try it now.
https://cordova.apache.org/docs/en/latest/cordova-plugin-network-information/index.html
-
@Fran-Diox You are right. That pesky script tag was causing the issues. I removed it in my code and BOOM! The code is bright! So bright you say, yes, so I bright I have to wear shades! :sunglasses:
-
@munsterlander ahahaha do you have a class to teach me?
<script src="angular-onsenui.js"></script> <script> document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { checkConnection(); } function checkConnection() { var networkState = navigator.connection.type; var states = {}; states[Connection.NONE] = 'No network connection'; if (states[networkState] == 'No network connection') { ons.notification.confirm({ message: 'Do you want to change your settings?', title: 'No internet connection available', buttonLabels: ['Yes', 'No'], animation: 'none', primaryButtonIndex: 1, cancelable: false, callback: function (index) { if (index == 0) { if (typeof cordova.plugins.settings.openSetting != undefined) { cordova.plugins.settings.openSetting("wifi", function () { console.log("Open the settings") }, function () { console.log("error to acess") }); } } else if (index == 1) { navigator.app.exitApp(); } } }); } } </script>
Reputation 13. Yes i’m not good lol But you saved my code!
-
@Leonardo-Augusto Glad it is working!
-
This post is deleted!
-
@munsterlander thanks again.
-
@munsterlander looking to your code modifications i agree that isn’t necessary
to keep part of the code like:states[Connection.WIFI] = 'WiFi connection'; states[Connection.CELL_2G] = 'Cell 2G connection'; states[Connection.CELL_3G] = 'Cell 3G connection'; states[Connection.CELL_4G] = 'Cell 4G connection'; states[Connection.CELL] = 'Cell generic connection';
When i’m checking just my connection ( If i have or not)
I just have added other navigator.app.exitApp(); for one reason:
if the user access the settings but cancel for any reason , could be possible to return to the application.if (index == 0) { if (typeof cordova.plugins.settings.openSetting != undefined) { cordova.plugins.settings.openSetting("wifi", function () { console.log("Acessando suas configurações") }, function () { console.log("Erro para alterar configurações, tente manualmente!") }); } } else if (index == 1) { navigator.app.exitApp(); } navigator.app.exitApp();