Search Unity

  1. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  2. Unity 2017.2 beta is now available for download.
    Dismiss Notice
  3. Unity 2017.1 is now released.
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  6. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice

Internet Reachability Verifier - Support Thread

Discussion in 'Assets and Asset Store' started by tonic, Jun 19, 2014.

  1. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    309
    Hi @sayangel, please take a look in the Examples folder (under InternetReachabilityVerifier). There you can find example scenes, but also example script code.

    For a simple C# code example with comments look at the SkeletonIRVExample.cs. The script assumes you make a GameObject and add an InternetReachabilityVerifier component to it, and also the SkeletonIRVExample component. In the script code you can see that in the Start() method there are these two code lines:
    Code (CSharp):
    1.         internetReachabilityVerifier = GetComponent<InternetReachabilityVerifier>();
    2.         internetReachabilityVerifier.statusChangedDelegate += netStatusChanged;
    3.  
    Above the Start() method there's void netStatusChanged(InternetReachabilityVerifier.Status newStatus) method which will be called when there's a change in the network status.

    Try & run the included example scenes and study how they are set up and the included code. Hope this helps!
     
  2. sayangel

    sayangel

    Joined:
    Apr 11, 2014
    Posts:
    6
    hi @tonic I did try out the SkeletonIRVExample before posting yesterday but I didn't see a response when turning my WiFi on and off. I was expecting something to be output to the console, but nothing happened.

    Thanks!
     
  3. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    309
    Can you tell me did you test this in Unity Editor on a desktop machine, or on a mobile device?

    If you run the very simple SkeletonIRVExample scene in Unity Editor, then you will only get "InternetReachabilityVerifier.Status: NetVerified" message to the console. And when you're testing on a desktop machine, it never totally "lose the network hardware" (LAN is always available even if you turn WiFi on/off). So there won't be notification for that. On a mobile device it is possible to actually lose possibility to even try to make connections, so you will get status change for that.

    The main point of this asset is to actually test if the internet access works -- that is, it will tell you it is functional once user has for example logged in a public wifi (while Unity's own Application.internetReachability will say network works even if the only thing you can reach is a login screen for the public wifi, for example).

    But this asset will not actively monitor if the network is "still up". That would be actually impolite towards user, since doing that reliably would mean doing some network traffic all the time to test if it works, and that could cause extra cost for users when using a mobile subscription with limited amount of bandwidth/traffic.

    So, after you notice the internet access is verified and start doing something - e.g. make a WWW connection somewhere, you should still monitor the return status yourself. It's possible the network is lost middle of operation, or that even if internet access generally works, that particular server does not. If you detect an error situation when you do networking, then you can ask IRV to re-verify the internet (see forceReverification in the skeleton script).

    Hope this helps you!
     
  4. SoftwareLogicAU

    SoftwareLogicAU

    Joined:
    Mar 30, 2014
    Posts:
    34
    Hi,

    I am developing a mobile game and purchased IRV as I was having lockup issues using yield return www when there was no internet and needed to be able to detect it.
    I have my own server which holds unique unlock codes for my game, so I decided to use the custom server option so I could detect the server is reachable.
    It all works fine when running it in the editor, but once on Mobile it gets stuck on the PendingVerification status. I ran the standard demo IRVEXAMPLE on my mobile as a test and it works fine if using the Apple2 option, but the custom option once again causes it to get stuck on PendingVerification (I changed the url and expected value parameters 1st).
    I am using the latest version of Unity (5.2.0f3) and my mobile is an iPhone 6s running the latest iOS.
    Do you have any ideas on what else I can do?

    Thanks!
     
  5. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    309
    Hi @SoftwareLogicAU, can you share what exact URL are you using with the custom option, and what customMethodExpectedData? And if you're using a custom verifier delegate, what's the code for that.
    (if you don't want to discuss such specifics here on public forum, we can move the discussion over email - write to contact (at) strobotnik dot com)
     
  6. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    309
    Just to let everybody know: SoftwareLogicAU's problem above was solved by upgrading to Unity 5.2.1f1.
     
  7. mydev555

    mydev555

    Joined:
    Mar 15, 2014
    Posts:
    8
    Hi tonic,

    I have a problem with your script since the latest few Unity releases. Right now I'm using patch release 5.2.1p4, but the problem is apparent since a few releases already. The problem especially happens on iOS 9 when testing on device. Here's how you can reproduce it:

    - Start an app with your script / asset included on device
    - Check the internet connectivity
    InternetReachabilityVerifier.Status.NetVerified: NetVerified

    - Turn off airplane mode / turn off Wifi on your device
    - Check the internet connectivity again

    Result:
    InternetReachabilityVerifier.Status.NetVerified: NetVerified


    My method simply goes like this:

    public static bool check() {
    return (InternetReachabilityVerifier.Instance.status == InternetReachabilityVerifier.Status.NetVerified);
    }



    No Matter how often I test, I always get "NetVerified" result, no matter whether I'm online or offline. I did not use any custom settings, use your script with defaults.
    This worked correctly a few unity releases before, I also made sure to use the latest version of your Asset from Asset Store. Something doesnt seem to work correctly with the latest Unity release or with iOS 9 maybe...? Can you check that please?
     
    Last edited: Oct 21, 2015
  8. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    309
    Hi @mydev555, sorry to hear you're having problems. I'll try to replicate this and see if I get the same problem.

    As you can see from the previous messages, there was some problems with late version(s) of Unity.. But whatever that problem was, it was solved by upgrading to 5.2.1f1. Since you're using a newer version than that, it seems you're having a different new problem (or a regression).
     
  9. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    309
    @mydev555, I tried to replicate the issue. Using both Unity 5.2.1f1 and 5.2.1p4, with iOS 9.0.2 device. But it seems to work just fine for me.

    However, there is one slightly worrying notification output by Unity viewable in the Xcode debug log:
    This happened even if I turned "Allow downloads over HTTP" off in Player Settings. This is something new in Unity, and I think it shouldn't have any effect in using the WWW class for own stuff.

    Can you please verify what happens when you test in a new mini test project and use one of the included example scenes... e.g. "IRVExample". So we know if there's something weird with the integration to your app.

    Note: with the latest update the net activity coroutine is stopped if you disable the IRV component or the game object containing it. Make sure not to delete or disable the game object containing IRV! And keep the "don't destroy on load" checked if you load another scene, it's fine to use the same instance.

    Additionally, a slightly silly remark:
    You wrote that you "turn off airplane mode / turn off Wifi". I'm quite sure you meant that turned on airplane mode and Wifi off... since if you turn both off, then the mobile carrier data will be used if available, in which case the net check works just as expected. Can you verify it wasn't just a small error like this?
     
  10. mydev555

    mydev555

    Joined:
    Mar 15, 2014
    Posts:
    8
    Thanks for your answer, I will try to set up a demo project asap.

    What we have in our Info.Plist because of Appodeal-plugin we use, is "NSAppTransportSecurity" and in this dict we have to set "NSAllowsArbitraryLoads: Yes".

    Could this be the problem? This is required by Appodeal / Unity / iOS 9 right now for Appodeal to work correctly.

    About your last silly remark: Yes, of course I meant turning on airplane mode and switching off wifi :)
     
  11. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    309
    I think that should not be a problem. But I'm interested to know if the presence of the Appodeal plugin and Info.Plist modifications is the cause -- so I hope you can do a test using a new isolated demo project without anything extra like that.

    If the isolated test project still fails, please send me a link to that project via email (contact at strobotnik.com) so I can check if it does the same with me, as I can't figure out right now what might be differently set up here.
     
  12. mydev555

    mydev555

    Joined:
    Mar 15, 2014
    Posts:
    8
    Hi tonic,

    I now know what the problem is - and it is a quite interesting one:)
    First I must explain: We put our scripts into the "Plugins" folder for optimizing compile times in the current project, so we also use your script inside of "Plugins" instead of the default installation folder.
    Normally, this is no problem. We use all Prime31 plugins and a lot of others this way without any problems. But your script shows a very interesting behaviour, only(!) when being put into the Plugin folder:

    - It only recognizes the current network state at first start or when being put to background and then to foreground again. So basically, only 1 time when the app "comes to foreground".

    - When you stay in the game and turn off Wifi while having the game open, the network status is never updated. It always says "True" - because it only recognized the first game startup network status


    You can see the file structure here:
    [​IMG]
    (this is from a small demo project i set up for this test)

    Do you have any explanation why this is not working correctly when being put into the Plugin folder?
    And maybe a hint how we could make it work?
     
  13. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    309
    Hi @mydev555, thanks for taking the trouble to figure that out! I think I haven't tested using IRV before as part of the Plugins folder at all.

    I'm a bit busy right now, but I will test that out myself as soon as I have a bit of time to debug this and try to figure any reason for that weirdness. I hope in the meantime you can just use it as part of the normal Assets instead of Plugins as a "workaround".
     
  14. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    309
    @mydev555, sorry it took this long until I had the time to do further testing on this.

    When using the same Unity version (5.2.1p4) with iOS 9.1, I still can't replicate the issue. I tested by taking the IRVExample scene as a base. I created a "Plugins" folder and dragged InternetReachabilityVerifier folder under that. Then I saved a custom copy of the scene file, with additional test script which just polls the status once per second and writes to debug log (in addition to the UI of the IRVExample).

    What I found out with this combination:
    • Toggling WiFi on/off while app is running is properly detected by the IRV, so that it goes to "Offline" state when there's no network reachability at all, and it re-verifies the internet connection after the network is enabled.
    • On this iOS version only the Apple and Apple2 verification methods work (naturally DefaultByPlatform also works as it picks the Apple2 one). I think also custom method works if one uses a https:// url with it. --- I did not enable the checkbox for "Allow downloads over HTTP" on purpose. (In this case, other verification methods result in this error written on screen: "Error: The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.")
    I'm inclined to think that there is some weird side-effect of using IRV with some other plugin (or modified project settings), which causes the issue you described.

    If you manage to replicate the issue with a mini test project, please send me a link to it over email (contact at strobotnik.com).
     
  15. MooseMouse

    MooseMouse

    Joined:
    Sep 14, 2011
    Posts:
    485
    Hi tonic,

    In your "SkeletonIRVExample.cs" you have "forceReverification()". When would need to use this? Are there circumstances in which "isNetVerified()" would not return the proper result unless I first "forceReverification"?
     
  16. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    309
    Hi @MooseMouse, after network access is verified to be working, after that it isn't constantly polled with actual connections to see if it is still up.

    So what does that mean in practice?

    On mobile devices, if all possibility for network connections is lost, that will be detected and the network goes to "offline" state. This happens e.g. if user turns off WiFi and Mobile Data (e.g. with airplane mode).

    But if all internet connections simply stop working for a while, in that case you want to manually force the re-verification so you know when the internet connectivity is back up. You do this by monitoring the error state of whatever network activity you're doing (you shouldn't assume that this asset or any asset like this could free you from doing error checks).

    You may be wondering why the network isn't constantly polled to see if it's still up ...
    That's because it would be impolite - the user's data connection may be metered so any "unnecessary" traffic would cost extra for the user. And in this case the constant polling would be unnecessary, since the same effect can be achieved by monitoring the error status as I mentioned and only start the re-checking of network connectivity when it's known to be lost.
     
  17. MooseMouse

    MooseMouse

    Joined:
    Sep 14, 2011
    Posts:
    485
    Thanks for the reply, tonic. I'm soorry but I'm still not clear for my situation.

    So, in my specific circumstance in I want to download leaderboard data.. I first check for internet. Do I:

    bool netVerified = isNetVerified();
    If (netVerified) GetLeaderboardData();

    Or

    forceReverification();
    bool netVerified = isNetVerified();
    If (netVerified) GetLeaderboardData();

    Thanks!
     
  18. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    309
    @MooseMouse, if you're using the SkeletonIRVExample.cs as the base, then I suggest you study this suggestion below, and use something along these lines: (written from top of my head)

    Code (CSharp):
    1. ...
    2. string leaderboardURL = "..."; // add correct url
    3. bool leaderboardsPending = true;
    4. ...
    5. // SkeletonIRVExample.Start() configures the IRV component so that
    6. // this will be called when the status is changed
    7. void netStatusChanged(InternetReachabilityVerifier.Status newStatus)
    8. {
    9.     if (newStatus == InternetReachabilityVerifier.Status.NetVerified &&
    10.         leaderboardsPending)
    11.     {
    12.         // network access is verified, and we haven't yet fetched leaderboards, so try it now:
    13.         StartCoroutine(GetLeaderboardData());
    14.         leaderboardsPending = false; // fetch not pending anymore
    15.     }
    16. }
    17.  
    18. IEnumerator GetLeaderboardData()
    19. {
    20.     // example of how we might fetch leaderboards using WWW
    21.     WWW www = new WWW(leaderboardURL);
    22.     yield return www;
    23.     if (www.error != null && www.error.Length > 0)
    24.     {
    25.         // Leaderboard fetch failed!
    26.  
    27.         // you should do a few tests how this might fail and study
    28.         // what the error situations look like:
    29.         Debug.LogWarning(www.error);
    30.  
    31.         // since leaderboard fetch failed, set the pending flag back on:
    32.         leaderboardsPending = true;
    33.  
    34.         // ASSUMING the only reason for failure here is that
    35.         // the network connectivity was lost, then we need to
    36.         // verify the connectivity again:
    37.         forceReverification(); // call the helper method for that
    38.  
    39.         // NOTE: the example code above does not check if the failure is
    40.         // because of some other reason.. for example, if the network
    41.         // works but server configuration is wrong or is just missing
    42.         // the leaderboard URL (http return code 404).
    43.     }
    44.     else
    45.     {
    46.         // Leaderboard fetch was successful!
    47.  
    48.         // now you would do something with the result ...
    49.         // here we just print it out with Debug.Log
    50.         Debug.Log(www.text);
    51.     }
    52. }
     
  19. Yuemari

    Yuemari

    Joined:
    Mar 22, 2012
    Posts:
    3
    @tonic: Hi there, we are considering on buying this asset as it looks great, but in our case using a custom server is not an option, so we were having the doubt if with the default behaviour of the asset can still work properly in countries with restricted internet access like China on both iOS and Android?.

    Thanks in advance and great work!
     
    Last edited: Dec 1, 2015
  20. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    309
    @Yuemari I cannot guarantee that the asset will work there, as it depends on access to a validation server.

    Since the asset has support for several existing servers, you might test and find out if one of them works for you on all platforms where you want to use it. If I have understood correctly, the "Google" way might be blocked there (or may have been blocked at some point in the past). But my guess is that the other methods could work just fine.

    If you want to be sure to use only a single detection method, don't pick "default by platform" -- instead just set the method in editor for the Unity component already to some other setting. I recommend you try e.g. Apple2 or MicrosoftNCSI method. The MicrosoftNCSI has been the same system for long time, while both Google and Apple have been changing how they do the detection (which is why this asset has two separate versions for both of them).

    It should be perfectly fine to use e.g. "MicrosoftNCSI" method from also iOS and Android devices.
    (note: due to some Unity WWW implementation differences, you can't use the Google204 method on iOS for example)
     
    Yuemari likes this.
  21. Yuemari

    Yuemari

    Joined:
    Mar 22, 2012
    Posts:
    3
    Ok, thanks a lot that clarifies it!. We will give it a try.
     
  22. graviton

    graviton

    Joined:
    Jan 11, 2013
    Posts:
    75
    @tonic

    What's wrong with my code?
    I keep getting a NullReferenceException (Object reference not set to an instance of an object) for both scripts

    Note, InternetReachabilityVerifier.cs is on a GameObject named InternetReachabilityVerifier

    adding my scripts to a separate GameObject

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class internetTest1 : MonoBehaviour
    5. {
    6.  
    7.     // Returns true when there is verified internet access.
    8.     public bool isOnline()
    9.     {
    10.         return InternetReachabilityVerifier.Instance.status == InternetReachabilityVerifier.Status.NetVerified;
    11.     }
    12.  
    13.     // Use this for initialization
    14.     void Awake ()
    15.     {
    16.         InternetReachabilityVerifier.Instance.setNetActivityTimes(1.0f, 1.0f, 1.0f);
    17.     }
    18. }
    19.  

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class internetTest2 : MonoBehaviour
    5. {
    6.  
    7.     // Returns true when there is verified internet access.
    8.     public bool isOnline()
    9.     {
    10.         return InternetReachabilityVerifier.Instance.status == InternetReachabilityVerifier.Status.NetVerified;
    11.     }
    12.  
    13.     // Use this for initialization
    14.     void Awake ()
    15.     {
    16.         Verify();
    17.     }
    18.  
    19.     void Verify()
    20.     {
    21.         InternetReachabilityVerifier.Instance.status = InternetReachabilityVerifier.Status.PendingVerification;
    22.     }
    23. }
    24.  
     
    Last edited: Dec 14, 2015
  23. PS

    PS

    Joined:
    Nov 21, 2012
    Posts:
    2
    Hi, I've purchased this plugin and it works fine for android and iOS. However for Mac OSX Standalone it returns false even Mac OSX is connected via WiFI to network?

    Is there a fix for it?
     
  24. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    309
    @graviton, that sounds like you should change Edit->Project Settings->Script Execution Order so that InternetReachabilityVerifier is run earlier than your own scripts.

    @PS, it should definitely work (assuming the mac really has working internet connectivity). So I should investigate this. What Unity version are you building with? (and what OSX version do you have? although that shouldn't matter...)
     
  25. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    309
    @PS, I just verified with Unity 5.3.0f4 with OSX standalone build, using only WiFi networking, that the verification works okay. Also if I turn off WiFi and try "Force reverification" button in the IRVExample, the net access Status goes to Error (as intended, since the remote host can't be resolved). After enabling WiFi again and waiting a bit, the net access verification worked and went again to "NetVerified".

    If you keep having problems, I need more exact info of what Unity, OSX and IRV versions you're using, and that you send me a minimal test project (without other libraries) where the problem appears. You can send package of that test project to contact @ strobotnik . com).
     
  26. graviton

    graviton

    Joined:
    Jan 11, 2013
    Posts:
    75
    @tonic

    Put "InternetReachabilityVerifier.cs" at the top of the Script Execution Order

    The Error is gone, but now I have another issue

    When I start the scene, and the game is Offline my debug log correctly states it's "Offline"

    then when I turn On wifi, my log correctly states it's "Online", but when I turn wifi Off again, it still says I'm "Online"

    It just gets stuck and never changes

    I'm using Unity 5.0.0f4 RC4 64-bit, if that makes a difference

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class internetTest : MonoBehaviour
    5. {
    6.  
    7.     // Returns true when there is verified internet access.
    8.     public bool isOnline()
    9.     {
    10.         return InternetReachabilityVerifier.Instance.status == InternetReachabilityVerifier.Status.NetVerified;
    11.     }
    12.  
    13.     // Use this for initialization
    14.     void Awake ()
    15.     {
    16.         InternetReachabilityVerifier.Instance.setNetActivityTimes(1.0f, 1.0f, 1.0f);
    17.         Verify();
    18.     }
    19.    
    20.     void Verify()
    21.     {
    22.         InternetReachabilityVerifier.Instance.status = InternetReachabilityVerifier.Status.PendingVerification;
    23.     }
    24.  
    25.     // Update is called once per frame
    26.     void Update ()
    27.     {
    28.  
    29.         if(isOnline())
    30.         {
    31.             Debug.Log("Online");
    32.         }
    33.         else
    34.         {
    35.             Debug.Log("Offline");
    36.         }
    37.     }
    38. }
    39.  
     
  27. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    309
    Great to hear your initial issue was solved.

    Your second question has been asked a few times before, so I'm just going to copy-paste my last answer and reasoning from an earlier message:
    This asset will not actively monitor if the network is "still up". That would be actually impolite towards user, since doing that reliably would mean doing some network traffic all the time to test if it works, and that could cause extra cost for users when using a mobile subscription with limited amount of bandwidth/traffic.

    So, after you notice the internet access is verified and start doing something - e.g. make a WWW connection somewhere, you should still monitor the return status yourself. It's possible the network is lost middle of operation, or that even if internet access generally works, that particular server does not. If you detect an error situation when you do networking, then you can ask IRV to re-verify the internet (see forceReverification in the skeleton script).​
     
  28. graviton

    graviton

    Joined:
    Jan 11, 2013
    Posts:
    75
    What I'm trying to do is let the player play when the game is Online and Lock the game when connection is lost

    The Skeleton example isn't even working anymore, I've deleted and re imported the asset with no success
    I have 2 versions of Unity (Unity 5.0.0f4 and Unity 5.1.2f1), as I understand it you are saying my code in the Update Method, my "isOnline()" bool is not going to update on its own (that's why I need to force verify) and that's why it says "Online" when it's "Offline"

    Code (CSharp):
    1. void Update ()
    2.     {
    3.  
    4.         if(isOnline())
    5.         {
    6.             Debug.Log("Online");
    7.         }
    8.         else
    9.         {
    10.             Debug.Log("Offline");
    11.         }
    12.     }
    13.  
    The thing I'm not understanding is why does this same script work in "Unity 5.1.2f1", if I turn On wifi it says "Online", if I turn Off wifi it says "Offline", I could switch wifi On and Off forever and still get the correct result in "Unity 5.1.2f1"
    Doesn't this mean it's updating the bool (maybe not every frame but) after specified wait times

    isn't this what this line does, setting how often the plugin checks connection (so as to not be impolite)?
    Code (CSharp):
    1. InternetReachabilityVerifier.Instance.setNetActivityTimes(1.0f, 1.0f, 1.0f);
    2.  
    Why does it work in one version of Unity and not another
     
  29. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    309
    @graviton, I can think of two reasons to what you're seeing... Did you test on the same device/machine with both Unity versions, or with a different types of devices?

    Since the "network loss" situation will be detected on a mobile device, where all network connectivity can be lost. But a desktop computer Unity API will always report that at least local network connectivity is supposed to be available, so the network loss won't be detected. And IRV asset does not have a separate polling for that case, as I already described (since it'd cause unnecessary network traffic).

    If it's just about the different Unity versions functioning differently on the same device, then it could be that the particular Unity 5.0.0f4 version has a bug which affects this functionality. If you read back messages on this thread, one issue another user was having was fixed by upgrading Unity to newest version (back then it was 5.2.1f1). I recommend you also do the switch either to latest 5.2.x or 5.3.x.
     
  30. graviton

    graviton

    Joined:
    Jan 11, 2013
    Posts:
    75
    I will figure it out myself
     
  31. MooseMouse

    MooseMouse

    Joined:
    Sep 14, 2011
    Posts:
    485
    I've been using this plugin successfully for a few months. But recently I updated to Unity v5.3.2 (now on 5.3.2p2) and it no longer seems to detect no internet connection on iOS. It just keeps showing InternetReachabilityVerifier.Status as "PendingVerification". It works as expected in the Editor and on Android devices.

    If there is an internet connection, it shows up properly on iOS.. just no internet connection that does not work as it used to.

    Any idea what is going on?
     
  32. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    309
    Hi @MooseMouse, try enabling "Allow downloads over HTTP (nonsecure)" in the iOS Player Settings. Plain HTTP support is required for proper captive portal detection.
     
  33. MooseMouse

    MooseMouse

    Joined:
    Sep 14, 2011
    Posts:
    485
    Thanks for the reply. I already thought about that one earlier and made sure it was checked. It is, and always has been, so that is not the problem (unfortunately).
     
  34. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    309
    Hmm. Does your project have any native code customizations to project file (Xcode)? I guess there might be some new different change. What was the previous Unity version which still worked for you?
     
  35. MooseMouse

    MooseMouse

    Joined:
    Sep 14, 2011
    Posts:
    485
    No new native code customizations. I'm not sure which was the last version because I often forget to test without internet. I will have to test some old builds at some point. Right now I'm under deadline so I'm just assuming that after 5 seconds of "PendingVerification" the internet is unavailable. Not the best solution, but the best solution for right now...
     
  36. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    309
    @MooseMouse I'll look into re-testing with the latest Unity version, but it may take a bit of time, so if you can live with whatever workaround for now, that's good.

    Your wording on the original question got me thinking though: ..."it no longer seems to detect no internet connection on iOS."
    Please note that detecting lost internet connection is not a feature of the IRV asset. Instead it verifies that network connection is a properly working one when it is available.

    Detecting loss of network is something one should always do as part of the network stuff what you're doing... for example, if you try to connect somewhere or do a web request, checking the error return codes from the particular networking API will tell you if you lost the network. When that happens, you can then ask IRV to re-verify the internet connection. Then it will keep trying (PendingVerification), and once the network works, you'll get the success status.
     
  37. MooseMouse

    MooseMouse

    Joined:
    Sep 14, 2011
    Posts:
    485
    I'm away from my computer right now but will try to explain more fully.
    1. I turn iPhone to Aiprplane mode.
    2. Build and run from Xcode.
    3. Your plugin status says "PendingVerification".
    4. I listen for status change but it never changes.

    On Android status does change to "Offline (I believe"). IPhone used to behave the same way.

    If iPhone test is done with Airplane mode off (wifi and internet available) your plugin starts with status of "PendingVerification", but soon changes (to "Online" I believe).

    If intended behavior is to never change from "PendingVerifivation" when offline, I don't understand the point of having an "Offline" status. Plus it used to work differently as describred above.
     
  38. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    309
    Thanks for the detailed explanation.

    I try to explain the difference between "Offline" and "PendingVerification":

    "Offline" means that the device is known for sure to be offline: Both WiFi and mobile data are turned off, so it's not even "technically possible" to try to get online.

    When IRV is in "PendingVerification" state, it means that there's some networking system enabled: either WiFi, mobile data or local area networking (on desktop computers). After this one can try to make a connection, so IRV goes to the PendingVerification state - meaning it will keep trying periodically if the internet connections actually work or not.
    --
    So, basically your software might not ever see the "Offline" state if user doesn't turn off all networking types. It's better just to assume the device is offline until getting to the "NetVerified" state. (and after which you still need to check for errors & ask for re-verification if needed, as of course the network connection can always be lost at any possible time)
     
  39. MooseMouse

    MooseMouse

    Joined:
    Sep 14, 2011
    Posts:
    485
    Thanks for the reply.

    According to your docs:

    Offline: No internet access or network connectivity at all. (Only when Unity's built-in Application.internetReachability equals NetworkReachability.NotReachable).

    PendingVerification: Internet access is being verified by using doing a WWW request to the active captive portal detection method.

    Error: Verifying internet access resulted in a WWW error response. (See lastError.) Verification will be retried automatically after a delay.

    Mismatch: Verification failed – a “captive portal” has been detected. That is, a page was successfully fetched but contained wrong data. This usually means that the user needs to login into network, and there's a good chance that the network will soon be available. Verification will be retried automatically after a delay.

    NetVerified: Network & internet access has been verified. You're online!

    Consequently, I'd expect that if the game is launched in "Airplane Mode", your asset would show status as either "Offline" or "Error". That is how it works on Android and that is how it used to work on iOS. "PendingVerification" on these two platforms used to signal an intermediate status in which your asset was trying to categorize the status as one of the other 4. Something has changed on iOS. I like it better the way it used to work. If "PendingVerification" can now also mean some type of permanent status in which the internet is not reachable, that is not as good. "PendingVerification" should be just that, and a more informative final status should be determined, imho :)
     
  40. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    309
    @MooseMouse, sure it is possible that something has changed in iOS / latest iOS SDK / latest Unity version ... (and I didn't yet have the time to do a full test round to check if something is now different).

    But, user can use "Airplane Mode" and still have WiFi enabled (that's allowed). In that case the status will never go to "Offline" and will stay in PendingVerification instead, and that's just as intended. When testing, make sure you detach usb cable between mac & iOS device, and then try the Airplane mode with also WiFi being turned off.
     
  41. MooseMouse

    MooseMouse

    Joined:
    Sep 14, 2011
    Posts:
    485
    I will try one last time as it doesn't seem like you are fully understanding my point of view as a customer.

    When my iPhone has no cellular, no wifi, and no usb connection to a computer (it is definitely offline), your asset used to be able to almost immediately tell me that the internet was definitely unreachable. That was really awesome! Now your asset does not do this.. it just tells me that verification is pending. This is not as good.

    Now I always have to wait for a timeout period (I've set it to 5 seconds at the moment) to decide how to proceed. This is okay.. sometimes when the internet was just slow I would use a timeout. But it is much better to know for sure one way or the other as quickly as possible when it is possible, as this is a better user experience. I'd like your asset to work the way it used to again. If you can't make it work as it used to (or are unwilling to), that is good info for me to know, too.
     
  42. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    309
    @MooseMouse, thanks for the patience and explaining again what you meant. :)
    The "offline" state is indeed dependent on Unity reporting Application.internetReachability==NetworkReachability.NotReachable, so it's merely a convenience part of the asset, rather than an actual feature, in a way.

    I will investigate if newer Unity is changed somehow about this... but, in the end, the feature (or the "point") of this asset not to detect offline state, but instead to verify if internet connection actually works when networking is available - for example when there's some public wifi login screen preventing internet from actually working.
     
  43. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    309
    @MooseMouse, I just tested with the latest versions: Unity 5.3.2p2, Xcode 7.2.1, iOS 9.2.1.

    Using a new app with IRVExample as is for the test scene. It works just as before:

    (a) Device is first turned to Airplane mode AND WiFi turned off. When starting IRVExample, it goes to "Offline" state. Then after enabling WiFi, after a moment IRVExample briefly goes to PendingVerification state and then to NetVerified.

    (b) Device is first turned to Airplane mode but WiFi is enabled. Starting IRVExample, it starts in "PendingVerification" state and then soon switched to NetVerified as network is available.
     
  44. MooseMouse

    MooseMouse

    Joined:
    Sep 14, 2011
    Posts:
    485
    @tonic Thanks for looking into it.
     
  45. quaigon

    quaigon

    Joined:
    Aug 16, 2013
    Posts:
    8
    I have an other problem. Maybe its a bug at unitys www-class. i use unity 5.3.2 and iOS 9.1

    iPad is connected to my cellphone, so internet is provided via cellphone data connection.

    if the data connection is on, NetVerified appears. Data can be received.

    Now i switch-off the data connection on my cellphone. wifi connection from iPad to cellphone is on. IRV set PendingVerfication and try WWW request. But nothing happens there. The WWW class receive no data but also send no error. So IRV has no status change.

    This is known? Maybe some other solutions, except to allow only a maximum time for Pending and the WWW request?
     
  46. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    309
    @quaigon, sounds to me IRV is working alright, since pending verification means it will periodically try again to see if the network becomes available.

    If you do your own WWW access and "nothing happens" (no data or error), how long did you wait for something to happen? In case the capability for trying network connections is available (wifi enabled, but access point without internet connection), then the connection will time out and that can take a while. Depending on platform that can apparently be something like 60 seconds.
     
  47. quaigon

    quaigon

    Joined:
    Aug 16, 2013
    Posts:
    8
    yeah, i think its no problem with IRV, but with the unity www class. In my case the www class stop at 50%. So IRV can no longer handle the pending verification. its stopped an the WWW w = new WWW(url) line. there is no w to return. no error. If you yield with while loop (instead of yiel return w), then you can see the stopped progress at 0.5.

    At the moment i stopped the progress after 4 seconds and set the status to missmatch manually. So i can open a hint for the user. 60 secs is too long for waiting and nothing is happend.

    This problem is only in this special case. Maybe also with network login, like in hotels and fairs?

    I tested this case never bevor, so i'am not sure since when this happens.
     
  48. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    309
    With some Google searching I found out that on iOS and Android the WWW timeout length can be up to 60 seconds and there's apparently not much to do about it ... not sure why the progress would claim 0.5 though, but that's something to do with Unity itself anyway (not in scope of IRV).
     
  49. fivebits

    fivebits

    Joined:
    Feb 4, 2015
    Posts:
    9
    Hi, will this work with an IPV6-only network?
     
  50. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    309
    Well, I'm not absolutely 100% sure about that. But there's no direct IP (v4) addresses used, and the verification uses standard http connections using UnityEngine.WWW, so I think it should work just fine.