Join our Mobile Early Access Program

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();

#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();

#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();