Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by ConfusedExpert · Jun 29, 2016 at 07:22 AM · iosconnectioninternet

Detect if device is connected to Wifi

Hello,

I am developing an app for mobile and need to be able to tell if the device is connected to the internet via WIFI or via 3G. I have already managed to do so for the android version, using a pulgin that exposes native calls, but I can't seem to find any solution for iOS. Does somebody have any suggestions or plugins that can help me solve this issue?

Thanks in advance, ConfusedExpert

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

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by CodeElemental · Jun 29, 2016 at 08:13 AM

Can you try this approach out ? http://stackoverflow.com/questions/24351155/unity-check-internet-connection-availability

Comment
Add comment · Show 4 · 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 ConfusedExpert · Jun 29, 2016 at 11:04 AM 0
Share

This approach works for checking if the device is connected to the internet. What I would like to know is if the device is connected using WIFI, or not.

avatar image CodeElemental ConfusedExpert · Jun 29, 2016 at 11:20 AM 0
Share

Are you sure? From what i can read in the unity documentation it should work.

http://docs.unity3d.com/ScriptReference/NetworkReachability.ReachableViaLocalAreaNetwork.html

avatar image ConfusedExpert CodeElemental · Jun 29, 2016 at 12:32 PM 0
Share

Forgive me, your solution works perfectly. Thanks a lot CodinRonin!

Show more comments
avatar image
1

Answer by ntsparmar · Jun 29, 2016 at 05:29 PM

check this condition its working for me

if(Network.player.ipAddress!="0.0.0.0"){ //your are Connected in Network }

Comment
Add comment · Show 2 · 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 sapanda88 · Aug 29, 2016 at 08:41 PM 0
Share

Doesn't work for ipv6

avatar image DavidHidvegi · Oct 09, 2017 at 04:44 PM 0
Share

Very nice idea, I used this and this one works the best, but it will only work on mobile with 100% stability.

Because on PC if you insert a LAN cable and then pull it out then it reserves your IP address, so it will return true even when you are not connected to Lan nor Wifi.

avatar image
0

Answer by ankitdave · Jun 30, 2016 at 05:15 PM

@ConfusedExpert void Start() { string url = "http://google.com"; WWWForm form = new WWWForm(); WWW www = new WWW(url);

 if (www.error == null)
  {
      //means wifi or mobile data is on
     //do whatever you want here  like suppose
      Application.LoadLevel("login scene");
  }
  else
  {
     //means wifi or mobile data is off,
     //now do whatever you want to do. 
  }

}

Comment
Add comment · Show 1 · 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 265lutab · Jun 30, 2016 at 06:47 PM 0
Share

That only tells them if they are connected to the internet not whether it is a WiFi or 3G connection.

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

61 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image 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

Web Player build doesn't connect to my server, PC build works fine 0 Answers

Connecting online? 0 Answers

How Check the internet Connection Windows 2 Answers

Game lags when there is no internet (iOS) 1 Answer

cannot connect asset store via unity editor ( it is just loading) 0 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