Skip to content

Instantly share code, notes, and snippets.

@TooTallNate
Forked from bored-engineer/Run.js
Created September 27, 2011 21:04
Show Gist options
  • Save TooTallNate/1246244 to your computer and use it in GitHub Desktop.
Save TooTallNate/1246244 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 (info, foo) {
try {
console.log('inside callback!')
var i = new $.am_device_notification_callback_info(info)
if (i.msg == $.ADNCI_MSG_CONNECTED) {
console.log('yes')
} else {
console.log('no')
}
} 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