static int itdb_iphone_post_notification(idevice_t device, lockdownd_client_t client, const char *notification) { np_client_t np = NULL; uint16_t nport = 0; lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &nport); if (!nport) { fprintf(stderr, "notification_proxy could not be started!\n"); return -1; } np_client_new(device, nport, &np); if(!np) { fprintf(stderr, "connection to notification_proxy failed!\n"); return -1; } if(np_post_notification(np, notification)) { fprintf(stderr, "failed to post notification!\n"); np_client_free(np); return -1; } np_client_free(np); return 0; }
DeviceStatus Device::postNotification(string notification) { if (this->mSb == NULL) { if (np_client_start_service(this->mDevice, &this->mNp, NULL) != NP_E_SUCCESS) { return StatusError; } } np_error_t status = np_post_notification(this->mNp, notification.c_str()); if (status != NP_E_SUCCESS) { return StatusError; } return StatusOK; }
static int itdb_iphone_post_notification(idevice_t device, lockdownd_client_t client, const char *notification) { np_client_t np = NULL; #ifdef HAVE_LIBIMOBILEDEVICE_1_1_5 lockdownd_service_descriptor_t service = NULL; lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &service); if (!service || !service->port) { fprintf(stderr, "notification_proxy could not be started!\n"); return -1; } np_client_new(device, service, &np); #else uint16_t nport = 0; lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &nport); if (!nport) { fprintf(stderr, "notification_proxy could not be started!\n"); return -1; } np_client_new(device, nport, &np); #endif if(!np) { fprintf(stderr, "connection to notification_proxy failed!\n"); return -1; } if(np_post_notification(np, notification)) { fprintf(stderr, "failed to post notification!\n"); np_client_free(np); return -1; } np_client_free(np); return 0; }
static void perform_notification(idevice_t phone, lockdownd_client_t client, const char *notification) { lockdownd_service_descriptor_t service = NULL; np_client_t np; lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &service); if (service && service->port) { printf("::::::::::::::: np was started ::::::::::::\n"); np_client_new(phone, service, &np); if (np) { printf("::::::::: PostNotification %s\n", notification); np_post_notification(np, notification); np_client_free(np); } } else { printf("::::::::::::::: np was NOT started ::::::::::::\n"); } if (service) { lockdownd_service_descriptor_free(service); service = NULL; } }