Skip to main content
The App API provides methods to control application behavior, access locale information, manage recent documents, and configure app-level settings.

Application Control

quit()

Quit the application gracefully.
use Native\Desktop\Facades\App;

App::quit();

relaunch()

Restart the application.
App::relaunch();

focus()

Bring the application to focus.
App::focus();

hide()

Hide the application (macOS).
App::hide();

isHidden()

Check if the application is currently hidden.
return
bool
Returns true if the application is hidden
if (App::isHidden()) {
    App::focus();
}

Locale and Internationalization

getLocale()

Get the current application locale.
return
string
Returns the locale string (e.g., “en-US”)
$locale = App::getLocale(); // "en-US"

getLocaleCountryCode()

Get the country code from the current locale.
return
string
Returns the country code (e.g., “US”)
$country = App::getLocaleCountryCode(); // "US"

getSystemLocale()

Get the system-level locale.
return
string
Returns the system locale string
$systemLocale = App::getSystemLocale();

Application Information

version()

Get the current application version.
return
string
Returns the version string from your config
$version = App::version(); // "1.0.0"

isRunningBundled()

Check if the application is running as a bundled executable.
return
bool
Returns true if running as a bundled app, false in development
if (App::isRunningBundled()) {
    // Production mode
} else {
    // Development mode
}

Badge and Indicators

badgeCount()

Get or set the badge count on the app icon (macOS and Windows).
count
int|null
The badge count to set, or null to get the current count
return
int
Returns the current badge count
// Set badge count
App::badgeCount(5);

// Get current badge count
$count = App::badgeCount(); // 5

// Clear badge
App::badgeCount(0);

Recent Documents

addRecentDocument()

Add a document to the recent documents list.
path
string
required
Absolute path to the document file
App::addRecentDocument('/path/to/document.pdf');

recentDocuments()

Get the list of recent documents.
return
array
Returns an array of document paths
$documents = App::recentDocuments();
// ['path/to/doc1.pdf', 'path/to/doc2.txt']

clearRecentDocuments()

Clear all recent documents.
App::clearRecentDocuments();

Startup Behavior

openAtLogin()

Get or set whether the app should open at system login.
open
bool|null
True to enable, false to disable, null to get current setting
return
bool
Returns the current or new setting
// Enable open at login
App::openAtLogin(true);

// Disable open at login
App::openAtLogin(false);

// Check current setting
$opensAtLogin = App::openAtLogin(); // true or false

Emoji Panel

isEmojiPanelSupported()

Check if the emoji panel is supported on this platform.
return
bool
Returns true if emoji panel is supported
if (App::isEmojiPanelSupported()) {
    // Show emoji picker button
}

showEmojiPanel()

Show the system emoji picker panel.
App::showEmojiPanel();

Complete Examples

Application Lifecycle

use Native\Desktop\Facades\App;

// Graceful shutdown with confirmation
if ($hasUnsavedChanges) {
    $result = Alert::new()
        ->buttons(['Cancel', 'Quit'])
        ->show('You have unsaved changes. Quit anyway?');
    
    if ($result === 1) {
        App::quit();
    }
} else {
    App::quit();
}

// Restart after update
if ($updateInstalled) {
    App::relaunch();
}

Locale-Aware Features

// Display content based on user's locale
$locale = App::getLocale();
$country = App::getLocaleCountryCode();

// Use for date formatting, currency, etc.
if ($country === 'US') {
    $dateFormat = 'MM/DD/YYYY';
} else {
    $dateFormat = 'DD/MM/YYYY';
}

Recent Documents Menu

// When user opens a file
App::addRecentDocument($filePath);

// Build recent files menu
$recentDocs = App::recentDocuments();

foreach ($recentDocs as $doc) {
    Menu::add(
        MenuItem::link(basename($doc))
            ->url("file://" . $doc)
    );
}

Unread Count Badge

// Show unread messages count
$unreadCount = Message::where('read', false)->count();
App::badgeCount($unreadCount);

// Clear when all messages are read
if ($unreadCount === 0) {
    App::badgeCount(0);
}

Platform Notes

macOS: All features are fully supported including hide(), badgeCount(), and emoji panel.Windows: Badge count shows in taskbar. hide() and emoji panel have limited support.Linux: Feature support varies by desktop environment.

Build docs developers (and LLMs) love