mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-05 09:41:40 +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;
|
||||
|
|
|
|||
|
|
@ -200,6 +200,8 @@ class member extends ModuleObject {
|
|||
if(!$oDB->isIndexExists('member_nickname_log', 'idx_after_nick_name')) return true;
|
||||
if(!$oDB->isIndexExists('member_nickname_log', 'idx_user_id')) return true;
|
||||
|
||||
if(!$oDB->isColumnExists('member_devices', 'device_token_type')) return true;
|
||||
|
||||
$config = ModuleModel::getModuleConfig('member');
|
||||
|
||||
// Check members with phone country in old format
|
||||
|
|
@ -372,6 +374,15 @@ class member extends ModuleObject {
|
|||
$oDB->addIndex('member_nickname_log', 'idx_user_id', array('user_id'));
|
||||
}
|
||||
|
||||
// Add device token type 2020.10.28
|
||||
if(!$oDB->isColumnExists('member_devices', 'device_token_type'))
|
||||
{
|
||||
$oDB->addColumn('member_devices', 'device_token_type', 'varchar', '20', '', true, 'device_token');
|
||||
$oDB->addIndex('member_devices', 'idx_device_token_type', array('device_token_type'));
|
||||
$oDB->query("UPDATE member_devices SET device_token_type = 'fcm' WHERE device_type = 'android' OR LENGTH(device_token) > 64");
|
||||
$oDB->query("UPDATE member_devices SET device_token_type = 'apns' WHERE device_type = 'ios' AND LENGTH(device_token) = 64");
|
||||
}
|
||||
|
||||
$config = ModuleModel::getModuleConfig('member');
|
||||
$changed = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ class memberController extends member
|
|||
$args = new stdClass();
|
||||
$args->member_srl = $member_info->member_srl;
|
||||
executeQuery('member.deleteAuthMail', $args);
|
||||
|
||||
|
||||
if(!$config->after_login_url)
|
||||
{
|
||||
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', '');
|
||||
|
|
@ -99,6 +99,7 @@ class memberController extends member
|
|||
if(!$password && !$allow_guest_device) return new BaseObject(-1, 'NULL_PASSWORD');
|
||||
if(!$device_token) return new BaseObject(-1, 'NULL_DEVICE_TOKEN');
|
||||
|
||||
// Get device information
|
||||
$browserInfo = Rhymix\Framework\UA::getBrowserInfo();
|
||||
$device_type = strtolower($browserInfo->os);
|
||||
$device_version = $browserInfo->os_version;
|
||||
|
|
@ -107,23 +108,18 @@ class memberController extends member
|
|||
$device_model = escape($browserInfo->device);
|
||||
}
|
||||
|
||||
if('ios' === $device_type)
|
||||
// Detect device token type
|
||||
if (preg_match('/^[0-9a-z]{64}$/', $device_token))
|
||||
{
|
||||
if(!preg_match("/^[0-9a-z]{64}$/", $device_token))
|
||||
{
|
||||
return new BaseObject(-1, 'INVALID_DEVICE_TOKEN');
|
||||
}
|
||||
$device_token_type = 'apns';
|
||||
}
|
||||
elseif('android' === $device_type)
|
||||
elseif (preg_match('/^[0-9a-zA-Z:_-]+$/', $device_token) && strlen($device_token) > 64)
|
||||
{
|
||||
if(!preg_match("/^[0-9a-zA-Z:_-]+$/", $device_token))
|
||||
{
|
||||
return new BaseObject(-1, 'INVALID_DEVICE_TOKEN');
|
||||
}
|
||||
$device_token_type = 'fcm';
|
||||
}
|
||||
else
|
||||
{
|
||||
return new BaseObject(-1, 'NOT_SUPPORTED_OS');
|
||||
return new BaseObject(-1, 'INVALID_DEVICE_TOKEN');
|
||||
}
|
||||
|
||||
if($user_id && $password)
|
||||
|
|
@ -151,6 +147,7 @@ class memberController extends member
|
|||
$args->device_srl = getNextSequence();
|
||||
$args->member_srl = $member_srl;
|
||||
$args->device_token = $device_token;
|
||||
$args->device_token_type = $device_token_type;
|
||||
$args->device_key = $device_key;
|
||||
$args->device_type = $device_type;
|
||||
$args->device_version = $device_version;
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@
|
|||
</tables>
|
||||
<columns>
|
||||
<column name="device_token" />
|
||||
<column name="device_type" />
|
||||
<column name="device_token_type" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="in" column="member_srl" var="member_srl" notnull="notnull" />
|
||||
<condition operation="in" column="device_type" var="device_type" pipe="and" />
|
||||
<condition operation="in" column="device_token_type" var="device_token_type" pipe="and" />
|
||||
</conditions>
|
||||
</query>
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
<column name="device_srl" var="device_srl" notnull="notnull" />
|
||||
<column name="member_srl" var="member_srl" notnull="notnull" />
|
||||
<column name="device_token" var="device_token" notnull="notnull" />
|
||||
<column name="device_token_type" var="device_token_type" notnull="notnull" />
|
||||
<column name="device_key" var="device_key" notnull="notnull" />
|
||||
<column name="device_type" var="device_type" notnull="notnull" />
|
||||
<column name="device_version" var="device_version" notnull="notnull" />
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
<column name="device_srl" type="number" notnull="notnull" primary_key="primary_key" />
|
||||
<column name="member_srl" type="number" notnull="notnull" index="idx_member_srl" />
|
||||
<column name="device_token" type="varchar" size="191" notnull="notnull" unique="unique_device_token" />
|
||||
<column name="device_token_type" type="varchar" size="20" notnull="notnull" index="idx_device_token_type" />
|
||||
<column name="device_key" type="char" size="64" notnull="notnull" />
|
||||
<column name="device_type" type="varchar" size="20" notnull="notnull" index="idx_device_type" />
|
||||
<column name="device_version" type="varchar" size="20" notnull="notnull" />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue