mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-09 03:32:00 +09:00
Separate device type (android/ios) from token type (fcm/apns)
애플 기기에서도 FCM을 사용하여 푸시알림을 구현할 수 있으므로 디바이스의 운영체제와 무관하게 토큰 타입을 지정하도록 변경합니다. 기존에 등록된 토큰은 운영체제 및 포맷에 따라 자동 변환합니다.
This commit is contained in:
parent
61f6456b6c
commit
ed7add6d9c
6 changed files with 39 additions and 30 deletions
|
|
@ -290,10 +290,10 @@ class Push
|
|||
$output = null;
|
||||
|
||||
// Android FCM
|
||||
if(count($tokens->android))
|
||||
if(count($tokens->fcm))
|
||||
{
|
||||
$fcm_driver = $this->getDriver('fcm');
|
||||
$output = $fcm_driver->send($this, $tokens->android);
|
||||
$output = $fcm_driver->send($this, $tokens->fcm);
|
||||
$this->sent = count($output->success) ? true : false;
|
||||
$this->success_tokens = $output ? $output->success : [];
|
||||
$this->deleted_tokens = $output ? $output->invalid : [];
|
||||
|
|
@ -303,10 +303,10 @@ class Push
|
|||
}
|
||||
|
||||
// iOS APNs
|
||||
if(count($tokens->ios))
|
||||
if(count($tokens->apns))
|
||||
{
|
||||
$apns_driver =$this->getDriver('apns');
|
||||
$output = $apns_driver->send($this, $tokens->ios);
|
||||
$output = $apns_driver->send($this, $tokens->apns);
|
||||
$this->sent = count($output->success) ? true : false;
|
||||
$this->success_tokens += $output ? $output->success : [];
|
||||
$this->deleted_tokens += $output ? $output->invalid : [];
|
||||
|
|
@ -339,26 +339,25 @@ class Push
|
|||
*/
|
||||
protected function _getDeviceTokens()
|
||||
{
|
||||
$member_srl_list = $this->getRecipients();
|
||||
$result = new \stdClass;
|
||||
$result->android = [];
|
||||
$result->ios = [];
|
||||
$result->fcm = [];
|
||||
$result->apns = [];
|
||||
|
||||
$args = new \stdClass;
|
||||
$args->member_srl = $member_srl_list;
|
||||
$args->device_type = [];
|
||||
$args->member_srl = $this->getRecipients();
|
||||
$args->device_token_type = [];
|
||||
$driver_types = config('push.types') ?: array();
|
||||
if(!count($driver_types))
|
||||
{
|
||||
return $result;
|
||||
}
|
||||
if(isset($driver_types['fcm']))
|
||||
{
|
||||
$args->device_type[] = 'android';
|
||||
$args->device_token_type[] = 'fcm';
|
||||
}
|
||||
if(isset($driver_types['apns']))
|
||||
{
|
||||
$args->device_type[] = 'ios';
|
||||
$args->device_token_type[] = 'apns';
|
||||
}
|
||||
if(!count($args->device_token_type))
|
||||
{
|
||||
return $result;
|
||||
}
|
||||
|
||||
$output = executeQueryArray('member.getMemberDeviceTokensByMemberSrl', $args);
|
||||
|
|
@ -369,7 +368,7 @@ class Push
|
|||
|
||||
foreach($output->data as $row)
|
||||
{
|
||||
$result->{$row->device_type}[] = $row->device_token;
|
||||
$result->{$row->device_token_type}[] = $row->device_token;
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue