Skip to content

Simple PHP Implementation for send Push Notification with OneSignal Service

License

Notifications You must be signed in to change notification settings

jeanjar/onesignal-simple-push-notification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple PHP Implementation for send Push Notification with OneSignal Service

Examples

Initial Setup

<?php
use JeanJar\OneSignal\PushNotification;

$api_id = 'API_ID';
$rest_api_key = 'REST_API_KEY';

$pushNotification = new PushNotification($api_id, $rest_api_key);

Create notification

Send to all subscribers

<?php
$pushNotification->setBody('English Message')
                 ->setSegments('All')
                 ->prepare()
                 ->send();

Send to a specific segment

<?php
$pushNotification->setBody('English Message')
                 ->setSegments('Active Users')
                 ->prepare()
                 ->send();

Send based on filters/tags

<?php
$pushNotification->setBody('English Message')
                 ->setFilter([
                     ['field' => 'tag', 'key' => 'level', 'relation' => '>', 'value' => '10'],
                     ['operator' => 'OR'],
                     ['field' => 'amount_spent', 'relation' => '>', 'value' => '0']
                 ])
                 ->prepare()
                 ->send();

Send based on OneSignal PlayerIds

<?php
$pushNotification->setBody('English Message')
                 ->setPlayersId([
                    'PLAYER_ID',
                    'ANOTHER_PLAYER_ID' 
                 ])
                 ->prepare()
                 ->send();

Reference guideline

OneSignal API Reference

TODO list

  • Apply S.O.L.I.D concepts
  • Tests
  • Error Validations
  • OneSignal - Cancel Notification
  • OneSignal - View apps
  • OneSignal - View an app
  • OneSignal - Create an app
  • OneSignal - Update an app
  • OneSignal - View devices
  • OneSignal - View device
  • OneSignal - Add a device
  • OneSignal - Edit device
  • OneSignal - New session
  • OneSignal - New purchase
  • OneSignal - Increment session length
  • OneSignal - CSV export
  • OneSignal - View notification
  • OneSignal - View notifications
  • OneSignal - Track Open

Enjoy!

Wanna by me a coffee? ☕

About

Simple PHP Implementation for send Push Notification with OneSignal Service

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages