utilityProcess creates a child process with Node.js and Message ports enabled. It provides the equivalent of child_process.fork API from Node.js but instead uses Services API from Chromium to launch the child process. Process: Main Methods utilityProcess.fork(modulePath[, args][, options]) Returns UtilityProcess Class: UtilityProcess Instances of the UtilityProcess represent the Chromium spawned child process with Node.js integration. UtilityProcess is an EventEmitter. Instance Methods child.postMessage(message, [transfer]) Send a message to the child process, optionally transferring ownership of zero or more MessagePortMain objects. For example: child.kill() Returns boolean Terminates the process gracefully. On POSIX, it uses SIGTERM but will ensure the process is reaped on exit. This function returns true if the kill is successful, and false otherwise. Instance Properties child.pid A Integer | undefined representing the process identifier (PID) of the child process. If the child process fails to spawn due to errors, then the value is undefined. When the child process exits, then the value is undefined after the exit event is emitted. child.stdout A NodeJS.ReadableStream | null that represents the child process’s stdout. If the child was spawned with options.stdio[1] set to anything other than ‘pipe’, then this will be null. When the child process exits, then the value is null after the exit event is emitted. child.stderr A NodeJS.ReadableStream | null that represents the child process’s stderr. If the child was spawned with options.stdio[2] set to anything other than ‘pipe’, then this will be null. When the child process exits, then the value is null after the exit event is emitted. Instance Events Event: ‘spawn’ Emitted once the child process has spawned successfully. Event: ‘exit’ Returns: Emitted after the child process ends. Event: ‘message’ Returns: Emitted when the child process sends a message using process.parentPort.postMessage().
Tray
Class: Tray Add icons and context menus to the system’s notification area. Process: Main Tray is an EventEmitter. Platform Considerations Linux MacOS Windows new Tray(image, [guid]) Creates a new tray icon associated with the image. Instance Events The Tray module emits the following events: Event: ‘click’ Returns: Emitted when the tray icon is clicked. Note that on Linux this event is emitted when the tray icon receives an activation, which might not necessarily be left mouse click. Event: ‘right-click’ macOS Windows Returns: Emitted when the tray icon is right clicked. Event: ‘double-click’ macOS Windows Returns: Emitted when the tray icon is double clicked. Event: ‘middle-click’ Windows Returns: Emitted when the tray icon is middle clicked. Event: ‘balloon-show’ Windows Emitted when the tray balloon shows. Event: ‘balloon-click’ Windows Emitted when the tray balloon is clicked. Event: ‘balloon-closed’ Windows Emitted when the tray balloon is closed because of timeout or user manually closes it. Event: ‘drop’ macOS Emitted when any dragged items are dropped on the tray icon. Event: ‘drop-files’ macOS Returns: Emitted when dragged files are dropped in the tray icon. Event: ‘drop-text’ macOS Returns: Emitted when dragged text is dropped in the tray icon. Event: ‘drag-enter’ macOS Emitted when a drag operation enters the tray icon. Event: ‘drag-leave’ macOS Emitted when a drag operation exits the tray icon. Event: ‘drag-end’ macOS Emitted when a drag operation ends on the tray or ends at another location. Event: ‘mouse-up’ macOS Returns: Emitted when the mouse is released from clicking the tray icon. Note: This will not be emitted if you have set a context menu for your Tray using tray.setContextMenu, as a result of macOS-level constraints. Event: ‘mouse-down’ macOS Returns: Emitted when the mouse clicks the tray icon. Event: ‘mouse-enter’ macOS Windows Returns: Emitted when the mouse enters the tray icon. Event: ‘mouse-leave’ macOS Windows Returns: Emitted when the mouse exits the tray icon. Event: ‘mouse-move’ macOS Windows Returns: Emitted when the mouse moves in the tray icon. Instance Methods The Tray class has the following methods: tray.destroy() Destroys the tray icon immediately. tray.setImage(image) Sets the image associated with this tray icon. tray.setPressedImage(image) macOS Sets the image associated with this tray icon when pressed on macOS. tray.setToolTip(toolTip) Sets the hover text for this tray icon. tray.setTitle(title[, options]) macOS Sets the title displayed next to the tray icon in the status bar (Support ANSI colors). tray.getTitle() macOS Returns string – the title displayed next to the tray icon in the status bar tray.setIgnoreDoubleClickEvents(ignore) macOS Sets the option to ignore double click events. Ignoring these events allows you to detect every individual click of the tray icon. This value is set to false by default. tray.getIgnoreDoubleClickEvents() macOS Returns boolean – Whether double click events will be ignored. tray.displayBalloon(options) Windows Displays a tray balloon. tray.removeBalloon() Windows Removes a tray balloon. tray.focus() Windows Returns focus to the taskbar notification area. Notification area icons should use this message when they have completed their UI operation. For example, if the icon displays a shortcut menu, but the user presses ESC to cancel it, use tray.focus() to return focus to the notification area. tray.popUpContextMenu([menu, position]) macOS Windows Pops up the context menu of the tray icon. When menu is passed, the menu will be shown instead of the tray icon’s context menu. The position is only available on Windows, and it is (0, 0) by default. tray.closeContextMenu() macOS Windows Closes an open context menu, as set by tray.setContextMenu(). tray.setContextMenu(menu) Sets the context menu for this icon. tray.getBounds() macOS Windows Returns Rectangle The bounds of this tray icon as Object. tray.isDestroyed() Returns boolean – Whether the tray icon is destroyed.
TouchBar
Class: TouchBar Create TouchBar layouts for native macOS applications Process: Main new TouchBar(options) Creates a new touch bar with the specified items. Use BrowserWindow.setTouchBar to add the TouchBar to a window. Note: The TouchBar API is currently experimental and may change or be removed in future Electron releases. Tip: If you don’t have a MacBook with Touch Bar, you can use Touch Bar Simulator to test Touch Bar usage in your app. Static Properties TouchBarButton A typeof TouchBarButton reference to the TouchBarButton class. TouchBarColorPicker A typeof TouchBarColorPicker reference to the TouchBarColorPicker class. TouchBarGroup A typeof TouchBarGroup reference to the TouchBarGroup class. TouchBarLabel A typeof TouchBarLabel reference to the TouchBarLabel class. TouchBarPopover A typeof TouchBarPopover reference to the TouchBarPopover class. TouchBarScrubber A typeof TouchBarScrubber reference to the TouchBarScrubber class. TouchBarSegmentedControl A typeof TouchBarSegmentedControl reference to the TouchBarSegmentedControl class. TouchBarSlider A typeof TouchBarSlider reference to the TouchBarSlider class. TouchBarSpacer A typeof TouchBarSpacer reference to the TouchBarSpacer class. TouchBarOtherItemsProxy A typeof TouchBarOtherItemsProxy reference to the TouchBarOtherItemsProxy class. Instance Properties The following properties are available on instances of TouchBar: touchBar.escapeItem A TouchBarItem that will replace the “esc” button on the touch bar when set. Setting to null restores the default “esc” button. Changing this value immediately updates the escape item in the touch bar. Examples Below is an example of a simple slot machine touch bar game with a button and some labels. Running the above example To run the example above, you’ll need to (assuming you’ve got a terminal open in the directory you want to run the example): You should then see a new Electron window and the app running in your touch bar (or touch bar emulator).
SystemPreferences
Get system preferences. Process: Main, Utility Events The systemPreferences object emits the following events: Event: ‘accent-color-changed’ Windows Returns: Event: ‘color-changed’ Windows Returns: Methods systemPreferences.isSwipeTrackingFromScrollEventsEnabled() macOS Returns boolean – Whether the Swipe between pages setting is on. systemPreferences.postNotification(event, userInfo[, deliverImmediately]) macOS Posts event as native notifications of macOS. The userInfo is an Object that contains the user information dictionary sent along with the notification. systemPreferences.postLocalNotification(event, userInfo) macOS Posts event as native notifications of macOS. The userInfo is an Object that contains the user information dictionary sent along with the notification. systemPreferences.postWorkspaceNotification(event, userInfo) macOS Posts event as native notifications of macOS. The userInfo is an Object that contains the user information dictionary sent along with the notification. systemPreferences.subscribeNotification(event, callback) macOS Returns number – The ID of this subscription Subscribes to native notifications of macOS, callback will be called with callback(event, userInfo) when the corresponding event happens. The userInfo is an Object that contains the user information dictionary sent along with the notification. The object is the sender of the notification, and only supports NSString values for now. The id of the subscriber is returned, which can be used to unsubscribe the event. Under the hood this API subscribes to NSDistributedNotificationCenter, example values of event are: If event is null, the NSDistributedNotificationCenter doesn’t use it as criteria for delivery to the observer. See docs for more information. systemPreferences.subscribeLocalNotification(event, callback) macOS Returns number – The ID of this subscription Same as subscribeNotification, but uses NSNotificationCenter for local defaults. This is necessary for events such as NSUserDefaultsDidChangeNotification. If event is null, the NSNotificationCenter doesn’t use it as criteria for delivery to the observer. See docs for more information. systemPreferences.subscribeWorkspaceNotification(event, callback) macOS Returns number – The ID of this subscription Same as subscribeNotification, but uses NSWorkspace.sharedWorkspace.notificationCenter. This is necessary for events such as NSWorkspaceDidActivateApplicationNotification. If event is null, the NSWorkspaceNotificationCenter doesn’t use it as criteria for delivery to the observer. See docs for more information. systemPreferences.unsubscribeNotification(id) macOS Removes the subscriber with id. systemPreferences.unsubscribeLocalNotification(id) macOS Same as unsubscribeNotification, but removes the subscriber from NSNotificationCenter. systemPreferences.unsubscribeWorkspaceNotification(id) macOS Same as unsubscribeNotification, but removes the subscriber from NSWorkspace.sharedWorkspace.notificationCenter. systemPreferences.registerDefaults(defaults) macOS Add the specified defaults to your application’s NSUserDefaults. systemPreferences.getUserDefault<Type extends keyof UserDefaultTypes>(key, type) macOS Returns UserDefaultTypes[Type] – The value of key in NSUserDefaults. Some popular key and types are: systemPreferences.setUserDefault<Type extends keyof UserDefaultTypes>(key, type, value) macOS Set the value of key in NSUserDefaults. Note that type should match actual type of value. An exception is thrown if they don’t. Some popular key and types are: systemPreferences.removeUserDefault(key) macOS Removes the key in NSUserDefaults. This can be used to restore the default or global value of a key previously set with setUserDefault. systemPreferences.isAeroGlassEnabled() Windows Returns boolean – true if DWM composition (Aero Glass) is enabled, and false otherwise. An example of using it to determine if you should create a transparent window or not (transparent windows won’t work correctly when DWM composition is disabled): systemPreferences.getAccentColor() Windows macOS Returns string – The users current system wide accent color preference in RGBA hexadecimal form. This API is only available on macOS 10.14 Mojave or newer. systemPreferences.getColor(color) Windows macOS Returns string – The system color setting in RGBA hexadecimal form (#RRGGBBAA). See the Windows docs and the macOS docs for more details. The following colors are only available on macOS 10.14: find-highlight, selected-content-background, separator, unemphasized-selected-content-background, unemphasized-selected-text-background, and unemphasized-selected-text. systemPreferences.getSystemColor(color) macOS Returns string – The standard system color formatted as #RRGGBBAA. Returns one of several standard system colors that automatically adapt to vibrancy and changes in accessibility settings like ‘Increase contrast’ and ‘Reduce transparency’. See Apple Documentation for more details. systemPreferences.getEffectiveAppearance() macOS Returns string – Can be dark, light or unknown. Gets the macOS appearance setting that is currently applied to your application, maps to NSApplication.effectiveAppearance systemPreferences.canPromptTouchID() macOS Returns boolean – whether or not this device has the ability to use Touch ID. systemPreferences.promptTouchID(reason) macOS Returns Promise<void> – resolves if the user has successfully authenticated with Touch ID. This API itself will not protect your user data; rather, it is a mechanism to allow you to do so. Native apps will need to set Access Control Constants like kSecAccessControlUserPresence on their keychain entry so that reading it would auto-prompt for Touch ID biometric consent. This could be done with node-keytar, such that one would store an encryption key with node-keytar and only fetch it if promptTouchID() resolves. systemPreferences.isTrustedAccessibilityClient(prompt) macOS Returns boolean – true if the current process is a trusted accessibility client and false if it is not. systemPreferences.getMediaAccessStatus(mediaType) Windows macOS Returns string – Can be not-determined, granted, denied, restricted or unknown. This user consent was not required on macOS 10.13 High Sierra so this method will always return granted. macOS 10.14 Mojave or higher requires consent for microphone and camera access. macOS 10.15 Catalina or higher requires consent for screen access. Windows 10 has a global setting controlling microphone and camera access for all win32 applications. It will always return granted for screen and for all media types on older versions of Windows. systemPreferences.askForMediaAccess(mediaType) macOS Returns Promise<boolean> – A promise that resolves with true if consent was granted and false if it was denied. If an invalid mediaType is passed, the promise will be rejected. If an access request was denied and later is changed through the System Preferences pane, a restart of the app will be required for the new permissions to take effect. If access has already been requested and denied, it must be changed through the preference pane; an alert will not pop up and the promise will resolve with the existing access status. Important: In order to properly leverage this API, you must set the NSMicrophoneUsageDescription and NSCameraUsageDescription strings in your app’s Info.plist file. The values for these keys will be used to populate the permission dialogs so that the user will be properly informed as to the purpose of the permission request. See Electron Application Distribution for more information about how to set these in the context of Electron. This user consent was not required until macOS 10.14 Mojave, so this method will always return true if your system is running 10.13 High Sierra. systemPreferences.getAnimationSettings() Returns Object: Returns an object with system animation settings. Properties systemPreferences.accessibilityDisplayShouldReduceTransparency() macOS A boolean property which determines whether the app avoids using semitransparent backgrounds. This maps to NSWorkspace.accessibilityDisplayShouldReduceTransparency systemPreferences.effectiveAppearance macOS Readonly A string property that can be dark, light or unknown. Returns the macOS appearance setting that is currently applied to your application, maps to NSApplication.effectiveAppearance
Shell
Manage files and URLs using their default applications. Process: Main, Renderer (non-sandboxed only) The shell module provides functions related to desktop integration. An example of opening a URL in the user’s default browser: Note: While the shell module can be used in the renderer process, it will not function in a sandboxed renderer. Methods The shell module has the following methods: shell.showItemInFolder(fullPath) Show the given file in a file manager. If possible, select the file. shell.openPath(path) Returns Promise<string> – Resolves with a string containing the error message corresponding to the failure if a failure occurred, otherwise “”. Open the given file in the desktop’s default manner. shell.openExternal(url[, options]) Returns Promise<void> Open the given external protocol URL in the desktop’s default manner. (For example, mailto: URLs in the user’s default mail agent). shell.trashItem(path) Returns Promise<void> – Resolves when the operation has been completed. Rejects if there was an error while deleting the requested item. This moves a path to the OS-specific trash location (Trash on macOS, Recycle Bin on Windows, and a desktop-environment-specific location on Linux). shell.beep() Play the beep sound. shell.writeShortcutLink(shortcutPath[, operation], options) Windows Returns boolean – Whether the shortcut was created successfully. Creates or updates a shortcut link at shortcutPath. shell.readShortcutLink(shortcutPath) Windows Returns ShortcutDetails Resolves the shortcut link at shortcutPath. An exception will be thrown when any error happens.
ShareMenu
The ShareMenu class creates Share Menu on macOS, which can be used to share information from the current context to apps, social media accounts, and other services. For including the share menu as a submenu of other menus, please use the shareMenu role of MenuItem. Class: ShareMenu Create share menu on macOS. Process: Main new ShareMenu(sharingItem) Creates a new share menu. Instance Methods The shareMenu object has the following instance methods: shareMenu.popup([options]) Pops up this menu as a context menu in the BrowserWindow. shareMenu.closePopup([browserWindow]) Closes the context menu in the browserWindow.
Session
Manage browser sessions, cookies, cache, proxy settings, etc. Process: Main The session module can be used to create new Session objects. You can also access the session of existing pages by using the session property of WebContents, or from the session module. Methods The session module has the following methods: session.fromPartition(partition[, options]) Returns Session – A session instance from partition string. When there is an existing Session with the same partition, it will be returned; otherwise a new Session instance will be created with options. If partition starts with persist:, the page will use a persistent session available to all pages in the app with the same partition. if there is no persist: prefix, the page will use an in-memory session. If the partition is empty then default session of the app will be returned. To create a Session with options, you have to ensure the Session with the partition has never been used before. There is no way to change the options of an existing Session object. session.fromPath(path[, options]) Returns Session – A session instance from the absolute path as specified by the path string. When there is an existing Session with the same absolute path, it will be returned; otherwise a new Session instance will be created with options. The call will throw an error if the path is not an absolute path. Additionally, an error will be thrown if an empty string is provided. To create a Session with options, you have to ensure the Session with the path has never been used before. There is no way to change the options of an existing Session object. Properties The session module has the following properties: session.defaultSession A Session object, the default session object of the app. Class: Session Get and set properties of a session. Process: MainThis class is not exported from the ‘electron’ module. It is only available as a return value of other methods in the Electron API. You can create a Session object in the session module: Instance Events The following events are available on instances of Session: Event: ‘will-download’ Returns: Emitted when Electron is about to download item in webContents. Calling event.preventDefault() will cancel the download and item will not be available from next tick of the process. Event: ‘extension-loaded’ Returns: Emitted after an extension is loaded. This occurs whenever an extension is added to the “enabled” set of extensions. This includes: Event: ‘extension-unloaded’ Returns: Emitted after an extension is unloaded. This occurs when Session.removeExtension is called. Event: ‘extension-ready’ Returns: Emitted after an extension is loaded and all necessary browser state is initialized to support the start of the extension’s background page. Event: ‘file-system-access-restricted’ Returns: Event: ‘preconnect’ Returns: Emitted when a render process requests preconnection to a URL, generally due to a resource hint. Event: ‘spellcheck-dictionary-initialized’ Returns: Emitted when a hunspell dictionary file has been successfully initialized. This occurs after the file has been downloaded. Event: ‘spellcheck-dictionary-download-begin’ Returns: Emitted when a hunspell dictionary file starts downloading Event: ‘spellcheck-dictionary-download-success’ Returns: Emitted when a hunspell dictionary file has been successfully downloaded Event: ‘spellcheck-dictionary-download-failure’ Returns: Emitted when a hunspell dictionary file download fails. For details on the failure you should collect a netlog and inspect the download request. Event: ‘select-hid-device’ Returns: Emitted when a HID device needs to be selected when a call to navigator.hid.requestDevice is made. callback should be called with deviceId to be selected; passing no arguments to callback will cancel the request. Additionally, permissioning on navigator.hid can be further managed by using ses.setPermissionCheckHandler(handler) and ses.setDevicePermissionHandler(handler). Event: ‘hid-device-added’ Returns: Emitted after navigator.hid.requestDevice has been called and select-hid-device has fired if a new device becomes available before the callback from select-hid-device is called. This event is intended for use when using a UI to ask users to pick a device so that the UI can be updated with the newly added device. Event: ‘hid-device-removed’ Returns: Emitted after navigator.hid.requestDevice has been called and select-hid-device has fired if a device has been removed before the callback from select-hid-device is called. This event is intended for use when using a UI to ask users to pick a device so that the UI can be updated to remove the specified device. Event: ‘hid-device-revoked’ Returns: Emitted after HIDDevice.forget() has been called. This event can be used to help maintain persistent storage of permissions when setDevicePermissionHandler is used. Event: ‘select-serial-port’ Returns: Emitted when a serial port needs to be selected when a call to navigator.serial.requestPort is made. callback should be called with portId to be selected, passing an empty string to callback will cancel the request. Additionally, permissioning on navigator.serial can be managed by using ses.setPermissionCheckHandler(handler) with the serial permission. Event: ‘serial-port-added’ Returns: Emitted after navigator.serial.requestPort has been called and select-serial-port has fired if a new serial port becomes available before the callback from select-serial-port is called. This event is intended for use when using a UI to ask users to pick a port so that the UI can be updated with the newly added port. Event: ‘serial-port-removed’ Returns: Emitted after navigator.serial.requestPort has been called and select-serial-port has fired if a serial port has been removed before the callback from select-serial-port is called. This event is intended for use when using a UI to ask users to pick a port so that the UI can be updated to remove the specified port. Event: ‘serial-port-revoked’ Returns: Emitted after SerialPort.forget() has been called. This event can be used to help maintain persistent storage of permissions when setDevicePermissionHandler is used. Event: ‘select-usb-device’ Returns: Emitted when a USB device needs to be selected when a call to navigator.usb.requestDevice is made. callback should be called with deviceId to be selected; passing no arguments to callback will cancel the request. Additionally, permissioning on navigator.usb can be further managed by using ses.setPermissionCheckHandler(handler) and ses.setDevicePermissionHandler(handler). Event: ‘usb-device-added’ Returns: Emitted after navigator.usb.requestDevice has been called and select-usb-device has fired if a new device becomes available before the callback from select-usb-device is called. This event is intended for use when using a UI to ask users to pick a device so that the UI can be updated with the newly added device. Event: ‘usb-device-removed’ Returns: Emitted after navigator.usb.requestDevice has been called and select-usb-device has fired if a device has been removed before the callback from select-usb-device is called. This event is intended for use when using a UI to ask users to pick a device so that the UI can be updated to remove the specified device. Event: ‘usb-device-revoked’ Returns: Emitted after USBDevice.forget() has been called. This event can be used to help maintain persistent storage of permissions when setDevicePermissionHandler is used. Instance Methods The following methods are available on instances of Session: ses.getCacheSize() Returns Promise<Integer> – the session’s current cache size, in bytes. ses.clearCache() Returns Promise<void> – resolves when the cache clear operation is complete. Clears the session’s HTTP cache. ses.clearStorageData([options]) Returns Promise<void> – resolves when the storage data has been cleared. ses.flushStorageData() Writes any unwritten DOMStorage data to disk. ses.setProxy(config) Returns Promise<void> – Resolves when the proxy setting process is complete. Sets the proxy settings. You may need ses.closeAllConnections to close currently in flight connections to prevent pooled sockets using previous proxy
Screen
Retrieve information about screen size, displays, cursor position, etc. Process: Main This module cannot be used until the ready event of the app module is emitted. screen is an EventEmitter. Note: In the renderer / DevTools, window.screen is a reserved DOM property, so writing let { screen } = require(‘electron’) will not work. An example of creating a window that fills the whole screen: DOCS/FIDDLES/SCREEN/FIT-SCREEN (31.4.0)Open in Fiddle Another example of creating a window in the external display: Events The screen module emits the following events: Event: ‘display-added’ Returns: Emitted when newDisplay has been added. Event: ‘display-removed’ Returns: Emitted when oldDisplay has been removed. Event: ‘display-metrics-changed’ Returns: Emitted when one or more metrics change in a display. The changedMetrics is an array of strings that describe the changes. Possible changes are bounds, workArea, scaleFactor and rotation. Methods The screen module has the following methods: screen.getCursorScreenPoint() Returns Point The current absolute position of the mouse pointer. Note: The return value is a DIP point, not a screen physical point. screen.getPrimaryDisplay() Returns Display – The primary display. screen.getAllDisplays() Returns Display[] – An array of displays that are currently available. screen.getDisplayNearestPoint(point) Returns Display – The display nearest the specified point. screen.getDisplayMatching(rect) Returns Display – The display that most closely intersects the provided bounds. screen.screenToDipPoint(point) Windows Returns Point Converts a screen physical point to a screen DIP point. The DPI scale is performed relative to the display containing the physical point. screen.dipToScreenPoint(point) Windows Returns Point Converts a screen DIP point to a screen physical point. The DPI scale is performed relative to the display containing the DIP point. screen.screenToDipRect(window, rect) Windows Returns Rectangle Converts a screen physical rect to a screen DIP rect. The DPI scale is performed relative to the display nearest to window. If window is null, scaling will be performed to the display nearest to rect. screen.dipToScreenRect(window, rect) Windows Returns Rectangle Converts a screen DIP rect to a screen physical rect. The DPI scale is performed relative to the display nearest to window. If window is null, scaling will be performed to the display nearest to rect.
SafeStorage
Allows access to simple encryption and decryption of strings for storage on the local machine. Process: Main This module adds extra protection to data being stored on disk by using OS-provided cryptography systems. Current security semantics for each platform are outlined below. Note that on Mac, access to the system Keychain is required and these calls can block the current thread to collect user input. The same is true for Linux, if a password management tool is available. Methods The safeStorage module has the following methods: safeStorage.isEncryptionAvailable() Returns boolean – Whether encryption is available. On Linux, returns true if the app has emitted the ready event and the secret key is available. On MacOS, returns true if Keychain is available. On Windows, returns true once the app has emitted the ready event. safeStorage.encryptString(plainText) Returns Buffer – An array of bytes representing the encrypted string. This function will throw an error if encryption fails. safeStorage.decryptString(encrypted) Returns string – the decrypted string. Decrypts the encrypted buffer obtained with safeStorage.encryptString back into a string. This function will throw an error if decryption fails. safeStorage.setUsePlainTextEncryption(usePlainText) This function on Linux will force the module to use an in memory password for creating symmetric key that is used for encrypt/decrypt functions when a valid OS password manager cannot be determined for the current active desktop environment. This function is a no-op on Windows and MacOS. safeStorage.getSelectedStorageBackend() Linux Returns string – User friendly name of the password manager selected on Linux. This function will return one of the following values:
pushNotifications
Process: Main Register for and receive notifications from remote push notification services For example, when registering for push notifications via Apple push notification services (APNS): Events The pushNotification module emits the following events: Event: ‘received-apns-notification’ macOS Returns: Emitted when the app receives a remote notification while running. See: https://developer.apple.com/documentation/appkit/nsapplicationdelegate/1428430-application?language=objc Methods The pushNotification module has the following methods: pushNotifications.registerForAPNSNotifications() macOS Returns Promise<string> Registers the app with Apple Push Notification service (APNS) to receive Badge, Sound, and Alert notifications. If registration is successful, the promise will be resolved with the APNS device token. Otherwise, the promise will be rejected with an error message. See: https://developer.apple.com/documentation/appkit/nsapplication/1428476-registerforremotenotificationtyp?language=objc pushNotifications.unregisterForAPNSNotifications() macOS Unregisters the app from notifications received from APNS. See: https://developer.apple.com/documentation/appkit/nsapplication/1428747-unregisterforremotenotifications?language=objc