Export devices added in Apple's iOS Provision portal
Asked Answered
B

14

23

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.

Bueno answered 17/4, 2013 at 6:11 Comment(0)
P
32

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.

Pedaiah answered 3/4, 2015 at 5:32 Comment(3)
Its jQuery code, don't you think we have to include jQuery library and then execute above code. ?Bueno
@IrfanDANISH - No, jQuery will already have been included by Apple, assuming that you're running this code in a JavaScript console on Apple's provisioning portal to extract the list of device id's. I can't really think of any other context in which the snippet would be useful.Pedaiah
As of September 2016, you need to switch names and ids on the output += line. Ids first. Then name. Otherwise it won't work. Awesome answer btw!Auk
P
29

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);
Positively answered 24/9, 2019 at 2:41 Comment(3)
This works for me without any problems. Other solutions here are outdated.Cyanogen
It works. Thanks!Elysian
This worked for me too. However need to remove non-english charactersEfrenefron
H
9

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

Huxley answered 17/4, 2013 at 6:44 Comment(3)
thanx, your solution is good and working. Don't you think apple should give simple export feature to developers :)Bueno
You're welcome :). Re your question. To be honest, I don't see this feature is really necessary - you might only need it in case of account migration, which is not a usual case.Huxley
That regexp did not do it for me. Finally came up with (.*\s)(\w+)$ and replace: \2\t\1Didache
O
7

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);
Oliveira answered 2/1, 2020 at 11:23 Comment(1)
Works in 2022..Paedo
C
6

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".

Carrillo answered 30/8, 2017 at 16:4 Comment(0)
C
5

None of the above worked for me, most likely because Apple changed the format. But what did work perfectly was the following:

  • copy/paste all the items from Apple's devices page
  • paste into Numbers, device ID and names are recognised as 2 distinct columns
  • drag the column order so devices are first rather than names
  • copy/paste all rows into a text file
  • upload to Apple and you're done
Curitiba answered 26/9, 2013 at 14:57 Comment(0)
K
2

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");
}
Knotweed answered 11/6, 2019 at 7:18 Comment(0)
G
2

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

Gimp answered 26/10, 2022 at 17:38 Comment(0)
K
1

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.

Kerb answered 17/4, 2013 at 6:38 Comment(2)
Great tool, but it doesn't work anymore :( Due to an update by Apple to the Dev Center on April 7th, the current version of Cupertino does not work. For lack of a public API, Cupertino relied on screen-scraping to get its information, so a change in the structure of the site breaks the functionality of the CLI. We are working quickly to restore compatibility with the next release. Thanks for your patience.Huxley
I totally missed that :( hopefully they get it fixed soon.Kerb
E
1

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

This is screenshot: enter image description here

Eulalie answered 22/12, 2020 at 8:29 Comment(1)
This imo is the best answer, although hacky, as it uses internal Apple API which can be used to source information the public api doesnt show.Megaphone
C
1
// 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://mcmap.net/q/554096/-export-devices-added-in-apple-39-s-ios-provision-portal


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);
Clarkclarke answered 1/8, 2022 at 6:5 Comment(0)
C
0

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.

Captainship answered 31/3, 2017 at 20:32 Comment(0)
D
0

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):

enter image description here

In Chrome, you can right-click the resulting array and click Copy Object:

enter image description here

You'll get a big JSON object you can paste into any editor. In VSCode I did the following:

  1. ⌘+K, ⌘+M - format as JSON
  2. Do a find and replace of spaces and quotes at the beginning and end of the line (replace " with nothing, and ", also with nothing)
  3. Copy the contents of each array, paste into a spreadsheet column. Done.
Dutchman answered 26/5, 2022 at 13:58 Comment(0)
P
0

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);
Paedo answered 11/10, 2022 at 15:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.