https://github.com/gdpa/chabok
Chabok Notification Channel for laravel
https://github.com/gdpa/chabok
chabok-notification laravel push-notification
Last synced: 2 months ago
JSON representation
Chabok Notification Channel for laravel
- Host: GitHub
- URL: https://github.com/gdpa/chabok
- Owner: gdpa
- License: mit
- Created: 2018-08-18T08:53:35.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2021-01-11T12:19:57.000Z (over 5 years ago)
- Last Synced: 2025-05-31T13:22:01.803Z (about 1 year ago)
- Topics: chabok-notification, laravel, push-notification
- Language: PHP
- Homepage:
- Size: 34.2 KB
- Stars: 5
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Chabok notifications channel for Laravel 5.3+
[](https://packagist.org/packages/gdpa/chabok)
[](LICENSE.md)
[](https://travis-ci.org/gdpa/chabok)
[](https://github.styleci.io/accounts/145205024)
[](https://scrutinizer-ci.com/g/gdpa/chabok/?branch=master)
[](https://scrutinizer-ci.com/g/gdpa/chabok/?branch=master)
[](https://packagist.org/packages/gdpa/chabok)
This package makes it easy to sent [Chabok](https://chabokpush.com//) Notifications with Laravel 5.3+.
## Contents
- [Installation](#installation)
- [Setting up the Chabok service](#setting-up-the-chabok-service)
- [Usage](#usage)
- [Available Message methods](#available-message-methods)
- [Changelog](#changelog)
- [Testing](#testing)
- [Security](#security)
- [Contributing](#contributing)
- [Credits](#credits)
- [License](#license)
## Installation
You can install the package via composer:
``` bash
composer require gdpa/chabok
```
Install for laravel 7:
``` bash
composer require gdpa/chabok:^3.1
```
Install for laravel 6:
``` bash
composer require gdpa/chabok:^2.0
```
Install for laravel < 5.8:
``` bash
composer require gdpa/chabok:^1.0
```
### Setting up the Chabok service
Add your Chabok REST API Key to your `config/services.php`:
```php
// config/services.php
...
'chabok' => [
'app_id' => env('CHABOK_APP_ID'),
'key' => env('CHABOK_API_KEY'),
],
...
```
You can add additional configuration for adding to request from config:
```php
// config/services.php
...
'chabok' => [
'app_id' => env('CHABOK_APP_ID'),
'key' => env('CHABOK_API_KEY'),
'additional' => [
'timeout' => 5,
'request_timeout' => 10
]
],
...
```
**Note: If you want to test chabok set `app_id` to `sandbox`.**
## Usage
Now you can use the channel in your `via()` method inside the notification:
``` php
use NotificationChannels\Chabok\ChabokChannel;
use NotificationChannels\Chabok\ChabokMessage;
use Illuminate\Notifications\Notification;
class ProjectCreated extends Notification
{
public function via($notifiable)
{
return [ChabokChannel::class];
}
public function toChabok($notifiable)
{
return ChabokMessage::create()
->content("This is the Chabok notification description")
->data(['id' => 1, 'title' => 'This is notification data']);
}
}
```
In order to let your Notification know which Chabok user you are targeting, add the `routeNotificationForChabok` method to your Notifiable model.
This method needs to return an uuid containing the your registered token on chabok.
```php
public function routeNotificationForChabok()
{
return [
'uuid' => 'user-uuid-which-set-on-chabok-by-client',
];
}
```
### Available methods
- `content('')`: Accepts a string value for the Chabok notification content.
- `trackId('')`: Accepts a string value for the Chabok notification trackId.
- `inApp()`: Call this if you want to set the Chabok notification inApp to true.
- `live()`: Call this if you want to set the Chabok notification live to true.
- `alert(''')`: Call this with no parameters if you want to set the Chabok notification useAsAlert to true. If you provide some string, it will set as alert text.
- `ttl('')`: Accepts a integer value for the Chabok notification ttl.
- `data([])`: Accepts a array for the Chabok notification data.
- `fallback([])`: Accepts a array for the Chabok notification fallback.
- `clientId('')`: Accepts a string value for the Chabok notification clientId.
- `notification([])`: Accepts a array for the Chabok notification notification.
- `idr()`: Call this if you want to set the Chabok notification idr to true.
- `silent()`: Call this if you want to set the Chabok notification silent to true.
- `binary('')`: Accepts a string value for the Chabok notification contentBinary.
- `type('')`: Accepts a string value for the Chabok notification contentType.
- `id('')`: Accepts a number value for the Chabok notification id.
## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
## Testing
``` bash
$ composer test
```
## Security
If you discover any security related issues, please email morteza.poussaneh@gmail.com instead of using the issue tracker.
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
## Credits
- [Morteza Poussaneh](https://github.com/gdpa)
- [All Contributors](../../contributors)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.