Search Unity

  1. Engage, network and learn at Unite Austin 2017, Oct 3 - 5. Get your ticket today!
    Dismiss Notice
  2. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  3. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  4. Unity 2017.1 is now released.
    Dismiss Notice
  5. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice
  6. Unity 2017.2 beta is now available for download.
    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:
    317
    Internet Reachability Verifier for Unity.

    LINK TO ASSET WEBSITE: Internet Reachability Verifier website.

    So what does it do? After all, there's already Application.internetReachability in the Unity API.

    Application.internetReachability has a bit misleading name - it actually tells if it is technically possible for you to try to use the network. So, on a desktop machine it will always tell you that you can. On a mobile device it’s nice for checking if you’re really offline, or if you can try to make a connection (and if it is going to use WiFi or carrier data).

    However, when using public WiFi, quite often you need to go through a login web page before the internet truly works. In such wireless network, any WWW request will actually give you the login page instead of the data you actually wanted. This is the situation where you want to use Internet Reachability Verifier.


    What features does Internet Reachability Verifier have?

    Accompanying pdf manual contains more details of each feature listed below.

    • Automatically monitors and verifies internet reachability, implemented using a light-weight coroutine.
    • If internet connectivity stops working middle of your own networking and you get error codes from some networking library, you can ask for reverification of the internet reachability (this asset will not actively monitor loss of effective networking, as that would use up user's mobile data quota unnecessarily).
    • 8 different captive portal detection methods: Google204, GoogleBlank, MicrosoftNCSI, Apple, Apple2, AppleHTTPS (new for ATS), Ubuntu, Custom.
    • Default setting is to automatically pick a suitable ("native") captive portal detection method by platform.
    • Optional delegate for matching returned data for using custom method.
    • Optionally append cache buster to url when using the custom method.
    • Detailed internet access status property (Offline, PendingVerification, Error, Mismatch, NetVerified).
    • Easy callback for listening to changes in the internet access status property (optional).

    About the implementation
    • Works with Desktop and Mobile platforms (self-hosted Custom method can be used with legacy Webplayer).
    • No native code.
    • C# source code included.
    • Small footprint.
    • Supports Unity 5, Unity 4 and Unity 3.5.7 (no Pro needed for older versions)

    Internet Reachability Verifier website

    Other assets from Strobotnik: Google Universal Analytics for Unity, Dynamic Text
     
    Last edited: Feb 25, 2017
  2. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    317
    v1.0.0 is now available!
     
  3. boddole

    boddole

    Joined:
    Sep 18, 2013
    Posts:
    35
    @tonic: looks quite useful (though I would appreciate an actual support e-mail address..), anyway I was wondering in terms of compatibility, is there anything that would break this plug-in? Such as iOS updates or Unity updates in the foreseeable future? Just wondering because I'm trying to figure out if I should go with your option to fix an issue I have, or try to talk to prime31 about their Game Center plugin and see if they can resolve it (if you care what that is see below), any feedback is appreciated.

    My specific issue: apparently a user can log into Game Center, then lose their internet connection but remain logged into Game Center. My app can upload saved score data while the user is offline and then submit it later, but just checking to see if they are logged into Game Center can yield a situation where the user is allowed to upload their scores while offline, think the upload succeeded, then look at the Game Center scoreboards (and of course their new scores won't be there). So I'm looking for a way to remedy this possible issue, and your plug-in looked like a winner.
     
  4. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    317
    Hi @boddole. Short answer to your question about if the plug-in can be broken in the future: "it's very unlikely, but possible".

    Better explanation with some details which may or may not make sense: This technique is based simply on using the Unity's own WWW class, simple Unity updates shouldn't make a big difference. However, e.g. the "Google204" captive portal detection requires check of the http status code, which is possible to get only in certain platforms with Unity's own WWW class, and in differing ways (e.g. different response header key on android than on desktop). If they change this, then it may slightly affect how the verification works, but even in that case it should gracefully do a fallback to work w/o the header. Also, it's of course possible that one of the big companies hosting the internet check stop keeping up their servers, although that's highly unlikely as well. :) Any way, you can opt to run own custom server for the file check.

    Regarding your Game Center issue... to me that sounds like it would be more about prime31 needing to fix their plug-in, although you might be able to solve your issue by doing some own custom stuff with this asset... In your particular case though, it _might_ be enough for you to just see that if (1) user already logged in game center successfully (there must be a valid connection), and (2) Unity's own Application.internetReachability field suddenly equals NotReachable, then you know the submission is not going through.. that is, you might be able to fix that without even buying my asset. (However, that kind of check wouldn't work on e.g. desktop builds as they never report NotReachable, but obviously you're not running on desktop).
     
  5. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    317
    v1.0.1 has been submitted for Asset Store reviewing -- this version adds "Apple2" method (which mimics how iOS7 does the detection), and also explains in the manual why using custom method is recommended.
     
  6. boddole

    boddole

    Joined:
    Sep 18, 2013
    Posts:
    35
    @tonic: Thank you for the detailed answer, I really appreciate it.

    As you mentioned, using Unity's Application.internetReachability would work for checking if the user has no connection, but (I think) that would still leave a gap where the users connection is available but they have not logged in to say a public wifi hotspot, which could prevent the sending of data to Game Center (again, not sure on that, maybe the data will make its way there anyway?). That is why I was so interested, because your plug-in could detect if the user was "truly" connected, and not just "had the potential to use the internet".

    BTW- prime31 got back to me, and apparently as long as the scores are packaged and sent correctly, Apple considers this a successful score submission, regardless of internet connectivity / Game Center verification (I love the way Apple thinks....).
     
    Last edited: Jul 23, 2014
  7. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    317
    @boddole, yes, my idea was under assumption that successful Game Center initialization/login would implicitly mean that there was proper internet connectivity, but that the user lost it. Perhaps that isn't so, in which case my asset could indeed be useful to you.

    Note that some captive portal systems used to run public WiFis actually have hardcoded checks for the captive portal checks, in which case even my asset can be fooled when using one of the standard options (I just noticed this happening with one airport wifi). For such cases the "custom" method should work more reliably but needs one to host own server or own file on some server for the checks, meaning a bit of extra hassle.
     
  8. boddole

    boddole

    Joined:
    Sep 18, 2013
    Posts:
    35
    @tonic: I see, thank you again for the clarification.
     
  9. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    317
    Version 1.0.1 is now available!
     
  10. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    959
    Hi,
    Do you have functionality to test if there has been no connection for a certain time period?
    Use case would be checking internet reachability for android google lvl check.
    In case user is offline they get a grace period before action is taken.
    eg: along the lines of this thread http://forum.unity3d.com/threads/lvl-check.167121/

    ty!
     
  11. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    317
    Hi @sonicviz, there's no ready-made function to return that info right now - maybe I'll add that to next version. It is pretty easy to add though. Here's a quick example how to do that by modifying SkeletonIRVExample.cs:

    add these rows of new code:
    Code (CSharp):
    1.     InternetReachabilityVerifier.Status prevStatus = InternetReachabilityVerifier.Status.Offline;
    2.     float noInternetStartTime = 0;
    3.  
    4.     float getTimeWithoutInternetConnection()
    5.     {
    6.         if (prevStatus == InternetReachabilityVerifier.Status.NetVerified)
    7.             return 0; // we're online
    8.         else
    9.             return Time.time - noInternetStartTime; // time without internet in seconds
    10.     }
    modify the implementation of netStatusChanged-method to this:
    Code (CSharp):
    1.     void netStatusChanged(InternetReachabilityVerifier.Status newStatus)
    2.     {
    3.         Debug.Log("InternetReachabilityVerifier.Status: " + newStatus);
    4.         if (prevStatus == InternetReachabilityVerifier.Status.NetVerified &&
    5.             newStatus != InternetReachabilityVerifier.Status.NetVerified)
    6.             noInternetStartTime = Time.time;
    7.         prevStatus = newStatus;
    8.     }
    Now you can call getTimeWithoutInternetConnection() and it should always return 0 when user is online, and amount of seconds spent being offline if there's no verified internet connectivity.
     
  12. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    959
    Thanks for the tips
     
  13. quaigon

    quaigon

    Joined:
    Aug 16, 2013
    Posts:
    8
    Hey @tonic,

    we tried your IRV to check the internet connection for mobile devices and webplayer.

    when i deactivate the wifi/wlan/lan component on the device - i only receive the error status from your script, not the offline status. Is this right?

    So is there any possibility to distinguish between real errors and only no active internet connection? I want to display 2 different messages for the user: Error to contact the admin, and Offline to check InternetConnection

    The first way i found to solve this problem is to analyse the lastError - String and search for keywords, like offline, resolve host, DNS, ... . Do you know where i can find a list with all error messages, which the www class can throw? Or is there any other options for me?

    thx :)
     
  14. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    317
    Hi @quaigon! This is going to be a bit long reply, as I think there's no clear solution for you, but I'll do my best to help anyway. Although I didn't exactly get what kind of situation is the "error to contact admin" - is your app meant for some internal and not public use?

    About WiFi and Offline: If you deactivate WiFi on the device, it may still be able to try connection using carrier data network like 3G if it's available, in which case it doesn't go into "Offline" status. The Offline status is reported only when there's no chance to try connection (in this case also Unity's Application.internetReachability equals NetworkReachability.NotReachable). On desktop computers that Offline state is basically never reported as they always tend to have LAN enabled even if there's no internet connectivity. But on mobile devices you'll get the Offline state if you enable airplane mode and make sure WiFi is not enabled.

    For the Error status there's unfortunately no easy way to distinguish between different possibilities what could be causing the error. This is because the error string is set by Unity's WWW class implementation, which is implemented slightly differently for each platform (being a wrapper for a native class). Unfortunately this also means that the error strings are different on each platform and can differ even by the OS version.
    For example, on Android non-existent url can result in "java.io.FileNotFoundException: http://wrong_url_here". On iOS the same error in this case would be "404: not found". And when running directly from Unity Editor on desktop Windows, it is "404: Not Found" (note different capitalization).

    So, there's no clear answer how to use the error string easily. If you still want to pursue that path further, below is some more info I found for both iOS and Android, which may be helpful to you.

    iOS:
    You can view the Unity's WWW wrapper code by locating it in the Unity installation directory: Unity/Editor/Data/PlaybackEngines/iossupport/Trampoline/Classes/Unity/WWWConnection.mm.
    There are two places which can send errors there - implementations of "didFailWithError:" and "didReceiveResponse:" (the latter one seems to used when http status code is e.g. in the 400 range). Both call native code to fetch error string (localizedDescription / localizedStringForStatusCode). For me that seemed to return strings in English even if I had set device to a different language.
    Here's instructions how you can get a list of English URL strings for iOS:
    On your Mac, open a new Terminal. Then make a copy(!) of URL.strings file in Foundation framework:
    cp /System/Library/Frameworks/Foundation.framework/Resources/en.lproj/URL.strings ~/tmp-URL.strings
    Then run this command to convert the temp file to different format:
    plutil -convert xml1 ~/tmp-URL.strings
    Now you can view the tmp-URL.strings file as xml data, and see different types of response strings.

    Android:
    I am not sure, but I'm guessing that the used HttpURLConnection implementation might be the code that's in following URL.
    https://android.googlesource.com/pl.../www/protocol/http/HttpURLConnectionImpl.java
    I think you want to check at least implementations of getInputStream() starting at line 1134, and doRequestInternal() starting at line 1614. It doesn't seem very clear what are the different types of responses.

    I think most helpful might be to check the http status code, which is reported differently (if at all). For that, peek how CaptivePortalDetectionMethod.Google204 in checkCaptivePortalDetectionResult is implemented (InternetReachabilityVerifier.cs) - on desktop the response header string key is "STATUS", on android it is funnily "NULL" (but it works). On iOS the status isn't reported, but as you can see from my example 404 string, the start of WWW error string has the code. (On WinStore/WP8 builds the status is also missing, but right now I don't have example error strings at hand to check if the status code is shown there.)

    Again, note that the WWW class implementation has varied between Unity versions (especially between 3.x/4.0/4.x). And there are also differences based on OS version, so the above hints apply only to recent versions.
     
  15. NeedNap

    NeedNap

    Joined:
    Nov 1, 2012
    Posts:
    21
    Hi @tonic, I'm developing a mobile app (iOS and Android) that must detect a local WiFi connection (based on a custom hardware configuration used for an automated gates system - the WiFi chip used is http://www.microchip.com/wwwproducts/Devices.aspx?product=RN171).
    Then the app should send and receive string commands to communicate with the software developed in the gate hardware motherboard.

    I would like to know if your library can solve these problems:

    - detect the WiFi connection available
    - establish the connection
    - communicate with the local server

    I need your reply as soon as possible due to the project deadline.
    Thank you in advance
     
  16. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    317
    Hi @NeedNap. Since you have a somewhat custom situation regarding the WiFi connection, I'm not sure if it is possible to use this package in your case or not.

    But, if the WiFi chip&connection works like any other network/WiFi connection would in Unity's view, then it should be possible to use this package using the "Custom" detection method.

    For the Custom method, you need to place a file to your local server, and the InternetReachabilityVerifier (IRV) component should then be configured to use the local url to that file. The file must have known contents (maybe just "OK" or "wifi available" - this same thing will be set for the IRV component). Additionally you should make sure the local server is configured so that it doesn't set cache control info for the file (so that client can assume it always needs to be fetched again when asking for it).

    After that, rest of communication with the local server is of course up to you, after you know from this package that the connection should be functional. :)
     
    Last edited: Aug 14, 2014
  17. NeedNap

    NeedNap

    Joined:
    Nov 1, 2012
    Posts:
    21
    Thank you @tonic, I'll try it as soon as possible and I'll let you know the result.
     
  18. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,534
    demo apk??
     
  19. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    317
    @imtrobin there's no separate demo version available, if that's what you're asking.
     
  20. phoenixrising

    phoenixrising

    Joined:
    Aug 9, 2013
    Posts:
    55
    currently, I am using your plugin to successfully determine if the internet is available and it works well.

    However, I need to know if the internet is wifi or cellular as cellular gives me problems.

    I found this link https://github.com/xamarin/monotouch-samples/blob/master/ReachabilitySample/reachability.cs

    which has an enum

    public enum NetworkStatus
    {
    NotReachable,
    ReachableViaCarrierDataNetwork,
    ReachableViaWiFiNetwork
    }

    would you consider adding this additional information to your plugin?
     
  21. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    317
    Hi @phoenixrising, nice to hear you like the asset.

    That particular feature you want is already available in Unity itself:
    http://docs.unity3d.com/ScriptReference/Application-internetReachability.html
    (the NetworkReachability has similar enum values)

    Further explanation: Application.internetReachability alone isn't enough to know if the internet access works (like the documentation says). For example, on desktop PC it always returns ReachableViaLocalAreaNetwork. But after you know that the internet access is verified using InternetReachabilityVerifier, you can peek at Application.internetReachability to see if it is carrier data network or Local/WiFi network.
     
  22. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,534
    No, I'm asking for an apk to that we can test to make sure it works. You can use guitext to output the status.
     
  23. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    317
    Hi @imtrobin, sorry, of course -- I don't know what I was thinking when writing that reply. I just sent you a private message with a link!
     
  24. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    317
    Version 1.0.2 is now available!

    It has slightly refined main example where you can switch the method to force re-verifying of internet access to try out the different ways.

    Additional what's new in the code:
    - Refined customMethodExpectedData check to support expected empty result.
    - Added option to append use a "cache buster" query string when using custom method.
    - Added getTimeWithoutInternetConnection().
     
  25. HoMeBoYErik

    HoMeBoYErik

    Joined:
    Mar 12, 2014
    Posts:
    22
    Hi tonic,
    I just bought your asset from the store. It seems pretty clear. I made a simple test with your test scene, I launched the scene from the editor and then I turned my wifi-off...I waited for the coroutine interval to shoot and detect the change but nothing happened. It seems that when it reaches the NetVerified status it won't detect the loss of reachability. Am I doing something wrong?
    Thank you

    PS: I just tried on my iPad and on the device it seems to work correctly.
     
    Last edited: Oct 6, 2014
  26. HoMeBoYErik

    HoMeBoYErik

    Joined:
    Mar 12, 2014
    Posts:
    22
    Hi Tonic,
    it's me again. Is there a method to check the status forcing the coroutine to shoot without waiting the WaitForSeconds?
    I'll try to explain better. Let's say my check interval is set to 30 seconds. In my app I want to download an image from my server so before starting the download (that maybe implies changing some stuff of my GUI) I want to be sure that the server is reachable but without waiting for the coroutine. Is it possible? Thank you

    EDIT:
    Just found this in the example
    Code (CSharp):
    1.  // *****
    2.             // This is how you force "pending verification" status
    3.             // so that Internet access will be tested again.
    4.             internetReachabilityVerifier.status = InternetReachabilityVerifier.Status.PendingVerification;
    5.             // (you should do this if you know some other way that
    6.             //  network connectivity has been lost or something)
    7.             // *****
    Is this the method? But I still have to wait for the timeout to shoot...
     
    Last edited: Oct 6, 2014
  27. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    317
    Hi @HoMeBoYErik! Good questions - it seems those details aren't answered clear enough in the current documentation.

    First, about detecting loss of network: It's true that the loss of internet connectivity isn't noticed the same way with verifying if the connection is available. For loss of connectivity it checks if the Unity's own Application.internetReachability becomes NotReachable - which is how you can check that on a mobile device. However, on desktop (and in editor) that reports network being always reachable, so turning off WiFi on computer won't change that -- and the loss of network isn't detected. For actively noticing it, there would need to be constant re-checks using an internet connection all the time when the internet is available, which should be considered impolite and "bad behavior" (as it would waste user's internet data transfer).

    So, for internet reachability loss, the recommended use case is that when you detect an error situation in whatever you're doing in internet, at that point you should force the Internet Reachability Verifier (IRV) status to the PendingVerification state (applies to using WWW class or some other network connection system). Error situations should always be taken into account anyway, as the device could lose the internet device just in middle of doing some transfer ... and after you have implemented such checks for error situations, it should be easy to just add that line of code to change the IRV status.

    Then, about your other question ...

    Yes, there's always the wait for the check interval before the asset re-checks the situation. The default delays are set to be a bit conservative, but feel free to set a bit smaller ones using the setNetActivityTimes method. Maybe set the error retry time just to a few seconds if you want the change to be detected a bit faster.

    So, just to clarify:
    Make your net-access code to wait until the IRV status changes (and preferably show "waiting for network connection" status to user). Once the status is NetVerified, you can then immediately start any network activity you want. But you should still check for any error situations, and if it happens that the internet access is lost, then you should manually force IRV status to PendingVerification -- and IRV will work on the background (maybe with some seconds of delay which is reasonable & makes it more light-weight and well-behaving).
     
    HoMeBoYErik likes this.
  28. HoMeBoYErik

    HoMeBoYErik

    Joined:
    Mar 12, 2014
    Posts:
    22
    @tonic thank you for your very clever explanation. Indeed I have an error manager in my app so I will let him manage the situation and set the state of IRV to PendingVerification. I was missing that.
    Thank you
     
  29. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    337
    Exactly what I need, added to purchase list.
     
  30. MSFX

    MSFX

    Joined:
    Sep 3, 2009
    Posts:
    96
    This looks great and just what I need. I'm assuming I can test the users connection and wait for the response before trying to send data to a server whenever I want, I don't have to set it up to test every X seconds etc? How long (i seconds) does it usually take to determine whether there is a connection or not (desktop platform)?
    Thanks! :)
     
  31. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    317
    Hi @MSFX, yes it's pretty much like you described. In case there's no connection, it'll internally keep trying again. The speed of the check is dependent on the quality&speed of network connection. If the network connection is good then the check is almost instantaneous (few tens of milliseconds).
     
  32. Mosy

    Mosy

    Joined:
    Aug 13, 2014
    Posts:
    24
    Hi, I'm developing an Android game, that is expected to get a port to iOS as soon as we get the Android version finished. We were having a problem with the game crashing on launch when the device did not have an internet connection. Once we tracked down the problem to the internet connection, my boss agreed to purchase this plugin. Since implementing this plugin the game loads reliably at all times, however it acts as if there was no internet connection even when there is one.
    It seems like when I call;

    <code>
    bool networkConnectionAvailable = InternetReachabilityVerifier.Instance.status == InternetReachabilityVerifier.Status.NetVerified;​
    </code>

    it is taking too long to verify those conditions are equal, meaning that networkConnectionAvailable is never getting set to true.
     
  33. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    317
    Hi @Mosy, great to hear the asset is helping you.

    It sounds like the first try for verification might lead to verification error in your testing, in which case Internet Reachability Verifier waits for half a minute before trying again (if default delay is used). You could try to reduce the default delay from 30 to 5 seconds and see if that helps at all:
    InternetReachabilityVerifier.Instance.setNetActivityTimes(5.0f, 5.0f, 7.0f);

    Additionally you might want to try if using a different verification method helps.

    From your code sample it can't be seen if you keep polling the status, or if you're doing it only once. If you want to verify status using that code row, you should have it e.g. in Update() so that it will be checked again and again.

    Alternatively you can also use a callback - for an example please see void netStatusChanged(newStatus) in SkeletonIRVExample.cs.

    If these things do not help, please tell me also: What Unity version, and what "verification method" are you using (or is it DefaultByPlatform)?

    One more thing: If you had a crash bug due to network connection not being reliably available, it sounds like you aren't possibly paying enough attention to error situations in your network code. IRV can only help with making sure the network is there when you try to make a connection or start a download for example. But if the network connection drops away right in middle of what you're doing, IRV can't help at all with that - so you should look into refining your own code as well and handle errors properly. (And when a network error happens because of connection is lost, then you should instruct IRV to re-verify internet connectivity - see void forceReverification() in SkeletonIRVExample.cs).
     
  34. noyeti

    noyeti

    Joined:
    Apr 25, 2014
    Posts:
    18
    Hi tonic!

    Has this been field tested in China? i.e. I believe the Chinese government block access to certain site like google...

    Thanks
     
  35. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    317
    Hi @noyeti, it's not exactly "field tested" in China but I've been asked about this previously.

    I don't know if some of the existing captive portal detection method urls are blocked in china or not. There's support for "custom" method. It means simply that you host (in a server you control) some very small file with known contents, and accessing that is used for verifying that network connection works properly. With this method you just then have to make sure that the server is always running or otherwise all connections start failing. But this way it should work in China as well as long as your server is not blocked there.

    I'd be glad to hear any experiences if somebody has tested each of the verification methods in China, if they're functional or not.
     
  36. noyeti

    noyeti

    Joined:
    Apr 25, 2014
    Posts:
    18
    Hi tonic,
    So I gave your plugin a go, it uses captive.apple.com and I can confirm this does work in China for iOS. (I've been told that in China you may not access google, facebook or twitter.) I would be interested to know if the Android version works, I've not managed to test that so I'm half minded to go with captive.apple.com as a custom URL.

    Thanks
     
  37. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    317
    Hi @noyeti, thanks for sharing your test results.

    On Android it should also work if you force the Apple2 method (captive.apple.com) instead of picking "DefaultByPlatform". (However, the opposite of trying to use Google204 method on iOS doesn't work due to iOS impl. of WWW lacking a bit).

    If you end up making further tests in China, it'd be great to hear further results. If you feel like it, perhaps you could also check if the MicrosoftNCSI method works or not. -- Also, if you do a test by running inside editor, you can actually test all of the methods (picking one instead of DefaultByPlatform), and try out if they work with your internet connection or not.
     
  38. noyeti

    noyeti

    Joined:
    Apr 25, 2014
    Posts:
    18
    Yeah I'm not in China! It was a mission to get someone to check that on iOS for us.

    It's a very nice plugin btw, I wish I picked it up earlier, it would have saved me much grief!
     
  39. gamescorpion

    gamescorpion

    Joined:
    Feb 15, 2014
    Posts:
    113
    Need some help, after switching scenes, internet dies out. When I restart my app, internet works again until I switch scenes. I've tried using IRV but no luck :(

    Any advice for this noob would be helpful :)

    Nav
     
  40. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    317
    Hi @gamescorpion, that sounds like a weird problem... although it sounds like it's not about IRV really. Hard to guess what could be a problem, but maybe you need to set some of your gameobjects with own scripts to be "DontDestroyOnLoad" so that they persist when you load a new scene? (look at the IRV Awake() method for example of how to do that)
     
  41. gamescorpion

    gamescorpion

    Joined:
    Feb 15, 2014
    Posts:
    113
    Okay figured it out, apparently when a scene changes the scripts loose their connection or something like that to the IRV, so in OnEnable of every script that uses IRV simply write the following and everything starts working fine:

    Code (csharp):
    1.  
    2.   IRV = (InternetReachabilityVerifier)FindObjectOfType(typeof(InternetReachabilityVerifier));
    3.  
    For anyone else having issues with this awesome asset like I did when changing scenes or loading new levels and returning back to a scene with IRV, the code above was the fix for me :)

    Nav
     
  42. JohnTube

    JohnTube

    Joined:
    Sep 29, 2014
    Posts:
    35
    Hey @tonic , Can you add poor/slow internet connection detection based on "heuristics" and preconfig (lowest acceptable ping, etc.) ?
     
  43. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    317
    @JohnTube, thanks for the suggestion. That's a nice idea -- but I still feel that is a bit out of boundaries of this asset.

    I think that way because the connection quality is more context sensitive with the server / service you're connecting to, than just mere existence of a connection. And I feel that doing a reasonable test should probably be done in cooperation with the service to be used, with the same connection type (tcp/udp) and traffic characteristics, for the result to be truly meaningful. I think that kind of test would be more reasonable feature for the networking library being used.
     
    JohnTube likes this.
  44. raj231

    raj231

    Joined:
    Nov 18, 2014
    Posts:
    46
    I bought your plugin and
    1. I want to check the internet connection available or not...if available and i need to do some task and if it's not available then i need to display the error message.
    2. it should check with both wifi and mobile data
     
  45. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    317
    Hi @raj231! (1.) Internet Reachability Verifier is for checking if connection to internet is available. After that when you do some task with network, you have to yourself check for error situations - using the features of network library / code you're using. For example using Unity's own WWW class check out example in the manual. Displaying error message is also up to you, using the UI system and style of your own preference.

    (2.) After you have verified internet reachability using this asset, you can check the connection type directly from Unity using Application.internetReachability, to see is it carrier data network or wifi/lan.
     
  46. JohnTube

    JohnTube

    Joined:
    Sep 29, 2014
    Posts:
    35
    @tonic I wonder how you managed to overcome/bypass this issue. Is there a workaround other than using "native/default" async methods of System.Net.HttpWebRequest/Response which requires Unity Pro or Good Ol' Sockets asset (or other assets) ?
     
  47. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    317
    I just use the value for that particular "NULL" key if there's no proper status and the key&value are present.
     
  48. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    317
    Update to version 1.0.3 is now available!

    What's new:
    • Support for Unity 5.
    • Made DontDestroyOnLoad optional.
    • Also start/stop netActivity in OnEnable/OnDisable.
     
  49. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    317
    Version 1.0.4 fixes Asset Store warning for Unity 5 users.
     
  50. sayangel

    sayangel

    Joined:
    Apr 11, 2014
    Posts:
    6
    I just purchased this asset and I'm trying to figure out how to use the callback. I want to be able to detect when someone turns on their internet connection. Is this not what the callback does?

    So if my WiFi is disabled, but then I enable it how can I be alerted?

    Thanks!