Communication between two iOS devices - iphone

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

Related

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/

Direct VoIP call from one iOS device to another

I'am going to develop peer-to-peer VoIP iOS application. And want do it without any SIP proxy, SIP providers and other servers. Just VoIP calls frpm iOSdevice-to-iOSdevice. Both iOS device could be somewhere in Internet. Is it real in VoIP (with PJSIP for example and general with SIP)?
Could you please point me to main keys that I need for development.
I have already read these topics. Is it real solve problems with addressing in my configuration. PJSIP could help with correcting addressing?
Look at Apples Multipeer Connectivity framework. I have built an app that does exactly what you want. If you look to my profile and the questions I have asked you will get some good guidance. Though I recommend you do it with a backend since MultiPeer wasn't the best solution, atleast when it comes to supporting multiple peers and to be able to call another device that has the app in the background.
See Frank Shearar's Answer Here
In short, it looks like this would be a very difficult task.
Another option would be to use the Twilio SDK for iPhone (Obj-C). This would work well for what you're trying to do and would be a whole lot easier. Link

How to do peer-to-peer communication in an iPhone app?

I'm trying to write a simple chat application for the iPhone (as an experiment). Is there a simple way for two devices to discover each others' IP addresses, and given the addresses is there a simple API or protocol that would let me send text messages back and forth?
I've investigated SIP (specifically Sofia and eXosip), but these tools exist as C libraries and are beyond my current ability to port them to the iPhone.
Update: I'm trying to connect two devices over the Internet (i.e. not over Bluetooth or a local wireless network, which is what GameKit does).
You're going to need a server that provides the match making service. Game Center makes this pretty easy, but your users will have to have Game Center accounts.
Alternatively, you can set up an XMPP (formerly Jabber, it's what powers Google Chat) server (I've never done this, but there are several available) and use the XMPP Framework for Cocoa. There are instructions for using it in iPhone apps here.
I'm sure there are other chat servers and client source also available. IRC and Mobile Colloquy come to mind.
Finally, you could write your own server using your favorite server language / framework. This isn't too hard (I've done it myself), but it's far from what I'd call simple, and I wouldn't use it for a production system.
There is support for exactly this kind of ad-hoc peer-to-peer networking in GameKit. Have a look at the second half of the GameKit documentation for details:
http://developer.apple.com/library/ios/#documentation/...
NSNetService is a good option.
Take a look at WebRTC Datachannels. WebRTC is a newer option with native iOS support a standard that is still being finalized, but it is more flexible should the iOS app need to communicate with browser or even android peers

about file sharing in iphone sdk?

i saw one application in App store.(files lite by olive toast). inwhich they have used
web server(webDAV url) to transfer file from PC to ipod or iphone and also another option bonjour.how can i use bonjour (what is it ?)..how can i do for my application?
internally how they have done?any help please?
Bonjour is Apple's "Zero-configuration networking". Essentially it allows you to advertise a service on the network by name, allowing other machines on the local network to discover it. There's plenty of high quality documentation available from Apple. Just google it.
Bonjour is just a way for your desktop application to discover the ip address of the iPhone. To actually transfer data to or from your device, you need to write that code yourself. Unfortunately Apple doesn't provide a framework to do this.
Some people use WebDAV, implemented with an open source framework.
Another option is to use ZSync, if you are using Core Data:
http://www.zarrastudios.com/ZSync/ZSync.html

Finding the systems connected in local network from iPhone?

I am developing an application which identifies(find) all the systems connected in same network/LAN to share the data.
could please share with me how to identify(find) the systems which are connected in same network/LAN.
thanks in advance.
When you say all systems, I assume you mean all instances of your application? If so then the correct solution is to use Bonjour. Documentation on how to use it can be found here. Note that your app needs to be actively running on all the devices that you are trying to discover, since the iPhone does not support background apps.
If you are just talking about finding all other devices in the area then you need to resort to techniques like port scanning.