-
-
Save TooTallNate/1246244 to your computer and use it in GitHub Desktop.
MobileDevice NodObjC basic example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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