- This topic has 12 replies, 5 voices, and was last updated 11 years, 9 months ago by
support-michael.
-
AuthorPosts
-
upasanaMemberHi
The following function , works properly for android builds, but not for iOS builds. What could be the issue?
function checkConnection() { network = navigator.network.connection.type; var states = {}; states[Connection.UNKNOWN] = 'Unknown connection'; states[Connection.ETHERNET] = 'Ethernet connection'; 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.NONE] = 'No network connection'; alert('Connection type: ' + states[network]); }
Thanks.
support-michaelKeymaster1) What version of MobiOne are you using?
2) If you are using MobiOne 2.5M1 what version of Cordova are you using?
3) What ios device and OS version are you testing?
4) Are you waiting for the the deviceready callback before using the cordova api?
upasanaMemberHi
1. I am using MobiOne 2.3.2
2. No separate cordova.js has been included. In android the built in version worked properly.
3. ipad version 6.1
4. yes the checking is done after ondeviceready callback.Regards
Upasana
support-michaelKeymasterIs the ipad support cellular (3G/4G) connectivity or is it only wifi support?
upasanaMemberHi
Thanks for the reply. It only supports wifi.
Regards
Upasana
support-octavioMemberHi upasana,
Can you share more details about what is the problem or error message that you get? does it fail to show alert, shows alert with incorrect message, etc? one or two screenshots would be helpful too.
upasanaMemberHi
I have attached the source files. The apk is also there that works perfectly on android. But on iOS compilation the same thing does not work.
Thanks
Upasana
Attachments:
You must be logged in to view attached files.
MassimilianoFabbriMemberHave you seen the navigator.network.connection deprecation message ?
May using navigator.connection It will work.
Please give me feedback because I’m using the same code but I ca’nt test on IOS
Thanks,
Max.
upasanaMemberHi
I tried out with navigator.connection. Didn’t work on ios.
Thanks
Upasana
MassimilianoFabbriMemberPlease Octavio,
keep us up to date for this behaviour.
Thanks,
Max
VickyMemberhere is the code where it works for an ios. hope this might help…
/** * Notification that the UI is about to transition to a new screen. * Perform custom prescreen-transition logic here. * @param {String} currentScreenId * @param {String} targetScreenId * @returns {boolean} true to continue transtion; false to halt transition */ phoneui.prePageTransition = function(currentScreenId,targetScreenId){ // add custom pre-transition code here // return false to terminate transition return true; } /** * Notification that the UI has transitioned to a new screen. * * @param {String} newScreenId */ phoneui.postPageTransition = function(newScreenId) { } /** * Notification that device orientation has changed. * * @param {String} newOrientation */ phoneui.postOrientationChange = function(newOrientation) { } /** * Called when document is loaded. */ phoneui.documentReadyHandler = function() { document.addEventListener("deviceready", onDeviceReady, false); } function onDeviceReady() { checkConnection(); } function checkConnection() { var networkState = navigator.connection.type; var states = {}; states[Connection.UNKNOWN] = 'Unknown connection'; states[Connection.ETHERNET] = 'Ethernet connection'; states[Connection.WIFI] = 'Wi-Fi connection'; states[Connection.CELL_2G] = 'Cell 2G connection'; states[Connection.CELL_3G] = 'Cell 3G connection'; states[Connection.CELL_4G] = 'Cell 4G connection'; states[Connection.NONE] = 'No network connection'; phoneui.alert('You are using '+ states[networkState], null, 'Connection Type'); }
support-michaelKeymasterThanks for sharing the example project.
The navigator.app.loadUrl() is not a cross platform api. It was only implemented on android. See the following info and there are many other references to the same issue:
http://stackoverflow.com/questions/13803020/navigator-app-undefinedIn the latest MobiOne 2.5 milestone-1 you have access to Cordova/PhoneGap 2.9 which includes the cross platform InAppBrowser api.
support-michaelKeymasterI also successfully retested the navigator.connection api from you example on ipad1/ios4.3(wifi only) and iphone5/ios6.
-
AuthorPosts