PHP code example of gaziantep-bilisim / onesignal_laravel
1. Go to this page and download the library: Download gaziantep-bilisim/onesignal_laravel library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gaziantep-bilisim / onesignal_laravel example snippets
$instance = GBSignal::createNotification(); # Create Notification
$instance->notification # Adjust the notification
->setHead('Selamlar') # Set Head
->setContent('Selam') # Set Content
->setData('key', 'value') # Set Data
->setSendAfter(Carbon::now()->addMinutes(10)) # Set Send After (Must Be Carbon Instance)
->addButton('id', 'button') # Add Button
->addButton('id2', 'button2'); # Add Button
/*
Onesignal üzerinde kayıtlı herkes'e gönderir
*/
$response = $instance->sendToAll();
/*
Onesignal üzerinde external id'leri kullanarak bildirim gönderme
Array Beklemektedir
Array ürünleri String olmalıdır
*/
$response = $instance->sendToExternal(['external_id1', 'external_id2']);
/*
Onesignal üzerinde kaydedilen tagler'i kullanarak bildirim gönderme
$key tagin ismi
$array bu taga için değerler !array beklemektedir
*/
$response = $instance->sendToTag($key, '=', $array); //Onesignal e kaydedilen tagları kullanarak bildirim gönderme
use HumblDump\GBSignal\OneSignal\Notification; //modelin sınıfını çek
/*
Veri tabanı üzerinden gönderdiğimiz modeli çek
*/
$oldNotification = \HumblDump\GBSignal\OneSignal\Notification::query()->first();
/*
Metoda çektiğimiz bu modeli aktar
*/
$response = GBSignal::getNotification($oldNotification); # Get notification invidual