Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How to detect when a player's internet connection becomes active?

Discussion in 'Scripting' started by jerotas, Jun 12, 2015.

  1. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,555
    Hi, I'm wondering how ho detect when a player connects to the internet. Like if they had wi-fi turned off, then turned it on and connected to their network.

    I need to know when that happens so I can try to fetch an ad again (previous attempts will have failed). Does MonoBehaviour have an event like that, or do we have to just keep doing it every 1 minute or something when ad fetching fails?
     
  2. Sean-Powell

    Sean-Powell

    Joined:
    Dec 18, 2014
    Posts:
    87
    what system are you using?
     
  3. alijib

    alijib

    Joined:
    Nov 14, 2014
    Posts:
    17
    I think use Network class (which is used to check player connection status).

    Then there is Application.InternetReachibility status
     
  4. Sean-Powell

    Sean-Powell

    Joined:
    Dec 18, 2014
    Posts:
    87
    The Application.InternetReachability is not meant for checking if the device is connected to the internet, it is for checking if it is using mobile data or WiFi. The NetworkReachablity function, tells you if the device is connected to the internet by any source
     
    alijib and Mycroft like this.
  5. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,555
    Yeah I know about those, I was hoping there was an actual event that fires when it changes so we wouldn't have to keep checking periodically.

    I'm using iOS.
     
  6. eisenpony

    eisenpony

    Joined:
    May 8, 2015
    Posts:
    971
    Last edited: Jun 12, 2015
  7. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,555
    Thanks! I'll check it out.
     
  8. Sean-Powell

    Sean-Powell

    Joined:
    Dec 18, 2014
    Posts:
    87
    give a suggestion to the unity devs to see if they can do it
     
  9. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    But wouldn't the thing that's going to file off the event need to be checking periodically anyway? I'd rather be in control of that rather than have something checking on by behalf in situations when I don't care to know.