PHP code example of hoyf / pushwoosh

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

    

hoyf / pushwoosh example snippets


// Create a new notification.
$notification = Notification::create()->setContent('Hello Jean !');

// Create a request for the '/createMessage' web service.
$request = CreateMessageRequest::create()->addNotification($notification);

// Send out the notification.
$response = $pushwoosh->createMessage($request);

// Check if it was sent ok.
$response->isOk();

Hoy\Pushwoosh\PushwooshServiceProvider::class

'Pushwoosh' => Hoy\Pushwoosh\Facades\Pushwoosh::class

// You can alias this in config/app.php.
use Hoy\Pushwoosh\Facades\Pushwoosh;

Pushwoosh::createMessage($request);
// We're done here - how easy was that, it just works!

Pushwoosh::getApplication();
// This example is simple and there are far more methods available.

use Hoy\Pushwoosh\Facades\Pushwoosh;

// Writing this…
Pushwoosh::connection('main')->createMessage($request);

// …is identical to writing this
Pushwoosh::createMessage($request);

// and is also identical to writing this.
Pushwoosh::connection()->createMessage($request);

// This is because the main connection is configured to be the default.
Pushwoosh::getDefaultConnection(); // This will return main.

// We can change the default connection.
Pushwoosh::setDefaultConnection('alternative'); // The default is now alternative.

use Hoy\Pushwoosh\PushwooshManager;

class Foo
{
	protected $pushwoosh;

	public function __construct(PushwooshManager $pushwoosh)
	{
		$this->pushwoosh = $pushwoosh;
	}

	public function bar($request)
	{
		$this->pushwoosh->createMessage($request);
	}
}

App::make('Foo')->bar();
bash
php artisan vendor:publish