Allow sending message to topics using FCM v1 API

This commit is contained in:
Kijin Sung 2024-04-23 23:58:15 +09:00
parent ac16d2e7f5
commit c7f96ad75b
2 changed files with 64 additions and 8 deletions

View file

@ -145,7 +145,7 @@ class Push
}
/**
* Get the list of recipients without country codes.
* Get the list of recipients.
*
* @return array
*/
@ -154,6 +154,28 @@ class Push
return $this->to;
}
/**
* Add a topic.
*
* @param string $topic
* @return bool
*/
public function addTopic(string $topic): bool
{
$this->topics[] = $topic;
return true;
}
/**
* Get the list of topics.
*
* @return array
*/
public function getTopics(): array
{
return $this->topics;
}
/**
* Set the subject.
*
@ -376,7 +398,7 @@ class Push
$output = null;
// FCM HTTP v1 or Legacy API
if(count($tokens->fcm))
if(count($tokens->fcm) || count($this->topics))
{
$fcm_driver_name = array_key_exists('fcmv1', config('push.types') ?: []) ? 'fcmv1' : 'fcm';
$fcm_driver = $this->getDriver($fcm_driver_name);
@ -442,7 +464,7 @@ class Push
{
$args->device_token_type[] = 'apns';
}
if(!count($args->device_token_type))
if(!count($args->device_token_type) || !count($args->member_srl))
{
return $result;
}