94

GitHub - kadircanerergun/laravel-onesignal: One Signal Push Notification Library...

 5 years ago
source link: https://github.com/kadircanerergun/laravel-onesignal
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md

Laravel OneSignal

Build Status

Send push notifications easily with OneSignal

Contents

Installation

In order to add Laravel OneSignal to your project, just add

composer require kce/onesignal-laravel

Composer auto discovery will register the provider. If dont use it add the following lines to "config/app.php"

'providers' => [
        ...
        .
        .
        KCE\OneSignal\OneSignalServiceProvider::class
]
...
.
.,
'aliases' => [
    ...
    ..
    .
    'OneSignalClient' => KCE\OneSignal\Facades\OneSignalClient::class
]

Publish the configuration

php artisan vendor:publish --provider="KCE\OneSignal\OneSignalServiceProvider"

Usage

Configuration

This package requires you to change the fields in the config/onesignal.php file:

return array (
    /*
     |--------------------------------------------------------------------------
     | One Signal App Id
     |--------------------------------------------------------------------------
     |
     | You can find in : Project > Settings > Key & ID's > ONESIGNAL APP ID
     |
     */
    'app_id' => env("ONESIGNAL_APP_ID", 'default_app_id'),

    /*
     |--------------------------------------------------------------------------
     | Rest API Key
     |--------------------------------------------------------------------------
     |
     | You can find in : Project > Settings > Key & ID's > REST API KEY
     |
     */
    'rest_api_key' => env("ONESIGNAL_REST_API_KEY", 'rest_api_key'),

    /*
     |--------------------------------------------------------------------------
     | User Auth Key
     |--------------------------------------------------------------------------
     |
     | You can find in : Profile > ACCOUNT & API KEYS > AUTH KEY
     |
     */
    'user_auth_key' => env("ONESIGNAL_USER_AUTH_KEY", 'user_auth_key'),
);

Send to ALL

Send notification to all subscribed devices

Send to Country

Send notification to specific country

Send to Location

Send notification to a particular area-wide. Use radius in meters

Send to single user or users.

Send notification to player ids.

or

Send to segment

Send notification to one or more segments

Send to Tags

Send notification filter by tags

Add Data and/or Title To Notifications

Scheduling

You can schedule notification for future date time.

Schedule based on User's Timezone

Notification will deliver at a specific time-of-day in each users own timezone.

addTag / addOrTag

If you use addTag or addTags method it will put AND between tags. If you want to use multiple tags with "OR" connector, you should use addOrTag method.

Send by First / Last Session

Typically filters has 3 parameters (key, relation, value) but some filters like last_session, first session has their own value keys. You can add specific value key as 4th parameter. If you want to send notification by users last or first active time you can use addFilter method by value key.

Multi Language Notifications

Default notification language is English. But if you want you can send notification to each user in their language. Just add an language => message array as message to any of send methods.

MORE OPTIONS

You can use method chaining...

License

Laravel OneSignal is free software distributed under the terms of the MIT license.

Feel free to send pull requests.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK