6

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 ?

Hemangi Pithava
  • 138
  • 1
  • 7
user1739413
  • 153
  • 6

1 Answers1

0

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>
Alan Zhiliang Feng
  • 1,774
  • 18
  • 20