Skip to content

This is a php laravel , composer library for implementing OneSignal push notifications

Notifications You must be signed in to change notification settings

lordjoo/onesignal-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OneSignal PHP Library

This PHP Library help You Integrate OneSignal Push Notification Easily in your website

This Library Supports Laravel Framework

Features

Two Ways You Can Send The Notification
  • Send Notification To all Subscribed Users
  • Send To Specific User
  • Send To Segment

Notification Features

  • Send With Custom Logo icons (Required)
  • Send With Large Image (Optional)
  • Send With Custom Badge (Optional)
  • Send With Unlimited Customized Buttons (Optional)

Installation

whether you re using laravel or not just install the package wit

composer require youssef20000/onesignal-php  

if you are using laravel >= 5.6 The Package will be detected automatically

Laravel Only

Publish the Config File For The Library

 php artisan vendor:publish --tag=config

How To Use It ?

Requiring And Initialize The Library

<?php 
// Require The Outload File For Composeer 
use Youssef\OneSignal\OneSignal;
// if not laravel 
$notification = new OneSignal($appID,$apiKEY);
// if laravel the appid and apikey will be obtained from the config file
?>

The Properties to change

Property Name Is Required The Value
$heading ☑️ The Title Heading With language code in array $notification->heading = ["en"=>"hello World !","ar"=>"مرحبا بالعالم"]
$content ☑️ The Notification Body With language code like the $heading
$logo ☑️ The Logo Url String
$image -- The Big Image Url String
$url -- The Action Url That Will Opened String
$appUrl -- If You Have App Url You Want Notification Redirect user To String
$buttons -- The Buttons Array Examples At The Official Docs
$badge -- The Notification Bage Icon Url string

EX1: Send To All Users
  $notification->sendToAll(); // This Will Reqturn A JSON With The Response From OneSginal
EX2: Send To Specific User
  $notification->sendToSpecific($userSuscribtionID); // This Will Reqturn A JSON With The Response From OneSginal
EX3: Send To Custom Segments
  $notification->sendToSegment($segmentsArray); // This Will Reqturn A JSON With The Response From OneSginal

To Do

  • Fix Buttons Format Error
  • Add Send To Multi Users By IDs
  • [*] Add Unit Test
  • [*] Handle Exceptions
  • Add Send To Custom Devices

About

This is a php laravel , composer library for implementing OneSignal push notifications

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages