PHP code example of s2br / nativephp-mobile-splashscreen

1. Go to this page and download the library: Download s2br/nativephp-mobile-splashscreen library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

s2br / nativephp-mobile-splashscreen example snippets


> use S2BR\MobileSplashscreen\MobileSplashscreenServiceProvider;
>
> public function plugins(): array
> {
>     return [
>         MobileSplashscreenServiceProvider::class,
>     ];
> }
> 

// routes/console.php
Schedule::command('nativephp:mobile-splashscreen:sync --url=https://your-cdn.com/animations.json')
    ->daily();

use S2BR\MobileSplashscreen\Facades\MobileSplashscreen;

MobileSplashscreen::syncFromUrl('https://your-cdn.com/animations.json')
                 ->resolveActive(daysAhead: 30);

MobileSplashscreen::hasActive();   // true if schedule-local.json exists
MobileSplashscreen::clearActive(); // remove schedule-local.json (reverts to default)

use Livewire\Attributes\On;
use S2BR\MobileSplashscreen\Events\SplashscreenCompleted;
use S2BR\MobileSplashscreen\Events\SplashscreenLoopCompleted;

#[On('native:'.SplashscreenCompleted::class)]
public function onSplashDone(string $animationName, float $duration): void
{
    // Dispatched after the splash exits (including any transition_out animation)
}

#[On('native:'.SplashscreenLoopCompleted::class)]
public function onSplashLoop(int $iteration, string $animationName): void
{
    if ($iteration >= 3) {
        // After 3 loops, do something in your app
    }
}

use S2BR\MobileSplashscreen\Facades\MobileSplashscreen;

$size = MobileSplashscreen::config('animation.size');
$bgType = MobileSplashscreen::config('background.type');

$errors = MobileSplashscreen::validate();

public function plugins(): array
{
    return [
        \S2BR\MobileSplashscreen\MobileSplashscreenServiceProvider::class,
    ];
}
bash
php artisan vendor:publish --tag=mobile-splashscreen-config
bash
php artisan native:plugin:list
bash
php artisan vendor:publish --tag=mobile-splashscreen-examples
javascript
import { onMounted, onUnmounted } from 'vue';

function onSplashDone(event) {
    const { animationName } = event.detail;
    console.log('Splash done', animationName);
}

onMounted(() => {
    window.addEventListener('native:S2BR\\MobileSplashscreen\\Events\\SplashscreenCompleted', onSplashDone);
});

onUnmounted(() => {
    window.removeEventListener('native:S2BR\\MobileSplashscreen\\Events\\SplashscreenCompleted', onSplashDone);
});
bash
php artisan native:plugin:register s2br/nativephp-mobile-splashscreen