thebeet / idevicekit

NodeJs wrapper for libimobiledevice
Other
29 stars 7 forks source link
ios libimobiledevice nodejs

NodeJs wrapper for libimobiledevice

Requirements

brew install libimobiledevice
brew install ideviceinstaller

Getting started

Install via NPM:

npm install --save idevicekit

API

idevicekit.listDevices()

Gets the list of currently connected devices.

idevicekit.getProperties(serial, [option])

Retrieves the properties of the device identified by the given serial number. This is analogous to ideviceinfo.

idevicekit.getPackages(serial, [option])

Retrieves the list of packages present on the device. This is analogous to ideviceinstaller.

idevicekit.screencap(serial)

Takes a screenshot in PNG format using idevicescreenshot.

idevicekit.install(serial, ipa)

Installs the IPA on the device, This is analogous to ideviceinstaller -i <ipa>

idevicekit.syslog(serial)

Retrieves syslog on the device, This is analogous to idevicesyslog

idevicesyslog will continue running until a 'close' event emit to emitter

idevicekit.reboot(serial)

reboot using idevicediagnostics restart.

idevicekit.shutdown(serial)

reboot using idevicediagnostics shutdown.

shortcut API

idevicekit.getBasicInformation(serial, [option])

Basic device information from Apple, such as CPU, RAM, Official Name

getResolution(serial)

getStorage(serial)

getBattery(serial)

Example

let co = require('co');
let idevicekit = require('./index');
let fs = require('fs');

co(function* () {
    let devices = yield idevicekit.listDevices();
    for (let device of devices) {
        let properties = yield idevicekit.getProperties(device);
        let battery = (yield idevicekit.getBattery(device)).level;
        let resolution = yield idevicekit.getResolution(device);
        let status = yield idevicekit.getDeveloperStatus(device);
        console.log(`${device}: ${properties['DeviceName']}`);
        console.log(`    model: ${properties['ProductType']}`);
        console.log(`    battery: ${battery}`);
        console.log(`    resolution: ${resolution['width']}x${resolution['height']}`);
        console.log(`    status: ${status}`);
        let screenshotStream = yield idevicekit.screencap(device);
        screenshotStream.pipe(fs.createWriteStream(device + '.png'));
        idevicekit.syslog(device).then((emitter) => {
            emitter.on('log', (data) => {
                console.log(JSON.stringify(data));
            });
            setTimeout(() => {
                emitter.emit('close');
            }, 10000);
        });
    }
}).catch((err) => {
    console.log(err);
});