NetworkStatus0 = TypeError: 'undefined' is not a function

牧云@^-^@ 提交于 2020-02-08 04:16:11

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!