- google/auth 패키지 추가 (OAuth2 Service Account 인증) - FcmSender: FCM HTTP v1 API 발송 서비스 - FcmResponse: 응답 DTO (성공/실패, 토큰 유효성 체크) - FcmException: FCM 전용 예외 클래스 - fcm:test artisan 명령어 (테스트 발송) - PushNotificationService에 FcmSender 연동 - config/fcm.php 설정 파일 추가 - 알림 유형별 채널 분리 (push_default, push_urgent)
27 lines
630 B
PHP
27 lines
630 B
PHP
<?php
|
|
|
|
namespace App\Services\Fcm;
|
|
|
|
use Exception;
|
|
|
|
class FcmException extends Exception
|
|
{
|
|
public function __construct(
|
|
string $message,
|
|
public readonly int $httpStatusCode = 0,
|
|
public readonly array $response = [],
|
|
?\Throwable $previous = null
|
|
) {
|
|
parent::__construct($message, 0, $previous);
|
|
}
|
|
|
|
/**
|
|
* HTTP 응답에서 예외 생성
|
|
*/
|
|
public static function fromResponse(int $statusCode, array $response): self
|
|
{
|
|
$message = $response['error']['message'] ?? 'Unknown FCM error';
|
|
|
|
return new self($message, $statusCode, $response);
|
|
}
|
|
} |