4

Can it be done? Opening the wifi settings is possible, but I dont know how to connect to a specific wifi network.

this code:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=WIFI"]];

opens the iPhone wifi settings dialog. Is there any way to compose the URL name? For example "prefs:root="WIFI&path=wifi_name"...

vikingosegundo
  • 52,040
  • 14
  • 137
  • 178
user1581203
  • 43
  • 1
  • 4
  • possible duplicate of [iPhone: How to detect and connect to a Wifi network programmatically using Apple SDK](http://stackoverflow.com/questions/2341657/iphone-how-to-detect-and-connect-to-a-wifi-network-programmatically-using-apple) – Cyrille Aug 07 '12 at 07:43

2 Answers2

2

This is possible inside an app, but I believe it is not allowed by Apple guidelines. You should be detecting if there is a networking connection either via WWAN or WiFi or if you can connect to a specific host via a URL. Please see Apple Reachability code for the full implementation for the Reachability code produced by Apple. So this is already done for you.

Popeye
  • 11,839
  • 9
  • 58
  • 91
  • If you can detect a WiFi network via the reachability code then you could then implement the option to connect to one of those connection. But you can not do it in the background without the user knowing. – Popeye Aug 07 '12 at 07:56
  • @user1581203 I am unsure how to do that part, but your better off learning how the Reachability works for anyway. Also not many apps do it because the iPhone will do most of it for you anyway. Such as if you have connected already it will auto connect, if you haven't connected when you try most phones these days will already ask you or at least tell you there are networks that have not been connected too. So your most wasting your time. – Popeye Aug 07 '12 at 08:17
  • The Reachability code us to be a requirement for Apple submission but because they do a lot for you its not need any more. But it is good to tell the user they can't connect to your host address if there is an issue. So my recommendation unless it is really needed is just to stick to the Reachability code, and make it your own. – Popeye Aug 07 '12 at 08:17
  • Yes, it does. Moreover, iOS 5.1 breaks the settings apps URL schemes. ouh yeah! iPhone couldnt do it more difficult for me. Any suggestion? – user1581203 Aug 07 '12 at 14:29
  • Sorry I am unable to help then. From my experience, and some research I have done I don't believe you will find an answer to this anytime soon. Your probably best of experimenting see what you can do, but please be aware you may be heading into a world of pain, and time wasting if Apple will not accept it. Good Luck – Popeye Aug 07 '12 at 14:58
0

I wouldn't expect this to be possible because of the security risks invovled. Imagine an app that messes with your WiFi settings without your knowledge and permission.

dandan78
  • 13,328
  • 13
  • 64
  • 78
  • Come on. Android can do this and acknowledge you the permission when you install the app. Why not iOS do something similar. – Yeung Sep 06 '13 at 10:19