Reputation: 8489
My apple developer is about to expire in 5 days. And after renewal I want to restore my devices count to 100 but meanwhile I want to export all currently added devices as backup for future use, these are 87 devices.
In new apple developer section I don't see any option to export all devices and I don't want to copy paste all 87 devices :(
Note: I want to export devices in the format required by the Apple for multiple device inserts.
Upvotes: 23
Views: 12063
Reputation: 141
Used right now and compatible with all devices, iPhone, iPad and Mac:
var data = document.querySelectorAll(".infinite-scroll-component .row");
var csvOutput = "Device ID Device Name Device Platform\n"
for (var i = 1; i < data.length; i++) {
let name = data[i].childNodes[0].childNodes[0].textContent;
let identifier = data[i].childNodes[1].childNodes[0].textContent;
let type = data[i].childNodes[2].childNodes[0].textContent;
switch(type) {
case "iPhone":
case "iPad":
type = "ios";
break;
case "Mac":
type = "mac";
break;
}
let device = [identifier, name, type].join(" ") + "\n";
csvOutput += device;
}
console.log(csvOutput);
If import fails just check if you have some Device Name using special characters
Upvotes: 2
Reputation: 13283
In my case, I'm under two different accounts but the same company. The new account needs the same list of devices from the old account.
So I wanted to export the list of the devices from the old one and import them to the new one.
Based on the sample file of Apple, the batched or multiple device upload should look like this:
Device ID Device Name Device Platform
A123456789012345678901234567890123456789 NAME1 ios
B123456789012345678901234567890123456789 NAME2 ios
A5B5CD50-14AB-5AF7-8B78-AB4751AB10A8 NAME3 mac
A5B5CD50-14AB-5AF7-8B78-AB4751AB10A7 NAME4 mac
After playing with the query in the console, I came up with this code. Courtesy of user Behdad.
var data = document.querySelectorAll(".infinite-scroll-component .row");
var csvOutput = "Device ID Device Name Device Platform\n"
for (var i = 1; i < data.length; i++) {
let identifier = data[i].childNodes[1].textContent;
let name = data[i].childNodes[0].textContent;
//let type = data[i].childNodes[2].textContent; //iphone, ipod, ipad
let type = "ios"
let device = [identifier, name, type].join(" ") + "\n";
csvOutput += device;
}
console.log(csvOutput);
Upvotes: 0
Reputation: 39
// Does not parse iPod device ids properly
// Order of platform, identifier and name is important while creating file, do not change..
// Save file extension as ".deviceids"
// Use this JS script in browser in device id's page. This script is useful when device names has space characters..
// Make sure device name does not have multi-byte characters. Apple allows UTF-8 characters only.
// Based on https://stackoverflow.com/a/58072373/4658933
var data = document.querySelectorAll(".infinite-scroll-component .row");
var header = `<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Device UDIDs</key>
<array>`;
var footer = `</array>
</dict>
</plist>`;
var deviceListString = "";
for (var i = 1; i < data.length; i++) {
// deviceListString += (data[i].childNodes[1].innerText + "\t" + data[i].childNodes[0].innerText + "\t" + (data[i].childNodes[2].innerText == "iPhone" || data[i].childNodes[2].innerText == "iPad" || data[i].childNodes[2].innerText == "Apple Watch" ? "ios" : "mac") + "\n");
deviceListString += `<dict>`
deviceListString += `<key>devicePlatform</key><string>${(data[i].childNodes[2].innerText == "iPhone" || data[i].childNodes[2].innerText == "iPad" || data[i].childNodes[2].innerText == "Apple Watch" ? "ios" : "mac")}</string>`;
deviceListString += `<key>deviceIdentifier</key><string>${data[i].childNodes[1].innerText}</string>`;
deviceListString += `<key>deviceName</key><string>${data[i].childNodes[0].innerText}</string>`;
deviceListString += `</dict>`
}
console.log(header + deviceListString + footer);
Upvotes: 1
Reputation: 700
I can't believe it's been 5 years, and Apple hasn't added an "Export" button!
So here's one I wrote š Paste this in the browser console:
// Create an array with values 1..4
[ ...Array(4).keys() ].map( i => i+1).map(
// For each, get the appropriate column and extract the text.
(i) => Array.from(new Set(document.querySelector(".infinite-scroll-component ").querySelectorAll(`div.row > span:nth-child(${i})`))).map((node) => node.innerText),
)
The console output will look like this (one array for every table column):
In Chrome, you can right-click the resulting array and click Copy Object
:
You'll get a big JSON object you can paste into any editor. In VSCode I did the following:
"
with nothing, and ",
also with nothing)Upvotes: 0
Reputation: 600
As of March 2021 this snippet that I have created (mixture of T.Nhan's answer above and Apple guidelines of upload format) works out of the box by just saving output in a .txt file and upload:
var data = document.querySelectorAll(".infinite-scroll-component .row");
var deviceListString = "Device ID\tDevice Name\tDevice Platform\n"
for (var i = 1; i < data.length; i++) {
deviceListString += (data[i].childNodes[1].innerText + "\t" + data[i].childNodes[0].innerText + "\t" + (data[i].childNodes[2].innerText == "iPhone" || data[i].childNodes[2].innerText == "iPad" || data[i].childNodes[2].innerText == "Apple Watch" ? "ios" : "mac") + "\n");
}
console.log(deviceListString);
Upvotes: 30
Reputation: 660
In my case, I also want to get the device model (ex, iPhone X, iPhone 8....)
You can get any device info base on UDID with object var object = JSON.parse(this.responseText);
var data = document.querySelectorAll(".infinite-scroll-component .row");
var deviceListString = ""
var databody = JSON.stringify({
teamId: 'XXXXXXXX' // your team id here
})
for (var i = 1; i < data.length; i++) {
var xhr = new XMLHttpRequest()
xhr.withCredentials = true
xhr.addEventListener('readystatechange', function() {
if (this.readyState === this.DONE) {
var object = JSON.parse(this.responseText);
deviceListString += object.data.attributes.name + "\t" + object.data.attributes.model + "\t" +object.data.attributes.udid + "\n";
}
})
var rowID = data[i].getAttribute('data-id');
var url = `https://developer.apple.com/services-account/v1/devices/${rowID}?fields[devices]=name,udid,platform,model,status,devicePlatformLabel`
xhr.open('POST', url);
xhr.setRequestHeader('content-type', 'application/vnd.api+json');
xhr.setRequestHeader('x-http-method-override', 'GET');
xhr.send(databody);
}
When you type enter, the result was stored in deviceListString So just get that value
deviceListString
Upvotes: 1
Reputation: 991
Looks like the webpage structure has been edited a little since the latest response. My new snippet also formats the output as CSV, so you can save the output and open it with Numbers/Excel and share it.
var data = document.querySelectorAll(".infinite-scroll-component .row");
var csvOutput = "Name, Identifier, Type\n"
for (var i = 1; i < data.length; i++) {
let name = data[i].childNodes[0].childNodes[0].textContent;
let identifier = data[i].childNodes[1].childNodes[0].textContent;
let type = data[i].childNodes[2].childNodes[0].textContent;
let device = [name, identifier, type].join(", ") + "\n";
csvOutput += device;
}
console.log(csvOutput);
Upvotes: 7
Reputation: 188
Nowaday, Apple doesn't have JQuery anymore. We can use this query to get
var data = document.querySelectorAll(".infinite-scroll-component .row");
for(var i = 0 ; i < dencho.length; i++){
var name = data[i].childNodes[0];
var id = data[i].childNodes[1]
console.log(name.innerText + "\t" + id.innerText + "\n");
}
Upvotes: 2
Reputation: 61
You can use a command tool call Spaceship, it exposes both the Apple Developer Center and the iTunes Connect API
Here is how I did to migrate all my devices from my Apple Developer account to a second one.
spaceship1 = Spaceship::Launcher.new("[email protected]", "password")
spaceship2 = Spaceship::Launcher.new("[email protected]", "password")
#Get all devices from the Apple Developer account 1.
devices = spaceship1.device.all
#Loop through all devices from account 1 and then add/create them in account2.
devices.each do |device| spaceship2.device.create!(name: device.name, udid: device.udid) end
Note: To quickly play around with spaceship launch irb in your terminal and execute require "spaceship".
Upvotes: 6
Reputation: 1281
My solution to this was to create new provisioning profile here and add all devices to it. Then download it and open with vim (or any other editor). The file will contain some binary style and plist (xml) with all your devices, which can be parsed I guess, but I just c&p device list. Smth like:
<key>ProvisionedDevices</key>
<array>
<string>device1 udid</string>
....
<string>deviceN udid</string>
</array>
Delete your provisioning profile if you don't need it after.
Upvotes: 0
Reputation: 54796
If you're looking for an option that doesn't require additional software, recordings, or fiddling with regular expressions, here's a JavaScript snippet you can run in Chrome's (or I'd assume, any other browser's) JavaScript console to get a properly-formatted device list:
var ids = ["Device ID"];
var names = ["Device Name"];
$("td[aria-describedby=grid-table_name]").each(function(){
names.push($(this).html());
});
$("td[aria-describedby=grid-table_deviceNumber]").each(function(){
ids.push($(this).html());
});
var output = "";
for (var index = 0; index < ids.length; index++) {
//output += names[index] + "\t" + ids[index] + "\n"; //original
output += ids[index] + "\t" + names[index] + "\n"; //post September 2016
}
console.log(output);
The complete export will be logged to the console, at which point you can simply copy/paste it into an empty text document, which can then be re-imported back to Apple at any time.
This works with Apple's current developer site layout, as of April 2015. Obviously it may break if they change stuff.
Upvotes: 32
Reputation: 436
None of the above worked for me, most likely because Apple changed the format. But what did work perfectly was the following:
Upvotes: 5
Reputation: 9593
Open list of devices safari, chrome or firefox&firebug. Open web inspector (opt-cmd-i in safari), go to instrument tab (ctrl+3). Press "Start Recording" button and refresh page.
In the very bottom of the appeared list find "listDevices.action" and select it. In the right column of a web inspector copy & paste full URL and download JSON file with a list of devices. Then, with a simple regexp (i.e. /\"name\": \"([^\"]+)\",\n\s*\"deviceNumber\": \"([^\"]+)\"/ ) you can get devices' name and number.
Format that Apple accepts for upload is
Device ID Device Name
A123456789012345678901234567890123456789 NAME1
B123456789012345678901234567890123456789 NAME2
Update:
Ah! Apple now provides a full deviceNumber on "iOS devices" page, so it makes whole process easier. Copy-paste the list in, for example, Sublime text and put devices' name and number in a proper order:
find: /^(.*) +([^\n]+)\n/
replace: \2\t\1\n
Upvotes: 9
Reputation: 20993
Check out Mattt's command line interface tool, Cupertino
You can run ios devices:list
to get the list of devices on your account.
It probably isn't the exact format for Apple's importer, but it should get you to a good point, there is also ios devices:add
that will let you re-add your devices from the command line.
Upvotes: 1