Can my iphone app communicate with a connected computer?

假装没事ソ 提交于 2019-12-21 17:07:33

问题


Preferably, this would be a computer connected via cable, but if there's a way to do it over wifi then this would also be useful. I'm wondering if it's possible to send messages between them?

Or if i had a mac app and an iPhone app, could I communicate between them over wifi or a usb connection, rather than using a server or something?


回答1:


Connecting over WiFi is possible, cable connection however isn't possible (certainly not in the documented API) unless the phone is jailbroken.

For wifi you're just going to connect to a TCP/IP host/socket. Have a look at CocoaAsyncSocket. The computer would need to be hosting some sort of server software. This is how iTunes Remote and AirMouse work.




回答2:


There are some "permitted" (non-cracked phone) ways to send data to the iPhone from a device that's physically plugged in. There are several barcode readers - like the Linēa-pro used in US Apple stores - and magstripe readers for credit cards (e.g., the Macally Quikswipe) that can send limited amounts of data to/from the iPhone.

If your computer is a small embedded device and your data requirements are meager, it may be possible.



来源:https://stackoverflow.com/questions/4847364/can-my-iphone-app-communicate-with-a-connected-computer

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