Notice: The Monaca & Onsen UI Community Forum is shutting down.
For Onsen UI bug reports, feature requests and questions, please use the Onsen UI GitHub issues page. For help with Monaca, please contact Monaca Support Team.
Thank you to all our community for your contributions to the forum. We look forward to hearing from you in the new communication channels.
Check internet connection state and app installed
-
Hello devs ! Does anyone knows how can i check the internet connection before the command bellow?
Example i want to show an alert , "No internet connection available"
or check if facebook is installed " “The Facebook app is not available on your device”I’m using PhoneGap Social Sharing plugin and visual studio
https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin<div class="action-label" onclick="window.plugins.socialsharing.shareViaFacebook('hi my custom message to share ', null /* img */, ' http://www.mywebsite.com/' /* url */, function () { console.log('share ok') }, function (errormsg) { alert(errormsg) })">
-
I haven’t tested this personally, but you should be able to use
window.navigator.offline
below is the reference doc link:https://developer.mozilla.org/en-US/docs/Web/API/NavigatorOnLine/onLine
Here is how to test this periodically with a JSFiddle:
Here is the code for jQuery but should be adaptable to JS or Angular:
var connectionStatus = false; $(document).on('pagebeforeshow', '#index', function () { setInterval(function () { connectionStatus = navigator.onLine ? 'online' : 'offline'; }, 100); $(document).on('click', '#check-connection', function () { alert(connectionStatus); }); });
-
Thanks . I’ll check your tip now. Looking for the documents of this plugin , i found
If Facebook, Twitter, Instagram, WhatsApp, SMS or Email is not available, the errorCallback is called with the text ‘not available’.
But i’m not receiving … not available
But this message
-
Unfortunately, I am not familiar with that plugin. I would recommend posting to their help section for specifics with the error.
-
The plugin developer told me .
If you use shareViaSMS, shareViaEmail, etc you’ll get ‘not available’ as the doc says, but if you do shareVia or canShareVia the plugin will respond with what you found; a list of packages you can share to instead
So this is the solution.
https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin/issues/531
-
@Leonardo-Augusto Awesome! Glad you were able to get a solution.
-
@munsterlander yes thanks . I’ve sent you an e-mail
-
@Leonardo-Augusto Hmm, I haven’t received it. Was it the reply to mine or a new one to my cfuze account? Either way, thank you again for any insight!
P.S., you wouldn’t be a Java or cordova plugin expert would you?
-
@munsterlander said:
Hmm, I haven’t received it. Was it the reply to mine or a new one to my cfuze account? Either way, thank you again for any insight!
P.S., you wouldn’t be a Java or cordova plugin expert would you?
Was a reply about your email … but seems i have some delay today. I’ll send you again hope you receive soon (few hours lol crazy)
-
@Leonardo-Augusto Ok! Sometimes Outlook goes nuts on my side so I just wanted to figure out what was what.
Thanks again!!