PHP code example of jlorente / laravel-pushy

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

    

jlorente / laravel-pushy example snippets


return [
    //other stuff
    'providers' => [
        //other stuff
        \Jlorente\Laravel\Pushy\PushyServiceProvider::class,
    ];
];

return [
    //other stuff
    'aliases' => [
        //other stuff
        'Pushy' => \Jlorente\Laravel\Pushy\Facades\Pushy::class,
    ];
];

return [
    'api_key' => 'YOUR_SECRET_API_KEY',
    //other configuration
];

Pushy::api()->deviceInfo($token);

/**
 * Get the PushyMessage that represents the notification.
 *
 * @param  mixed  $notifiable
 * @return \Jlorente\Laravel\Pushy\Notifications\Messages\PushyMessage|array
 */
public function toPushy($notifiable)
{
    return (new PushyMessage)
                ->setData([
                    'eventName' => 'my_event_name'
                ])
                ->setTimeToLive(3600);
}

/**
 * Get the notification channels.
 *
 * @param  mixed  $notifiable
 * @return array|string
 */
public function via($notifiable)
{
    return [PushyChannel::class];
}



namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Notifiable;

    /**
     * Route notifications for the Pushy channel.
     *
     * @param  \Illuminate\Notifications\Notification  $notification
     * @return string
     */
    public function routeNotificationForPushy($notification)
    {
        return $this->device_token;
    }
}
bash
$ php composer.phar 
bash
$ php artisan vendor:publish --provider=Jlorente\\Laravel\\Pushy\\PushyServiceProvider