Xcode IOS Connect to a specific wireless network using SSID and Password - iphone

I'm currently creating an iPhone app (Xcode 4.3.1, IOS 5) that has to work with wi-fi routers! Main goal of this application is indoor navigation (GPS inside buildings isn't really accurate).
One solution could be to scan all available wi-fi and then my application could make it's job! But as far as I looked into all documentations and dozens of articles, Apple doesn't provide any API to scan available wireless networks (actually there are some ways to get around this problem, but if you use them your app will be rejected from AppStore)..
Second solution could be just to connect to specific wi-fi access points!
All these access points are pre-written inside code, something like:
SSID: myHomeWifi; Password: somePassword; ... etc.
My app could try to connect or at least access or ping each of these routers and then make calculations.
So the question is.. is there any way to make connection with some wifi access point if I have all private data of the router?
any advice would be appreciated!
thanks!

Related

How to get available all wifi network name Listing in swift

I have a simple question but I don't know how to implement this. I need to create an app that can get all list of available wifi networks names and information when the user clicks on some network iPhone have to connect to this network. Can I do this? and How. Please Help me.
answer is no in some case you get list of nearer wifi but can't connect.(its also not advisable)
details :-
prefer below links to get wifi list:
How to get available wifi network name in iOS using swift
iOS Get list of all WiFi networks
some similar questions for reference:
Connect to WiFi programmatically in ios
connect to a specific wifi programmatically in ios with a given SSID and Password
Where do I find iOS Obj-C code to scan and connect to wifi (private API)
Programmatically auto-connect to WiFi iOS
The most interesting answer seems to be in the first link which points to a GitHub project: wifiAssociate. However someones in the third link explains that this doesn't work anymore with iOS8 so you might have hard time getting it running.
Furthermore the iDevice must be jailbroken.
i hope it will help you :)

Peer-to-peer communication between iOS devices

I am trying to prototype a solution to a problem and am currently exploring multiple routes I could try. Is it possible for one iOS device, running a certain app, to communicate directly with another iOS device, running the same application - without the need to be on the same LAN?
Solutions I am currently investigating are using Bluetooth and ad-hoc wireless connections.
Ideally, the application when installed would ask the user for the required permissions, and then would accept and/or send data to/from another client after a handshake had happened.
My concern with Bluetooth is that 'pairing' would need to happen with every device, rather than happen in the background once the user has installed the app. I have a feeling what I am talking about isn't possible from what I've been reading elsewhere on Stackoverflow.
Take a look at Bluetooth Low Energy.
https://developer.apple.com/library/ios/#samplecode/BTLE_Transfer/Introduction/Intro.html#//apple_ref/doc/uid/DTS40012927
Here is another example,
https://github.com/KhaosT/CBPeripheralManager-Demo
You might also want to look into GameKit and peer-to-peer connectivity there.
I can't tell you anything about it, but you might try looking at iOS 7. If that's an option, I'd take a look. Can't talk about what it is because of NDA though.
Depending on what you need to communicate, you could try checking out this project, which lets you share arrays of strings between iOS devices over Bluetooth LE.
You don't need to "pair" the devices and it can still communicate while the app is in the background. SimpleShare
Hope it helps!
From the documentation of MultipeerGroupChat:
MultipeerGroupChat sample application utilizes the Multipeer Connectivity framework to enable nearby users to discover, connected, and send data between each other. This sample simulates a simple chat interface where up to 8 devices can connect with each other and send text messages or images to each other. Here you will learn how to bring up framework UI for discovery and connections and also how to monitor session state, listen for incoming data and resources, and send data and resources.
This is an excellent example at developer.apple.com here is the link
https://developer.apple.com/library/ios/samplecode/MultipeerGroupChat/Introduction/Intro.html
Also this tutorial from Ralf Ebert demonstrates how to use Multipeer Connectivity framework for peer communication should help you.
https://www.ralfebert.de/tutorials/ios-swift-multipeer-connectivity/

How to detect all available Wifi networks and connect to one of them in an iOS app

In my iOS app, I want to detect all available wifi networks and then choose one network form the list and connect to it. The goal is to not open the Settings built in app to connect to a wifi, but to do it all in my app.
First, is this possible? If possible, please point me to what framework(s) and methods to use.
I have looked at the Reachability example, but that doesn't work for me because, I think, all it does is monitor the network state of the device.
I also looked at the Captive Network Support framework, and used the CNCopySupportedInterfaces function:
CFArrayRef allWifiNetworks = CNCopySupportedInterfaces();
NSLog(#"%#", allWifiNetworks);
but all I am seeing is the current wifi network that the device is connected to.
Thanks
I'm pretty sure you can't do this, at least not if you want to be able to publish on the App Store.

Communication between two iOS devices

I am looking for a way to have one iPhone app send a message to another app on a different phone (sort of like a Sender-Receiver set up). I am looking for the best possible way to do this. Does anyone have any ideas and/or tutorials?
Thanks for the help.
You should use GameKit. It is super easy to send messages between two iOS devices using it. Here's a great tutorial: Game Kit. You can also get more information about it here from the docs: About Game Kit.
You communicate by creating an ad-hoc bluetooth or local wireless network.
lmirak provided insightful info about device communication(especially about GameKit). I would like to add one more solution. You can use WiFi network to do your device communication.
See the link or download the sample application from developer.apple
The sample application named as WiTap. It demonstrates how to achieve network communication between applications. Using Bonjour, the application both advertises itself on the local network and displays a list of other instances of this application on the network.
If your app is only going to run on iOS, then you should use the fantastic MultipeerConnectivity library. https://developer.apple.com/documentation/multipeerconnectivity
If you need a solution that will work cross-platform, then one way to accomplish this is using sockets and connecting over a local network. On iOS you can use CocoaAsyncPods for sockets and NetService for discovery.
Here is a basic example app that does this: https://github.com/brendaninnis/LocalNetworkingApp
, which I explain in great detail here: http://brendaninnis.ca/connect-nearby-devices-part-1.html

How to display a list of Wifi-Networks in an iPhone app?

I found some private (undocumented) APIs but Apple does not allow apps to use private frameworks. So does anyone know how to do this using Apple official packages?
like: when youtube app prompts you to the push notification: "Select a Wi-fi network"
Thanks in advance.
If you set the UIRequiresPersistentWiFi setting in your info.plist file, the iPhone OS will know that your app needs Wifi and pop up the message for you.
As far as I know, no app actually manually displays the wifi selection alert.
Thats wrong check this app out
http://itunes.apple.com/us/app/ihome-connect-setup-app-for/id450241802?mt=8
It shows available wifi networks
The best you can do in iOS, currently, is display the network the user is currently connected to. iOS doesn't allow you to access a wifi scan from within an app. I've been wrestling with this inability for some time now.
If designing an accessory that has WiFi, where you're trying to pass the user's WiFi network SSID and password, it will be up to the accessory to give the app that wifi scan list. The app can then display the list the accessory gave it to the user.
(I bet that's how the app #zaid pointed out in his answer, "iHome Connect", is doing it.)
Another approach is you could have a screen that prompts the user to enter the password to the wifi network they're connected to already, and then once the accessory is connected to the app, pass those details without the need for a wifi network list. I think that approach has a better user experience.
Plenty of stackoverflow questions that answer how to get the current wifi network, here's a couple:
Getting OSX Connected Wi-Fi Network Name
How do I get the current wifi network name after Yosemite in Swift?