Add a feature to Electron - How to?


#1

Hi!

I would like to add a feature to Electron: making it possible for developers to trigger native notifications (for Mac, using NSNotification), from their javascript app.

I am still trying to wrap my head around how everything works.
What I got so far:

  • you create the objective-c class that implement the feature using Cocoa
  • you create a C++ class that will use the v8_Isolate and create a TemplateBuilder, that will register the native methods you can bind
  • you create an coffee script class under API that will bind the Javascript call to the native method specified in the template builder.

Is there any resource to get more familiar with how it’s being built? v8_isolate? A simple example in the code of how to implement something similar?

Thanks!


#2

Hey @jayztemplier, Electron already has quite good notification support.
I’m not sure if they are 100% native but you can easily trigger them using Notification.new in your Javascript code and they look pretty much, if not same, like native notifications.

You can find an example here: https://github.com/hokein/electron-sample-apps/tree/master/notifications


#3

I was also wondering about something similar. While Notification is definitely what we want to display events, there is also a need to detect some notification events from other apps (using NSDistributedNotificationCenter objective-c class on OS X). I tried NodObjC, but had little luck making it work.

Any advice would be appreciated!