Why might canDetectNetworkStatusChanges return nil?

I’m testing on my Nexus 7 which has a full strength WiFi connection and no problem accessing the internet. However I’m seeing ‘nil’ from network.canDetectNetworkStatusChanges

The same exact code running in the simulator shows ‘true’.

If I inspect the ‘network’ object on device, I see just a few fields:

06-30 21:49:25.987: I/Corona(21479): {

06-30 21:49:25.987: I/Corona(21479):   cancel = <function 1>,

06-30 21:49:25.987: I/Corona(21479):   download = <function 2>,

06-30 21:49:25.987: I/Corona(21479):   getConnectionStatus = <function 3>,

06-30 21:49:25.987: I/Corona(21479):   request = <function 4>,

06-30 21:49:25.987: I/Corona(21479):   setStatusListener = <function 5>,

06-30 21:49:25.987: I/Corona(21479):   upload = <function 6>

06-30 21:49:25.987: I/Corona(21479): }

Whereas if I inspect it on the simulator, it’s a much more complex object, although there’s still no value called canDetectNetworkStatusChanges.

I can’t find anything in the docs or on Google about where this value comes from, but maybe you guys know and can help me troubleshoot. 

Thanks!

Hi moderators, maybe the eng team could take a peek at the source and let us know what the conditions are for this value returning something other than true? I’m currently working around this by manually checking the network connection via socket, but that makes it challenging to monitor for changes in network availability without constantly polling. 

Hi @aaronkarp,

I assume you included the permission for Internet in your build settings? Are other network.* calls working as expected?

Brent

Network status (network reachability) is only available on Mac and iOS platforms. The network.canDetectNetworkStatusChanges call will return nil/false, indicating that the feature is not supported on Android.

We will update our docs to make this clearer.

Polling via socket it is. Thanks Tom! 

Hi moderators, maybe the eng team could take a peek at the source and let us know what the conditions are for this value returning something other than true? I’m currently working around this by manually checking the network connection via socket, but that makes it challenging to monitor for changes in network availability without constantly polling. 

Hi @aaronkarp,

I assume you included the permission for Internet in your build settings? Are other network.* calls working as expected?

Brent

Network status (network reachability) is only available on Mac and iOS platforms. The network.canDetectNetworkStatusChanges call will return nil/false, indicating that the feature is not supported on Android.

We will update our docs to make this clearer.

Polling via socket it is. Thanks Tom!