Skip to content

Instantly share code, notes, and snippets.

@bored-engineer
Forked from TooTallNate/Run.js
Created September 28, 2011 01:14
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bored-engineer/1246749 to your computer and use it in GitHub Desktop.
Save bored-engineer/1246749 to your computer and use it in GitHub Desktop.
MobileDevice NodObjC basic example.
var $ = require('NodObjC')
$.import('MobileDevice');
$.import('CoreFoundation')
// Callback function that's invoked when a device is plugged in
function callback (i, foo) {
try {
console.log('inside callback!')
var info = new $.am_device_notification_callback_info(i)
if (info.msg != $.ADNCI_MSG_CONNECTED) return;
$.AMDeviceConnect(info.dev);
console.log($.AMDeviceIsPaired(info.dev));
console.log($.AMDeviceValidatePairing(info.dev));
console.log($.AMDeviceValidatePairing(info.dev));
} catch (e) {
console.error(e.stack || e)
}
}
// create an instance of am_device_notification
var notif = new $.am_device_notification()
// listen for device notifications
$.AMDeviceNotificationSubscribe(callback, 0, 0, null, notif.ref());
console.error('beginning RunLoop')
$.CFRunLoopRun()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment