Search code examples
iosobjective-ccocoa-touchwifi

How to connect to wifi


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"...


Solution

  • 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.