mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-03 16:51:40 +09:00
FCM 요청 스키마 수정 및 배열 선언 가독성 개선
This commit is contained in:
parent
df76fa45c5
commit
f9521d4d93
2 changed files with 15 additions and 6 deletions
|
|
@ -53,7 +53,10 @@ class FCM extends Base implements \Rhymix\Framework\Drivers\PushInterface
|
|||
|
||||
$url = 'https://fcm.googleapis.com/fcm/send';
|
||||
$api_key = $this->_config['api_key'];
|
||||
$headers = array('Authorization:key='.$api_key,'Content-Type: application/json');
|
||||
$headers = array(
|
||||
'Authorization' => 'key=' . $api_key,
|
||||
'Content-Type' => 'application/json',
|
||||
);
|
||||
|
||||
// Set notification
|
||||
$notification = [];
|
||||
|
|
@ -67,11 +70,17 @@ class FCM extends Base implements \Rhymix\Framework\Drivers\PushInterface
|
|||
// Set android options
|
||||
$options = [];
|
||||
$options['priority'] = 'normal';
|
||||
$options['notification']['click_action'] = 'RX_NOTIFICATION';
|
||||
$options['click_action'] = 'RX_NOTIFICATION';
|
||||
|
||||
foreach($tokens as $i => $token)
|
||||
{
|
||||
$data = array('registration_ids' => $token, 'notification' => $notification, 'android' => $options, 'data' => $message->getData());
|
||||
$data = json_encode(array(
|
||||
'registration_ids' => [$token],
|
||||
'notification' => $notification,
|
||||
'android' => $options ?: new stdClass,
|
||||
'data' => $message->getData() ?: new stdClass,
|
||||
));
|
||||
|
||||
$result = \FileHandler::getRemoteResource($url, $data, 5, 'POST', 'application/json', $headers);
|
||||
if($result)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -125,9 +125,9 @@ class Push
|
|||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getFrom(): ?int
|
||||
public function getFrom(): int
|
||||
{
|
||||
return $this->from;
|
||||
return intval($this->from);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -339,7 +339,7 @@ class Push
|
|||
|
||||
foreach($output->data as $row)
|
||||
{
|
||||
$result[$row->device_type] = $row->device_token;
|
||||
$result[$row->device_type][] = $row->device_token;
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue