$.NSUserNotificationCenter('defaultUserNotificationCenter') returns null

Viewed 282

I am trying to fire up a notification to the Notification Center through node and NodObjC and the problem is:

    $.NSUserNotificationCenter('defaultUserNotificationCenter')

returns always null instead of an object to be abled to call the deliverNotification method ?

Does anyone has experience with NodObjC ?

1 Answers

I solved the issue by setting up a hook to provide the bundle id. Here is the demo code:

var $ = require('NodObjC');
$.import('Cocoa');

// hook the bundle id
($.NSBundle).getInstanceMethod('bundleIdentifier').setImplementation(function(value) {
  return $('com.example.app1');
});

// test
var center = $.NSUserNotificationCenter('defaultUserNotificationCenter');
console.log(center); // output: <_NSConcreteUserNotificationCenter: 0x103821e90>
Related