Bifrost turns 1! Get 30% off annual plans with code
HAPPYBIRTHDAY

System


Overview#

The System API covers system-level concerns — platform detection and opening the app's settings screen.

It's a core built-in: the facade resolves with nothing to install or register.

Copied!
use Native\Mobile\Facades\System;

Platform detection#

Copied!
System::isIos(); // true on iOS
System::isAndroid(); // true on Android
System::isMobile(); // true on either platform
System::platform(); // 'ios', 'android', or null outside the app

Use these to branch behavior or conditionally render UI for a specific platform. System::platform() 4.7 gives you the answer as a string, which saves checking both.

On the device Changed 4.7, the platform comes from an environment variable the app sets before PHP starts, so these checks are cheap enough to call as often as you like, even once per row of a long list. Before 4.7 every check asked the native side, which was far slower.

Under Jump, PHP runs on your computer instead of the phone, so that variable isn't set. The first check asks the connected device, and the answer is remembered after that.

To render a screen as one platform in a test, see Platform variants.

Each is also available as a global helper function — isIos(), isAndroid(), isMobile() — for terse use in Blade and components:

Copied!
if (isAndroid()) {
// ...
}

In Blade, the same checks are available as conditional directives:

Copied!
@ios
{{-- iOS-only markup --}}
@endios
 
@android
{{-- Android-only markup --}}
@endandroid
 
@mobile
{{-- running inside the native app (iOS or Android) --}}
@endmobile
 
@web
{{-- running in a browser / outside the native app --}}
@endweb

Each also supports the usual @else… and @unless… forms — @elseios, @unlessandroid, and so on.

App settings#

Open the app's page in the device Settings app — useful for sending a user to re-grant a permission they previously denied:

Copied!
System::appSettings();

Appearance (light / dark)#

Reading the current appearance and reacting to theme changes lives with the rest of theming — see Theming → Appearance in PHP for System::appearance(), isDarkMode(), isLightMode(), the isDark() / theme() helpers, and the AppearanceChanged event.

Orientation#

Read the orientation of the app window:

Copied!
System::orientation(); // 'portrait' | 'landscape'
System::isPortrait(); // bool
System::isLandscape(); // bool

When it changes, the OrientationChanged event fires. $orientation is 'portrait' or 'landscape':

Copied!
use Native\Mobile\Attributes\On;
use Native\Mobile\Events\System\OrientationChanged;
 
#[On(OrientationChanged::class)]
public function rotated(string $orientation): void
{
$this->columns = $orientation === 'landscape' ? 4 : 2;
}

OrientationChanged broadcasts globally. Next to the #[On] methods of the live screen, Event::listen hears it anywhere in your app.