user1739413
user1739413

Reputation: 153

$.NSUserNotificationCenter('defaultUserNotificationCenter') returns null

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 ?

Upvotes: 6

Views: 298

Answers (1)

Alan Zhiliang Feng
Alan Zhiliang Feng

Reputation: 2012

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>

Upvotes: 0

Related Questions