Download the PHP package codprox/laravel-onesignal without Composer
On this page you can find all versions of the php package codprox/laravel-onesignal. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download codprox/laravel-onesignal
More information about codprox/laravel-onesignal
Files in codprox/laravel-onesignal
Package laravel-onesignal
Short Description A Laravel package for OneSignal push notifications
License MIT
Informations about the package laravel-onesignal
Laravel-OneSignal
Package Laravel optimisé pour interconnecter votre backend avec OneSignal, permettant l'envoi de notifications push, la gestion de segments, et l'inscription d'utilisateurs de manière simple et performante.
Prérequis
- PHP >= 8.2
- Laravel >= 11.0
- Compte OneSignal avec un
App IDet uneREST API Key
Installation
Installez le package via Composer :
Publiez le fichier de configuration (Cela créera un fichier config/onesignal.php dans votre projet) : php artisan vendor:publish --tag=onesignal-config
Le fichier config/onesignal.php contient les options par défaut : return [ 'app_id' => env('ONESIGNAL_APP_ID'), 'rest_api_key' => env('ONESIGNAL_REST_API_KEY'), 'default_icon' => env('ONESIGNAL_DEFAULT_ICON', 'https://example.com/icon.png'), 'cache_ttl' => env('ONESIGNAL_CACHE_TTL', 3600), // Durée en secondes 'timeout' => env('ONESIGNAL_TIMEOUT', 10.0), // Timeout HTTP en secondes 'connect_timeout' => env('ONESIGNAL_CONNECT_TIMEOUT', 5.0), // Timeout de connexion ];
Utilisation
```Le package fournit une classe MyOneSignal accessible via une façade ou par injection de dépendance.
*** Via la Façade
use Codprox\OneSignal\Facades\OneSignal; OneSignal::sendToAll(['Subject', 'Body'], ['badge_count' => 1]);
*** Via Injection de Dépendance
use Codprox\OneSignal\MyOneSignal; class NotificationController extends Controller { protected MyOneSignal $oneSignal;
public function __construct(MyOneSignal $oneSignal)
{
$this->oneSignal = $oneSignal;
}
public function send()
{
$this->oneSignal->sendToAll(['Test', 'Hello World']);
}
}
Méthodes Disponibles
-
sendToAll(array $message, array $extraData = [], ?string $scheduledTime = null): array