Bifrost is on Product Hunt Please give us an upvote!

Application


#Application

The App facade allows you to perform basic operations with the Electron app.

Note: Some methods are only available on specific operating systems and are labeled as such.

To use the App facade, add the following to the top of your file:

Copied!
use Native\Laravel\Facades\App;

#Quit the app

To quit the app, use the quit method:

Copied!
App::quit();

#Relaunch the app

To relaunch the app, use the relaunch method. This will quit the app and relaunch it.

Copied!
App::relaunch();

#Focus the app

To focus the app, use the focus method.

On Linux, it focuses on the first visible window. On macOS, it makes the application the active one. On Windows, it focuses on the application's first window.

Copied!
App::focus();

#Hide the app

Only available on macOS

The hide method will hide all application windows without minimizing them. This method is only available on macOS.

Copied!
App::hide();

#Check if the app is hidden

Only available on macOS

To check if the app is hidden, use the isHidden method. This method is only available on macOS.

Returns a boolean: true if the application—including all its windows—is hidden (e.g., with Command-H), false otherwise.

Copied!
$isHidden = App::isHidden();

#Current Version

To get the current app version, use the version method. The version is defined in the config/nativephp.php file.

Copied!
$version = App::version();

#Locale information

The facade offers several methods for accessing some of the system's localisation information. This data can be helpful for localising your application, e.g. if you want to suggest the corresponding language to the user on first launch.

Copied!
App::getLocale(); // e.g. "de", "fr-FR"
App::getLocaleCountryCode(); // e.g. "US", "DE"
App::getSystemLocale(); // e.g. "it-IT", "de-DE"

The getLocale method will return the locale used by the app. Dependening on the user's settings, this might include both the language and the country / region or the language only. It is based on Chromiums l10n_util library; see this page to see possible values.

getLocaleCountryCode returns the user's system country code (using the ISO 3166 code). This information is pulled from native OS APIs. If it is not possible to detect this information, an empty string will be returned.

With getSystemLocale you can access the system-wide locale setting. This is the locale set at the operating system level, not necessarily what the app is using. Under Windows and Linux, Chromium's i18n library is used to evaluate this information. macOS will use [NSLocale currentLocale].

#App Badge Count

Only available on macOS and Linux

You can set the app's badge count. On macOS, it shows on the dock icon. On Linux, it only works for Unity launcher.

To set the badge count, use the badgeCount method:

Copied!
App::badgeCount(5);

To remove the badge count, use the badgeCount method with 0 as the argument:

Copied!
App::badgeCount(0);

To get the badge count, use the badgeCount method without any arguments:

Copied!
$badgeCount = App::badgeCount();

#Recent documents list

Only available on macOS and Windows

The recent documents list is a list of files that the user has recently opened. This list is available on macOS and Windows.

To add a document to the recent documents list, use the addRecentDocument method:

Copied!
App::addRecentDocument('/path/to/document');

To clear the recent documents list, use the clearRecentDocuments method:

Copied!
App::clearRecentDocuments();

#Open at login

Only available on macOS and Windows

To enable 'open at login', use the openAtLogin method:

Copied!
App::openAtLogin(true);

To disable open at login, use the openAtLogin method with false as the argument:

Copied!
App::openAtLogin(false);

To check if the app is set to open at login, use the openAtLogin method without any arguments:

Copied!
$isOpenAtLogin = App::openAtLogin();