56 lines
1.5 KiB
PHP
Executable File
56 lines
1.5 KiB
PHP
Executable File
<?php
|
|
|
|
namespace Mautic\NotificationBundle\Controller;
|
|
|
|
use Mautic\CoreBundle\Controller\CommonController;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
class JsController extends CommonController
|
|
{
|
|
/**
|
|
* We can't user JsonResponse here, because
|
|
* it improperly encodes the data array.
|
|
*/
|
|
public function manifestAction(): Response
|
|
{
|
|
$gcmSenderId = $this->coreParametersHelper->get('gcm_sender_id', '446150739532');
|
|
$data = [
|
|
'start_url' => '/',
|
|
'gcm_sender_id' => $gcmSenderId,
|
|
'gcm_user_visible_only' => true,
|
|
];
|
|
|
|
return new Response(
|
|
json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES),
|
|
200,
|
|
[
|
|
'Content-Type' => 'application/json',
|
|
]
|
|
);
|
|
}
|
|
|
|
public function workerAction(): Response
|
|
{
|
|
return new Response(
|
|
"importScripts('https://cdn.onesignal.com/sdks/OneSignalSDK.js');",
|
|
200,
|
|
[
|
|
'Service-Worker-Allowed' => '/',
|
|
'Content-Type' => 'application/javascript',
|
|
]
|
|
);
|
|
}
|
|
|
|
public function updaterAction(): Response
|
|
{
|
|
return new Response(
|
|
"importScripts('https://cdn.onesignal.com/sdks/OneSignalSDK.js');",
|
|
200,
|
|
[
|
|
'Service-Worker-Allowed' => '/',
|
|
'Content-Type' => 'application/javascript',
|
|
]
|
|
);
|
|
}
|
|
}
|