Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/azhovan/push-notification-library
Send push notification to Android and IOS devices with PHP
https://github.com/azhovan/push-notification-library
android apns autoload fcm ios notification-library notifications php server
Last synced: 3 days ago
JSON representation
Send push notification to Android and IOS devices with PHP
- Host: GitHub
- URL: https://github.com/azhovan/push-notification-library
- Owner: Azhovan
- Created: 2017-09-23T14:58:34.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-08-25T15:04:23.000Z (3 months ago)
- Last Synced: 2024-09-26T02:18:23.019Z (about 2 months ago)
- Topics: android, apns, autoload, fcm, ios, notification-library, notifications, php, server
- Language: PHP
- Homepage:
- Size: 153 KB
- Stars: 22
- Watchers: 1
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Push Notification Library for php
Standalone PHP library for easy devices message notifications push.
**Feel free to contribute!**Installation
-------------composer require push-notification/push-notification-php-library
composer dump-autoload -oThis repository uses PSR-0 autoload. After installation with composer please adjust you autoloading config if needed or include vendor/autoload.php in your index.php.
**Requirements:**
> - PHP 5.6+
> - PHP Curl and OpenSSL modules> **available supports:**
>
> - APNS (Apple)
> - GCM (Android) and FCM (Android)### Setting
1. settings of your provider (Apn, Fcm) at **.env**
(make sure you renamed the .env.example to .env and filled all the requirements)2. path to .env file :
you need to set **$path** variable at ```src/PushNotification/Setting``` to the .env file### How to use :
```php
include_once "vendor/autoload.php";use PushNotification\Service\PushService;
$data = array(
'device' => array(
'name' => '', // Android or AppleIOS
'token' => '', // device token | user token , if you want to send to apple device you have to fill this
'id' => 'unique id here'),'message' => array(
'action' => 'test',
'title' => 'this is test title',
'targets' => array(''), // if you want to use Fcm you can inclue array of targets
'body' => 'this is body',
'type' => '', // AndroidMessages or IOSMessages
'data' => array('type' => 'testType'))
);$response = PushService::getInstance()->send($data);
```
### Android :
```php
include_once "vendor/autoload.php";use PushNotification\Service\PushService;
$data = array(
'device' => array(
'name' => 'Android',
'token' => '',
'id' => 'some id here '),'message' => array(
'action' => 'test',
'title' => 'this is test title',
'targets' => array('token1', 'token2', 'token3'),
'body' => 'this is body',
'type' => 'AndroidMessages',
'data' => array('type' => 'testType'))
);
$response = PushService::getInstance()->send($data);
print_r($response);```
### IOS :
```php
include_once "vendor/autoload.php";use PushNotification\Service\PushService;
$data = array(
'device' => array(
'name' => 'AppleIOS',
'token' => 'token',
'id' => 'BECDSx'),'message' => array(
'action' => 'test',
'title' => 'this is test title',
'targets' => array(),
'body' => 'this is body',
'type' => 'IOSMessages',
'data' => array('type' => 'testType'))
);
$response = PushService::getInstance()->send($data);
print_r($response);```