foreach ($result['devices'] as $device) {
    if ($_GET['udid'] == $device['deviceNumber']) {
        $device_found = true;
        break;
    }
}
if ($device_found) {
    echo '<p>The device is already registered.</p>' . PHP_EOL;
    echo '<p>UDID: ' . $device['deviceNumber'] . '</p>' . PHP_EOL;
    echo '<p>deviceId: ' . $device['deviceId'] . '</p>' . PHP_EOL;
    echo '<p>name: ' . $device['name'] . '</p>' . PHP_EOL;
    //TODO: $result = AppleServices::updateDevice($deviceId);
} else {
    echo '<p>This device is not yet registered.</p>' . PHP_EOL;
    //TODO load $device and gat name to add it to Apple.
    $result = AppleServices::addDevice($_GET['udid'], 'iPhone de TODO', $team_id);
    if ($result['resultCode'] != 0) {
        Tools::dieError($result['userString']);
    }
    echo '<p>Device added.</p>' . PHP_EOL;
    foreach ($result['devices'] as $device) {
        if ($_GET['udid'] == $device['deviceNumber']) {
            $device_id = $device['deviceId'];
            // this is an id usefull for WS not the UDID
            break;
        }
    }
    echo '<p>Device id on server:' . $device_id . '</p>' . PHP_EOL;
}
$result = AppleServices::listProvisioningProfiles($team_id);
if ($result['resultCode'] != 0) {