问题
I'm using cordova-1.6.1 on Mac Lion with Xcode 4.3.1. I'm getting following error
CordovaApp[322:13403] [INFO] Error in success callback: NetworkStatus0 = TypeError: 'undefined' is not a function
when following line is executed.
navigator.network.isReachable("phonegap.com", reachableCallback, {});
A function is defined as follows
function reachableCallback(reachability) {
var networkState = reachability.code;
alert('Connection type: ' + networkState + ' - ' + reachability.message);
}
I'm unable to figure this out for a quite some time. Please help
Adam
回答1:
The isReachable method has been deprecated out of PhoneGap. You are better off looking at the new Network features like the online and offline events. As well looking at:
navigator.network.connection.type
Will tell you what type of network connection you currently have or None if there is no connection.
来源:https://stackoverflow.com/questions/10371986/networkstatus0-typeerror-undefined-is-not-a-function