0

We see a different behavior in the MBS and on our iOS and Android devices.

In the Simulator:

  • navigator.network.connection.type returns the value that is defined in the Simulator menu (this is the old API and is deprecated).
  • navigator.connection.type is undefined (this is the new and soon only official API).

simulator

On the devices:

  • Both return the right value (deprecated API and new API)

The implication is that the following call:

WL.Device.getNetworkInfo(function (networkInfo) {
  alert (networkInfo.ipAddress); 
  }
);
  • Receives an undefined networkInfo object in the MBS.
  • Receives an object with the right value on the devices.
christianmenkens
  • 790
  • 4
  • 22

2 Answers2

1

Both navigator.network.connection.type and navigator.connection.type are supported in the latest Worklight 6.1's Mobile Browser Simulator (Worklight 6.1 uses Cordova 3.1). Up to Cordova 2.3.0, the Connection object was accessed from navigator.network.connection. After Cordova 2.3.0 it was changed to navigator.connection. Navigator.network.connection is still available in Cordova 3.1, but is deprecated and will be eventually removed from Cordova.

nspeete
  • 659
  • 3
  • 10
0

I'm not sure why this works (and not works) in the MBS, but please do note that the WL.Device.getNetworkInfo API method is supported only in iOS and Android.

Idan Adar
  • 44,156
  • 13
  • 50
  • 89
  • since navigator.connection.type is new, we assume that this "new" API is not yet implemented in the Cordova Simulation of the Simulator. And that only the "old" API navigator.network.connection.type is currently implemented. - it should work in the Simulator, because there are the options to change the Network connection settings in the left menu bar of the Simulator. The call to navigator.network.connection.type returns exactly what is configured in the left menu bar! – christianmenkens Aug 27 '13 at 21:56
  • I have notified the feature developers. – Idan Adar Aug 28 '13 at 07:14