hatasever / onesignal
Onesignal push Notification api
1.0.5
2024-10-11 12:40 UTC
Requires
- php: >=5.4.0
- guzzlehttp/guzzle: ^7.9
Requires (Dev)
- orchestra/testbench: ^8.18
- vlucas/phpdotenv: ^2.2|^5.5
README
It allows you to send notifications via laravel using Onesignal push notification service.
Installation
Install the dependencies and devDependencies.
"```sh composer require hatasever/onesignal
Add these 3 parameters to the .env file
```sh
ONESIGNAL_APP_ID= Onesignal App id
ONESIGNAL_REST_API_KEY= Onesignal Api Key
USER_AUTH_KEY= OneSignal Auth Key
Add it to the service provider array in the config/app.php file
'providers' => [ . . * Package Service Providers... Hatasever\OneSignal\OneSignalServiceProvider::class, ], 'aliases' => [ . . . 'OneSignal' => Hatasever\OneSignal\OneSignalServiceProvider::class, ]
Send Notifications
use OneSignal; $params = []; $params['include_external_user_ids'] = [$userId]; /* Mobile app icon */ $params['small_icon'] = 'mdpi'; $params['large_icon'] = 'xxxhdpi'; $contents = [ "en" =>'Hello World!', "tr" => 'Merhaba Dünya!', ]; $params['contents'] = $contents; OneSignal::sendNotificationCustom($params);