All Projects → shailesh-ladumor → one-signal

shailesh-ladumor / one-signal

Licence: MIT license
Laravel One Signal Wrapper

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to one-signal

claim-reporter-pwa-poc
Example PWA application with Angular 6 and backend with Node
Stars: ✭ 39 (-56.67%)
Mutual labels:  push-notifications
OneSignal-Ionic-Sample
No description or website provided.
Stars: ✭ 85 (-5.56%)
Mutual labels:  push-notifications
homebridge-http-rgb-push
Homebridge plugin to control a web/http-based RGB device.
Stars: ✭ 16 (-82.22%)
Mutual labels:  push-notifications
pushnotification
Push notifications with Spring Boot and OneSignal
Stars: ✭ 25 (-72.22%)
Mutual labels:  push-notifications
hms-push-serverdemo-php
PHP sample code encapsulates APIs of the HUAWEI Push Kit server.It provides many sample PHP programs about quick access to HUAWEI Push Kit for your reference or usage.
Stars: ✭ 21 (-76.67%)
Mutual labels:  push-notifications
react-native-android-notification-listener
React Native Android Notification Listener - Listen for status bar notifications from all applications
Stars: ✭ 87 (-3.33%)
Mutual labels:  push-notifications
hms-push-serverdemo-java
Java sample code encapsulates APIs of the HUAWEI Push Kit server. It provides many sample programs for your reference or usage.
Stars: ✭ 39 (-56.67%)
Mutual labels:  push-notifications
OneSignal-Java-SDK
OneSignal SDK
Stars: ✭ 28 (-68.89%)
Mutual labels:  push-notifications
food-delivery-ios-app
A food delivery application built using Swift for iOS. The application uses Pushers notifications feature to send push notifications to mobile devices.
Stars: ✭ 36 (-60%)
Mutual labels:  push-notifications
browser-push
Complete workout and guidelines to add web push notifications support for your webapp without third-party notification provider
Stars: ✭ 67 (-25.56%)
Mutual labels:  push-notifications
FcmNotificationHandler
Android library that helps to construct and launch system tray notifications from FCM Notification messages received when the app is in foreground mimicking the default format and behavior applied when the app is background.
Stars: ✭ 18 (-80%)
Mutual labels:  push-notifications
GroundControl
Push notification service for Bitcoin wallets
Stars: ✭ 70 (-22.22%)
Mutual labels:  push-notifications
ejabberd mod gcm
Google Cloud Messaging API for Ejabberd (PUSH Messages)
Stars: ✭ 27 (-70%)
Mutual labels:  push-notifications
expo-push-notification-helper
💬🔥This package helps you make expo push notification for React Native easy to use.
Stars: ✭ 32 (-64.44%)
Mutual labels:  push-notifications
fcmpush
Firebase Cloud Messaging API wrapper for Ruby, suppot HTTP v1 API including access_token auto refresh feature.
Stars: ✭ 44 (-51.11%)
Mutual labels:  push-notifications
apns
Vapor APNS for iOS
Stars: ✭ 59 (-34.44%)
Mutual labels:  push-notifications
ios
React Native Push Notification API for iOS.
Stars: ✭ 604 (+571.11%)
Mutual labels:  push-notifications
node-xcs
NodeJS implementation of Google's XMPP Connection Server
Stars: ✭ 37 (-58.89%)
Mutual labels:  push-notifications
mobpush-api-java-client
MobPush 服务端集成SDK for Java
Stars: ✭ 14 (-84.44%)
Mutual labels:  push-notifications
node-onesignal
Node.js wrapper for the One Signal API
Stars: ✭ 33 (-63.33%)
Mutual labels:  push-notifications

Laravel One Signal

Laravel One Signal is Laravel Wrapper for One Signal. One Signal is a great platform for send a push notification to your users. This package mentions in One Signal's official Document. you can see here

Total Downloads Daily Downloads Monthly Downloads License

Give a Star if this package realy usefull to you. it's free 😆

🎞️ here are video tutorials

How to install and how to implement notifications and devices APIs.

how to implement Segment and Apps APIs.

Contents

Watch Other Lavavel tutorial here

)

Installation

Install the package by the following command,

composer require ladumor/one-signal:0.4.3

Publish the config file

Run the following command to publish config file,

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

Add Provider

Add the provider to your config/app.php into provider section if using lower version of laravel,

Ladumor\OneSignal\OneSignalServiceProvider::class,

Add Facade

Add the Facade to your config/app.php into aliases section,

'OneSignal' => \Ladumor\OneSignal\OneSignal::class,

Add ENV data

Add your api keys and OneSignal app id to your .env,

ONE_SIGNAL_APP_ID=XXXXXX-XXXXXX-XXXXXX-XXXXXX  (YOUR APP ID)
ONE_SIGNAL_AUTHORIZE=XXXXXX                    (REST API KEY)
ONE_SIGNAL_AUTH_KEY=XXXXXXX                    (YOUR USER AUTH KEY)

You can call them into your code with,

Usage

Send Push Notification

For send push notification, use the sendPush method by calling,

$fields['include_player_ids'] = ['xxxxxxxx-xxxx-xxx-xxxx-yyyyyyyyy'];
$message = 'hey!! this is test push.!'   

OneSignal::sendPush($fields, $message);

Optionally, you can obtain the id of the notification like this,

$notificationID = OneSignal::sendPush($fields, $message);
echo $notificationID["id"];

Cancel Notification

To cancel a notification, use the cancelNotification method by calling,

$notificationID = 'xxxxxxxx-xxxx-xxx-xxxx-yyyyyyyyy';

OneSignal::cancelNotification($notificationID);

Customise Contents

You can customise a contents and pass it in fields. message does not required when you pass contents

$fields['include_player_ids'] = ['xxxxxxxx-xxxx-xxx-xxxx-yyyyyyyyy'];
$fields['contents'] = array(
                          "en" => 'English Message',
                          "es" => 'Spanish Message',
                      );
OneSignal::sendPush($fields);

Get All Notifications

For retrieve all notifications, use the getNotifications method by calling,

OneSignal::getNotifications();

You can check here return response format.

Get Single Notification

For retrieve single notification, use the getNotification method with id param by calling,

OneSignal::getNotification($notificationId);    

You can check here return response format.

Get All Devices

For retrieve all user devices, use the getDevices method by calling,

OneSignal::getDevices();

You can check here return response format.

Get Single Device

For retrieve single Devices, use the getDevice method with id param by calling,

OneSignal::getDevice($deviceId);    

You can check here return response format.

Create Device

For add a device in your application, use the addDevice method by calling, if you want to create device in different application than you can specify app_id in $fields array.

 $fields = [
        'device_type'  => 0,
        'identifier'   => '7abcd558f29d0b1f048083e2834ad8ea4b3d87d8ad9c088b33c132706ff445f0',
        'timezone'     => '-28800',
        'game_version' => '1.1',
        'device_os'    => '7.0.4',
        'test_type'    => 1,
        'device_model' => "iPhone 8,2",
        'tags'         => array("foo" => "bar")
    ];
    
 return OneSignal::addDevice($fields);   

You can check here supported parameters and guide.

Update Device

For update a device in your application, use the addDevice method by calling, if you want to update device in different application than you can specify app_id in $fields array.

 $fields = [
        'device_type'  => 0,
        'identifier'   => '7abcd558f29d0b1f048083e2834ad8ea4b3d87d8ad9c088b33c132706ff445f0',
        'timezone'     => '-28800',
        'game_version' => '1.1',
        'device_os'    => '7.0.4',
        'test_type'    => 1,
        'device_model' => "iPhone 8,2",
        'tags'         => array("foo" => "bar")
    ];
    
 $playerId = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
    
 return OneSignal::updateDevice($fields, $playerId);   

You can check here supported parameters and guide.

Delete Device

Delete existing device on your application

OneSignal::deleteDevice($deviceId);

Create Segment

NOTE: REQUIRED ONE-SIGNAL PAID PLAN

For add a new segment in your application, use the createSegment method by calling,

 $fields = [
         'name' => 'iOS, Android, Web',
         "filters" => array("field" => "device_type", "relation" => "=", "value" => "Android"),
     ];

return OneSignal::createSegment($fields); 

You can check here supported parameters and guide.

OneSignal::deleteSegment('YOUR_SEGMENT_ID')

Delete Segment

NOTE: REQUIRED ONE-SIGNAL PAID PLAN

You can check here for more guide.

Apps

Note*: Auth key must be set in one-signal.php how to get auth_key?

View Apps

View the details of all of your current OneSignal apps

 $apps = OneSignal::getApps();

You can check here api response.

View App

View the details of single of your current OneSignal app or other app by passing app id.

 // It's return default site which is configured in config.
 $app = OneSignal::getApp();
 
 // you can specify app id as wel but it's optional
 $app = OneSignal::getApp('YOUR_APP_ID');

You can check here api response.

Create App

Creates a new OneSignal app.

 $fields = array(
        'name' => "TestByMe"
    );

 OneSignal::createApp($fields);

You can check here supported parameters and guide.

Update App

Update a new OneSignal app.

 $fields = array(
        'name' => "TestByMe"
    );

 OneSignal::updateApp($fields);
 // you can pass second param as a appId if you want to update other app.. default take from config.

You can check here supported parameters and guide.

User Device

You can generate a User Device APIs with just one command,

php artisan one-signal.userDevice:publish

this command generate following files,

  • UserDeviceAPIController
  • UserDeviceAPIRepository
  • UserDevice (model)
  • Migration

Also, do not forget to add following routes in to the api.php file.

use App\Http\Controllers\API\UserDeviceAPIController;
  Route::post('user-device/register', [UserDeviceAPIController::class, 'registerDevice']);
  Route::get('user-device/{playerId}/update-status', [UserDeviceAPIController::class, 'updateNotificationStatus']);

Change Log

Please see Change Log here

License

The MIT License (MIT). Please see License File for more information

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].