Fix #1939 #1952 add default sound to push notifications

This commit is contained in:
Kijin Sung 2022-06-09 21:15:18 +09:00
parent 8d26ca1a90
commit 241a26436a
2 changed files with 11 additions and 5 deletions

View file

@ -54,12 +54,17 @@ class APNs extends Base implements \Rhymix\Framework\Drivers\PushInterface
// Set parameters // Set parameters
$local_cert = $this->_config['certificate']; $local_cert = $this->_config['certificate'];
$passphrase = $this->_config['passphrase']; $passphrase = $this->_config['passphrase'];
$alert = []; $metadata = $message->getMetadata();
$alert['title'] = $message->getSubject();
$alert['body'] = $message->getContent();
$body['aps'] = array('alert' => $alert); $payload = json_encode([
$payload = json_encode($body); 'aps' => [
'alert' => [
'title' => $message->getSubject(),
'body' => $message->getContent(),
],
'sound' => isset($metadata['sound']) ? $metadata['sound'] : 'default',
],
]);
foreach($tokens as $token) foreach($tokens as $token)
{ {

View file

@ -62,6 +62,7 @@ class FCM extends Base implements \Rhymix\Framework\Drivers\PushInterface
$notification = $message->getMetadata(); $notification = $message->getMetadata();
$notification['title'] = $message->getSubject(); $notification['title'] = $message->getSubject();
$notification['body'] = $message->getContent(); $notification['body'] = $message->getContent();
$notification['sound'] = isset($notification['sound']) ? $notification['sound'] : 'default';
$chunked_token = array_chunk($tokens, 1000); $chunked_token = array_chunk($tokens, 1000);
foreach($chunked_token as $token_unit) foreach($chunked_token as $token_unit)