Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1806] Ti.Network.networkType === Ti.Network.NETWORK_MOBILE when in flight mode on iPhone device

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionNot Our Bug
Resolution Date2014-03-12T21:44:13.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsflightmode, ios, mobile, network, networking, online
ReporterMatthias Burbach
AssigneeRitu Agrawal
Created2014-02-17T17:51:38.000+0000
Updated2016-03-08T07:40:42.000+0000

Description

When querying Ti.Network.networkType on a physical device iPhone 5S (iOS 7.0.5) switched to flight mode (airplane mode) the result is Ti.Network.NETWORK_MOBILE and not Ti.Network.NETWORK_NONE as one would expect. I am using Titanium SDK 3.2.1.GA on Mac OS X 10.9.1. The code to test this behaviour is as follows: alert(Ti.Network.getNetworkType()); // prints '2' (NETWORK_MOBILE) when in flight mode If I switch off flight mode and switch off 'Mobile Data' in the Settings app, I get '0' (NETWORK_NONE) as expected. Same issue can be observed in the KitchenSink App on tab Platform, Row Network. Enter page with WIFI on, it displays type: 1, online: true name: WIFI correctly. Then enter into flight mode (but keep Mobile Data switched on). Shortly, the info turns to type: 0, online: false name: NONE, which is correct. Then it updates again, turning to type: 2, online: true name: MOBILE, which is wrong.

Attachments

FileDateSize
Reachability-AirplaneMode-5SecondsLater.png2014-03-12T10:34:25.000+000070331
Reachability-AirplaneMode-Initially.png2014-03-12T10:34:25.000+000052507
Reachability-Cellular.png2014-03-12T10:34:25.000+000063461

Comments

  1. Ritu Agrawal 2014-02-18

    I tried this on an iPhone 4S device and I get 0, as expected, when I switch phone to "Airplane mode". I see "Cellular" option being greyed out when the phone is in airplane mode so could not control these two settings independently. Is the reported behavior specific to iPhone 5s?
  2. Matthias Burbach 2014-02-18

    I will test myself on iPhone 4(S) as soon as I get hold of one. It may be specific to 5(S). Please note on 5S it shows the correct value for a short period of time but then automatically updates to the wrong value. Did you check KitchenSink for a minute or so to make sure it doesn't switch either after a while? Cellular option is greyed out on 5S too when in airplane mode, but on my device it makes all the difference whether I have switched off Cellular before going to airplane mode or not.
  3. Matthias Burbach 2014-02-18

    My colleague has tested the same on iPhone 4 and he found exactly the same false behaviour as I did on iPhone 5S. Please test once more yourself. There is also evidence from other users on http://developer.appcelerator.com/question/162644/tinetworknetworktype--tinetworknetworkmobile-when-in-flight-mode-on-iphone-device
  4. Dave Hudson 2014-02-18

    Just wanted to backup what Matthias is saying and confirm there is definitely an issue with Airplane mode and detecting if a device is online. I'm not seeing this issue on all devices though which is strange. My iPhone 4 running 7.0.2 correctly reports NONE when in Airplane mode. My iPhone 5 running 7.0.3 correctly reports NONE in Airplane mode for about 5 seconds and then reports MOBILE even though it's still in Airplane mode.
  5. Ritu Agrawal 2014-02-18

    I still cannot reproduce it on iPhone 4S device. I will test it on iPhone 5 as soon as I get hold of one.
  6. Eric Wieber 2014-02-20

    After more investigation where we tested both iPhone 5 and 5S running 7.0.3 and 7.1 with Kitchen Sink and a sample app we wrote, we are still not able to reproduce this issue. Could you please provide us with a little more information so that we can dig deeper? [~davehudson], [~matthias.burbach@tui.de] Where are you located? The ticket mentions iOS 7.0.5, which had some different changes for China and the UK, which we may not have. Also, could you please provide some test code or a sample app that you know to show this error. We would like to work with as close to your environment/code/setup as possible. To be clear, we followed these steps:

    Start the app with WIFI and Mobile Data on, and Flight mode off

    Notice that type = 1; name = WIFI

    Turn on Flight mode

    Notice that type = 0; name = NONE

    Wait upwards of 1 min

    Notice no change

    (We also tried turning off Mobile Data first, then turning on Flight mode, then turning Mobile Data on again. We did not see a change from type = 0; name = NONE)
  7. Matthias Burbach 2014-02-21

    Hi, thanks for your work on this! I am located in Germany. My colleague is located in UK and was able to replicate the same false behaviour on his iPhone 4 (see above). The steps you followed look absolutely fine to me. I think KitchenSink as sample app should be fine. Maybe it is worth checking how KitchenSink is built and deployed. I am using (excerpt from tiapp.xml): 3.2.1.GA com.appcelerator.kitchensink KitchenSink 3.2.1 Just pure guesswork, but maybe it has to do with some native event firing from the Cellular sub system depending on various dynamic conditions which have not much to do with the versions of the components we are testing with but more with the current connectivity state of the Cellular? Can you describe how Titanium links to the native APIs for the networkType API?
  8. Dave Hudson 2014-02-25

    Hi Eric, Sorry for the late reply. I am located in the UK also.
  9. Ritu Agrawal 2014-03-03

    It appears related to cellular system as we have not been able to reproduce this issue on multiple devices in US. Would it be possible for you to check this behavior with a simple native application over the same network?
  10. Dave Hudson 2014-03-03

    Sure, I'd be happy to. Just let me know how to install the app you want me to test with.
  11. Dave Hudson 2014-03-11

    Any update on this? This is a major issue for an app we need to release that the majority of target users will use offline in flight mode.
  12. Ritu Agrawal 2014-03-12

    Apple provides a nice Reachability sample application that demonstrates how to use the SystemConfiguration framework to monitor the network state of an iOS device. You should build and run this native application to determine the network state. https://developer.apple.com/library/ios/samplecode/Reachability/Introduction/Intro.html You can use a code snippet like this to check the status (more details on Stack Overflow:http://stackoverflow.com/questions/1083701/how-to-check-for-an-active-internet-connection-on-iphone-sdk)
        Reachability* reachability = [Reachability sharedReachability];
        [reachability setHostName:@"www.example.com"];    // set your host name here
        NetworkStatus remoteHostStatus = [reachability remoteHostStatus];
        
        if(remoteHostStatus == NotReachable) { }
        else if (remoteHostStatus == ReachableViaWiFiNetwork) { }
        else if (remoteHostStatus == ReachableViaCarrierDataNetwork) { }
        
  13. Dave Hudson 2014-03-12

    FYI I downloaded and ran the Reachability app from here in the UK on my iPhone 5 on 7.0.3 Reachability-Cellular.png screenshot shows initial connection on my 3G connection. Reachability-AirplaneMode-Initially.png screenshot shows what happens when you initially set Flight mode. Reachability-AirplaneMode-5SecondsLater.png shows you what happens 5 seconds later. Seems consistent with Appcelerator KitchenSink app.
  14. Eric Wieber 2014-03-12

    Unfortunately, this looks to be an Apple issue, then. The reachability app is correctly showing that you are in airplane mode with wifi disabled. Since the app is giving the same results as KitchenSink and other test apps, this points to the apps correctly displaying the devices abilities. We would recommend that you open an issue in Stack Overflow or open the issue with Apple. I will be closing this ticket as "not our bug".
  15. Dave Hudson 2014-03-17

    Just wanted to add that for anyone else who comes up against this issue it is indeed an Apple issue. Upgrading to iOS 7.1 does fix the problem.
  16. Ritu Agrawal 2014-03-17

    Thanks for sharing this information. Appreciate it.

JSON Source