first commit
This commit is contained in:
80
app/Notifications/DirectPushNotificationUser.php
Normal file
80
app/Notifications/DirectPushNotificationUser.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Channels\OneSignalChannel;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class DirectPushNotificationUser extends Notification implements ShouldQueue
|
||||
{
|
||||
|
||||
use Queueable;
|
||||
|
||||
public $tries = 2;
|
||||
public $timeout = 60;
|
||||
|
||||
public $param;
|
||||
|
||||
public function __construct(
|
||||
$param
|
||||
)
|
||||
{
|
||||
$this->param = $param;
|
||||
}
|
||||
|
||||
public function via($notifyRoutes)
|
||||
{
|
||||
return [OneSignalChannel::class];
|
||||
}
|
||||
|
||||
public function toOneSignal($notifyRoutes)
|
||||
{
|
||||
|
||||
/*$param = [
|
||||
'subject' => 'Otel Bilgileri Güncelleme',
|
||||
'message' => $params['property_info']['name']. ' Otel Bilgileri Güncellendi.',
|
||||
'oneSignalPlayerIds' => ['5931bd16-daac-43f4-824c-c953b8902e96']
|
||||
|
||||
];
|
||||
Notification::route('OneSignal', null)->notify(new DirectPushNotificationUser($param));*/
|
||||
|
||||
$oneSignalService = App::make("App\Core\Service\OneSignalService");
|
||||
|
||||
$restUrl = 'https://onesignal.com/api/v1/notifications';
|
||||
|
||||
if (!empty($this->param['oneSignalPlayerIds'])) {
|
||||
|
||||
$payloadJson = [
|
||||
'include_player_ids' => $this->param['oneSignalPlayerIds'],
|
||||
'headings' => [
|
||||
'en' => $this->param['subject']
|
||||
],
|
||||
'contents' => [
|
||||
'en' => $this->param['message']
|
||||
]
|
||||
];
|
||||
|
||||
if (isset($this->param['subtitle'])) {
|
||||
$payloadJson['subtitle'] = [
|
||||
'en' => $this->param['subtitle']
|
||||
];
|
||||
}
|
||||
|
||||
if (isset($this->param['url'])) {
|
||||
//$payloadJson['url'] = $this->param['url'];
|
||||
$payloadJson['data']['url'] = $this->param['url'];
|
||||
}
|
||||
|
||||
|
||||
$sendOneSignalPushNotification = $oneSignalService->sendOneSignalPushNotification($restUrl, $payloadJson);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user