PHP code example of paliari / php-push-notification

1. Go to this page and download the library: Download paliari/php-push-notification 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/ */

    

paliari / php-push-notification example snippets


use Paliari\PushFacade;
$configs = [
 'one_signal' => [
   '<yor app name>' => [
     'app_id'       => '<yor app_id>',
     'rest_api_key' => '<yor rest_api_key>',
   ],
   '<yor app name 2>' => [
     'app_id'       => '<yor app_id 2>',
     'rest_api_key' => '<yor rest_api_key 2>',
   ],
 ],
 'expo'       => [...],
];

PushFacade::setUp($configs);

use Paliari\PushFacade;

$tokens = ['<token_01>', '<token_02>','<token_n>'];
$extra_params = [
  'title' => '<your title message>', // optional
  'url' => 'http://website.com', // optional for web
  'data' => [
    '<your custom param>' => '<your custom value>',
    // ... any ...
  ],
]; 
$provider = PushFacade::ONE_SIGNAL;
$app_name = '<your-app-name>';
$message = '<your message content.>';
PushFacade::provider($provider, $app_name)->send($message, $tokens, $extra_params);