How to determine whether iOS device is connected to desktop computer (and iTunes)
Is there way to determine whether an iOS device is connected to a desktop computer usi开发者_如何学编程ng USB cable and it is listed on iTunes.
Yes you can be notified of such events using The External Accessory framework.
"It is capable of sending notifications whenever a hardware accessory is connected or disconnected. Although it is capable, it does not do so automatically. Your application must specifically request that notifications be generated by calling the registerForLocalNotifications method of the EAAccessoryManager
class. When an accessory is connected, authenticated, and ready to interact with your application, the framework sends an EAAccessoryDidConnectNotification
notification. When an accessory is disconnected, it sends an EAAccessoryDidDisconnectNotification
notification. You can register to receive these notifications using the default NSNotificationCenter
, and both notifications include information about which accessory was affected."
精彩评论