mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-05 17:51:40 +09:00
FCM push 테스트OK (APNs는 옵션 추가해야함)
This commit is contained in:
parent
10a01103b4
commit
df76fa45c5
2 changed files with 35 additions and 23 deletions
|
|
@ -286,15 +286,21 @@ class Push
|
|||
|
||||
try
|
||||
{
|
||||
$tokens = $this->getDeviceToken();
|
||||
$tokens = $this->getDeviceTokens();
|
||||
// Android FCM
|
||||
if(count($tokens['android']))
|
||||
{
|
||||
$fcm_driver = $this->getDriver('fcm');
|
||||
$this->sent = $fcm_driver->send($this, $tokens['android']);
|
||||
}
|
||||
|
||||
// iOS APNs
|
||||
if(count($tokens['ios']))
|
||||
{
|
||||
$apns_driver =$this->getDriver('apns');
|
||||
$this->sent = $apns_driver->send($this, $tokens['ios']);
|
||||
}
|
||||
}
|
||||
catch(\Exception $e)
|
||||
{
|
||||
$this->errors[] = class_basename($e) . ': ' . $e->getMessage();
|
||||
|
|
@ -316,33 +322,27 @@ class Push
|
|||
* @return array
|
||||
*
|
||||
*/
|
||||
protected function getDeviceToken(): array
|
||||
protected function getDeviceTokens(): array
|
||||
{
|
||||
$member_srl_list = $this->getRecipients();
|
||||
$result = [];
|
||||
$result['android'] = [];
|
||||
$result['ios'] = [];
|
||||
|
||||
$args = new stdClass;
|
||||
$args->member_srl = $member_srl_list;
|
||||
$output = executeQueryArray('member.getMemberDeviceByMemberSrl', $args);
|
||||
if(!$output->toBool())
|
||||
$output = executeQueryArray('member.getMemberDeviceTokensByMemberSrl', $args);
|
||||
if(!$output->toBool() || !$output->data)
|
||||
{
|
||||
return [];
|
||||
return $result;
|
||||
}
|
||||
|
||||
$device_tokens = [];
|
||||
$device_tokens['android'] = array_map(function($device){
|
||||
if('android' === $device->device_type)
|
||||
foreach($output->data as $row)
|
||||
{
|
||||
return $device->device_token;
|
||||
$result[$row->device_type] = $row->device_token;
|
||||
}
|
||||
}, $output->data);
|
||||
$device_tokens['ios'] = array_map(function($device){
|
||||
if('ios' === $device->device_type)
|
||||
{
|
||||
return $device->device_token;
|
||||
}
|
||||
}, $output->data);
|
||||
|
||||
return $device_tokens;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
12
modules/member/queries/getMemberDeviceTokensByMemberSrl.xml
Normal file
12
modules/member/queries/getMemberDeviceTokensByMemberSrl.xml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<query id="getMemberDeviceTokensByMemberSrl" action="select">
|
||||
<tables>
|
||||
<table name="member_devices" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="device_token" />
|
||||
<column name="device_type" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="in" column="member_srl" var="member_srl" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
Loading…
Add table
Add a link
Reference in a new issue