Communication between two iOS devices

北慕城南 提交于 2019-11-30 12:26:29

问题


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.


回答1:


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.




回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/11402263/communication-between-two-ios-devices

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!