diff --git a/MobileDevice.h b/MobileDevice.h index d97eafb..8c9ff91 100644 --- a/MobileDevice.h +++ b/MobileDevice.h @@ -195,6 +195,10 @@ mach_error_t AMDeviceNotificationSubscribe(am_device_notification_callback callback, unsigned int unused0, unsigned int unused1, void* //unsigned int dn_unknown3, struct am_device_notification **notification); + +mach_error_t AMDeviceNotificationUnsubscribe(am_device_notification subscription); + + /* Connects to the iPhone. Pass in the am_device structure that the * notification callback will give to you. * diff --git a/ios-deploy.c b/ios-deploy.c index b9babc1..2cf16eb 100644 --- a/ios-deploy.c +++ b/ios-deploy.c @@ -180,6 +180,7 @@ pid_t child = 0; const int SIGLLDB = SIGUSR1; AMDeviceRef best_device_match = NULL; NSString* tmpUUID; +struct am_device_notification *notify; // Error codes we report on different failures, so scripts can distinguish between user app exit // codes and our exit codes. For non app errors we use codes in reserved 128-255 range. @@ -1714,7 +1715,8 @@ void device_callback(struct am_device_notification_callback_info *info, void *ar switch (info->msg) { case ADNCI_MSG_CONNECTED: if(device_id != NULL || !debug || AMDeviceGetInterfaceType(info->dev) != 2) { - handle_device(info->dev); + AMDeviceNotificationUnsubscribe(*notify); + handle_device(info->dev); } else if(best_device_match == NULL) { best_device_match = info->dev; CFRetain(best_device_match); @@ -1967,7 +1969,6 @@ int main(int argc, char *argv[]) { NSLogOut(@"[....] Waiting for iOS device to be connected"); } - struct am_device_notification *notify; AMDeviceNotificationSubscribe(&device_callback, 0, 0, NULL, ¬ify); CFRunLoopRun(); }