Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by Tim-Michels · Jan 21, 2013 at 02:19 PM · mobilewwwconnectioninternetping

Best way to check internet connectivity (Android + iOS)

We're developing an app, which has to maintain an internet connection to communicate with our Smartfox servers. Before connecting to our Smartfox, we need to know if there's a stable internet connection. We have tried several approaches, Ping, WWW, Application.internetReachability, but we haven't found a profound solution that runs great on both our release platforms (Android & iOS)

Maybe we're missing something here, but in our case, the Ping solution would be the most logical, since we can Ping directly to the IP-adress of our Smartfox-servers, but this approach has given us a lot of headaches, because it's really unpredictable on Android.

Any help/tips are greatly appreciated, just bear in mind that we have to have a continuous check if we are connected to the internet (not just LAN)

Thanks in advance

btw: we're using Unity 3.5.7f6

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

4 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Straafe · Sep 30, 2013 at 09:54 PM

I ran into the same problem. I ended up just using hs_get to contact my database server and made a small script on it that simply returned a 0 when ran, so in Unity if I got a zero back, I was connected to the internet, if I got a null or anything else back, I was not. Worked for Android where ping failed.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by tonic · Aug 17, 2014 at 03:22 PM

(Adding a comment to an old posting in case somebody finds this using search...)

Indeed a working way is to make a WWW query with a known answer. This is called "captive portal detection" in operating systems, to verify if login WWW page should be presented to an user. This happens when a user connects to a network with a login page to gate actual access to internet.

I have made an easy asset called Internet Reachability Verifier for Unity, which implements this technique, offering chance to use one of the verification URLs from the big OS vendors or your own custom URL. Works with Desktop, Mobile and Webplayer platforms (need to self-host a file in originating server for Webplayer).

More info here: http://j.mp/IRVUN

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by grujicbr · Aug 19, 2014 at 06:39 PM

Hi,

I have released a event based plugin for ios that lets you do exactly this without having to do it manually. It is very easy to use and works on all ios devices. Android version is on works as well

https://www.assetstore.unity3d.com/en/#!/content/19869

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by KEric · Mar 17, 2020 at 09:09 AM

I've created an Android's library that can be used as Unity's plugin for this purpose. If anyone's interested it's available under https://github.com/rixment/awu

As for the iOS version unfortunately I don't have enough of knowledge in this area. It would be nice if someone could extend the repo to include the iOS version too.

Cheers!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

12 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Ping class producing false positives, alternative to check connectivity? 3 Answers

yield return WWW stops Coroutine? 0 Answers

Detecting internet availability on Android 7 Answers

Android game: allow internet for just specific domain 0 Answers

Detect if device is connected to Wifi 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges