mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-09 12:02:24 +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,14 +286,20 @@ class Push
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$tokens = $this->getDeviceToken();
|
$tokens = $this->getDeviceTokens();
|
||||||
// Android FCM
|
// Android FCM
|
||||||
$fcm_driver = $this->getDriver('fcm');
|
if(count($tokens['android']))
|
||||||
$this->sent = $fcm_driver->send($this, $tokens['android']);
|
{
|
||||||
|
$fcm_driver = $this->getDriver('fcm');
|
||||||
|
$this->sent = $fcm_driver->send($this, $tokens['android']);
|
||||||
|
}
|
||||||
|
|
||||||
// iOS APNs
|
// iOS APNs
|
||||||
$apns_driver =$this->getDriver('apns');
|
if(count($tokens['ios']))
|
||||||
$this->sent = $apns_driver->send($this, $tokens['ios']);
|
{
|
||||||
|
$apns_driver =$this->getDriver('apns');
|
||||||
|
$this->sent = $apns_driver->send($this, $tokens['ios']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch(\Exception $e)
|
catch(\Exception $e)
|
||||||
{
|
{
|
||||||
|
|
@ -316,33 +322,27 @@ class Push
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected function getDeviceToken(): array
|
protected function getDeviceTokens(): array
|
||||||
{
|
{
|
||||||
$member_srl_list = $this->getRecipients();
|
$member_srl_list = $this->getRecipients();
|
||||||
|
$result = [];
|
||||||
|
$result['android'] = [];
|
||||||
|
$result['ios'] = [];
|
||||||
|
|
||||||
$args = new stdClass;
|
$args = new stdClass;
|
||||||
$args->member_srl = $member_srl_list;
|
$args->member_srl = $member_srl_list;
|
||||||
$output = executeQueryArray('member.getMemberDeviceByMemberSrl', $args);
|
$output = executeQueryArray('member.getMemberDeviceTokensByMemberSrl', $args);
|
||||||
if(!$output->toBool())
|
if(!$output->toBool() || !$output->data)
|
||||||
{
|
{
|
||||||
return [];
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
$device_tokens = [];
|
foreach($output->data as $row)
|
||||||
$device_tokens['android'] = array_map(function($device){
|
{
|
||||||
if('android' === $device->device_type)
|
$result[$row->device_type] = $row->device_token;
|
||||||
{
|
}
|
||||||
return $device->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