PHP code example of roboticsexpert / laravel-onesignal-channel

1. Go to this page and download the library: Download roboticsexpert/laravel-onesignal-channel 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/ */

    

roboticsexpert / laravel-onesignal-channel example snippets


// config/app.php
'providers' => [
    ...
    NotificationChannels\OneSignal\OneSignalServiceProvider::class,
],

// config/services.php
...
'onesignal' => [
    'app_id' => env('ONESIGNAL_APP_ID'),
    'rest_api_key' => env('ONESIGNAL_REST_API_KEY')
],
...

public function routeNotificationForOneSignal()
{
    return 'ONE_SIGNAL_PLAYER_ID';
}

public function routeNotificationForOneSignal()
{
    return ['email' => '[email protected]'];
}

public function routeNotificationForOneSignal()
{
    return ['tags' => ['key' => 'device_uuid', 'relation' => '=', 'value' => '1234567890-abcdefgh-1234567']];
}

OneSignalMessage::create()
    ->button(
        OneSignalButton::create('id')
            ->text('button text')
            ->icon('button icon')
    );

OneSignalMessage::create()
    ->webButton(
        OneSignalWebButton::create('id')
            ->text('button text')
            ->icon('button icon')
            ->url('button url')
    );