Ibm mobilefirst navigator.connection在Worklight 6中不可用

Ibm mobilefirst navigator.connection在Worklight 6中不可用,ibm-mobilefirst,Ibm Mobilefirst,我需要从我的应用程序检查网络连接。 我发现cordova提供了以下功能: 但是当我在Chrome的预览版中测试我的应用程序时,当代码达到 “从我的应用程序返回navigator.connection.type.toString();” 我看到以下错误: “无法读取未定义的属性“type” 如果在Chrome的控制台中,我编写了navigator,Chrome会告诉我可能的选项,而连接不是其中之一。 同样的应用程序在Android emulator中测试,运行良好 我使用navigator.geo

我需要从我的应用程序检查网络连接。 我发现cordova提供了以下功能:

但是当我在Chrome的预览版中测试我的应用程序时,当代码达到 “从我的应用程序返回navigator.connection.type.toString();” 我看到以下错误:

“无法读取未定义的属性“type”

如果在Chrome的控制台中,我编写了navigator,Chrome会告诉我可能的选项,而连接不是其中之一。 同样的应用程序在Android emulator中测试,运行良好

我使用navigator.geolocation获取位置并显示地图,它工作正常


谢谢,Giovanni

您可以使用
WL.Device.getNetworkInfo
从Worklight应用程序获取网络信息。
文档可在

上获得。请查看模拟器存在问题-我假设您正在使用该问题-因为Worklight Studio中的预览会启动移动模拟器


navigator.network.connection.type和
最新Worklight 6.1的移动浏览器模拟器支持navigator.connection.type(Worklight 6.1使用Cordova 3.1)。在Cordova 2.3.0之前,连接对象是从navigator.network.Connection访问的。在Cordova 2.3.0之后,它被更改为navigator.connection。Navigator.network.connection在Cordova 3.1中仍然可用,但已弃用,最终将从Cordova中删除。

这应该是对上述问题的评论,而不是回答。请注意,由于上述模拟器存在问题,此调用仅在设备上有效,而不在可从WL Studio启动的预览模拟器中有效。