hatasever/onesignal

Onesignal push Notification api

1.0.5 2024-10-11 12:40 UTC

This package is auto-updated.

Last update: 2024-12-11 13:21:26 UTC


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);