PHP code example of sibche / onesignal-laravel

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

    

sibche / onesignal-laravel example snippets


'providers' => [
	// ...
	Berkayk\OneSignal\OneSignalServiceProvider::class
];

'aliases' => [
	// ...
	'OneSignal' => Berkayk\OneSignal\OneSignalFacade::class
];

    OneSignal::sendNotificationToAll(
        "Some Message", 
        $url = null, 
        $data = null, 
        $buttons = null, 
        $schedule = null
    );

    OneSignal::sendNotificationUsingTags(
        "Some Message",
        array(
            ["field" => "email", "relation" => "=", "value" => "[email protected]"],
            ["field" => "email", "relation" => "=", "value" => "[email protected]"],
            ...
        ),
        $url = null,
        $data = null,
        $buttons = null,
        $schedule = null
    );

    OneSignal::sendNotificationUsingTags(
        "Some Message",
        array(
            ["field" => "session_count", "relation" => ">", "value" => '2'],
            ["field" => "first_session", "relation" => ">", "value" => '2000'],
        ),
        $url = null,
        $data = null,
        $buttons = null,
        $schedule = null
    );

    OneSignal::sendNotificationToUser(
        "Some Message",
        $userId,
        $url = null,
        $data = null,
        $buttons = null,
        $schedule = null
    );

    OneSignal::sendNotificationToSegment(
        "Some Message",
        $segment,
        $url = null,
        $data = null,
        $buttons = null,
        $schedule = null
    );

    OneSignal::sendNotificationCustom($parameters);

    OneSignal::async()->sendNotificationCustom($parameters);

php artisan vendor:publish --tag=config