このように検出できます。プライベートAPIの必要はありません
static void _callback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo)
{
if ([(__bridge NSString*)name isEqualToString:@"com.apple.mobile.lockdown.host_attached"])
{
NSLog(@"USB connected");
}
else if ([(__bridge NSString*)name isEqualToString:@"com.apple.mobile.lockdown.host_detached"])
{
NSLog(@"USB disconnected");
}
}
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, _callback, CFSTR("com.apple.mobile.lockdown.host_attached"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, _callback, CFSTR("com.apple.mobile.lockdown.host_detached"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
助けてください –