Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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