|
| 1 | +--- |
| 2 | +title: Application |
| 3 | +order: 250 |
| 4 | +--- |
| 5 | + |
| 6 | +## Application |
| 7 | + |
| 8 | +The `App` facade allows you to perform basic operations with the Electron app. |
| 9 | + |
| 10 | +Note: Some methods are only available on specific operating systems and are labeled as such. |
| 11 | + |
| 12 | +To use the `App` facade, add the following to the top of your file: |
| 13 | + |
| 14 | +```php |
| 15 | +use Native\Laravel\Facades\App; |
| 16 | +``` |
| 17 | + |
| 18 | +### Quit the app |
| 19 | + |
| 20 | +To quit the app, use the `quit` method: |
| 21 | + |
| 22 | +```php |
| 23 | +App::quit(); |
| 24 | +``` |
| 25 | + |
| 26 | +### Focus the app |
| 27 | + |
| 28 | +To focus the app, use the `focus` method. |
| 29 | + |
| 30 | +On Linux, it focuses on the first visible window. On macOS, it makes the application the active one. On Windows, it |
| 31 | +focuses on the application's first window. |
| 32 | + |
| 33 | +```php |
| 34 | +App::focus(); |
| 35 | +``` |
| 36 | + |
| 37 | +### Hide the app |
| 38 | +_Only available on macOS_ |
| 39 | + |
| 40 | +The `hide` method will hide all application windows without minimizing them. This method is only available on macOS. |
| 41 | + |
| 42 | +```php |
| 43 | +App::hide(); |
| 44 | +``` |
| 45 | + |
| 46 | +### Check if the app is hidden |
| 47 | +_Only available on macOS_ |
| 48 | + |
| 49 | +To check if the app is hidden, use the `isHidden` method. This method is only available on macOS. |
| 50 | + |
| 51 | +Returns a boolean: `true` if the application—including all its windows—is hidden (e.g., with Command-H), `false` |
| 52 | +otherwise. |
| 53 | + |
| 54 | +```php |
| 55 | +$isHidden = App::isHidden(); |
| 56 | +``` |
| 57 | + |
| 58 | +### Current Version |
| 59 | + |
| 60 | +To get the current app version, use the `version` method. The version is defined in the `config/nativephp.php` file. |
| 61 | + |
| 62 | +```php |
| 63 | +$version = App::version(); |
| 64 | +``` |
| 65 | + |
| 66 | +### App Badge Count |
| 67 | +_Only available on macOS and Linux_ |
| 68 | + |
| 69 | +You can set the app's badge count. |
| 70 | +On macOS, it shows on the dock icon. On Linux, it only works for Unity launcher. |
| 71 | + |
| 72 | +To set the badge count, use the `badgeCount` method: |
| 73 | + |
| 74 | +```php |
| 75 | +App::badgeCount(5); |
| 76 | +``` |
| 77 | + |
| 78 | +To remove the badge count, use the `badgeCount` method with `0` as the argument: |
| 79 | + |
| 80 | +```php |
| 81 | +App::badgeCount(0); |
| 82 | +``` |
| 83 | + |
| 84 | +To get the badge count, use the `badgeCount` method without any arguments: |
| 85 | + |
| 86 | +```php |
| 87 | +$badgeCount = App::badgeCount(); |
| 88 | +``` |
| 89 | + |
| 90 | +### Recent documents list |
| 91 | +_Only available on macOS and Windows_ |
| 92 | + |
| 93 | +The recent documents list is a list of files that the user has recently opened. This list is available on macOS and |
| 94 | +Windows. |
| 95 | + |
| 96 | +To add a document to the recent documents list, use the `addRecentDocument` method: |
| 97 | + |
| 98 | +```php |
| 99 | +App::addRecentDocument('/path/to/document'); |
| 100 | +``` |
| 101 | + |
| 102 | +To clear the recent documents list, use the `clearRecentDocuments` method: |
| 103 | + |
| 104 | +```php |
| 105 | +App::clearRecentDocuments(); |
| 106 | +``` |
| 107 | + |
| 108 | +### Open at login |
| 109 | +_Only available on macOS and Windows_ |
| 110 | + |
| 111 | +To enable 'open at login', use the `openAtLogin` method: |
| 112 | + |
| 113 | +```php |
| 114 | +App::openAtLogin(true); |
| 115 | +``` |
| 116 | + |
| 117 | +To disable open at login, use the `openAtLogin` method with `false` as the argument: |
| 118 | + |
| 119 | +```php |
| 120 | +App::openAtLogin(false); |
| 121 | +``` |
| 122 | + |
| 123 | +To check if the app is set to open at login, use the `openAtLogin` method without any arguments: |
| 124 | + |
| 125 | +```php |
| 126 | +$isOpenAtLogin = App::openAtLogin(); |
| 127 | +``` |
| 128 | + |
0 commit comments