diff --git a/config/expo-notifications.php b/config/expo-notifications.php index 4993152..4ce5570 100644 --- a/config/expo-notifications.php +++ b/config/expo-notifications.php @@ -29,5 +29,7 @@ // https://docs.expo.dev/push-notifications/sending-notifications/#request-errors 'push_notifications_per_request' => (int) env('EXPO_PUSH_NOTIFICATIONS_PER_REQUEST_LIMIT', 99), ], + // https://expo.dev/blog/expo-adds-support-for-fcm-http-v1-api + 'use_fcm_legacy_api' => (bool) env('EXPO_USE_FCM_LEGACY_API', false), ], ]; diff --git a/src/ExpoNotificationsService.php b/src/ExpoNotificationsService.php index 1208b2e..768b1a2 100644 --- a/src/ExpoNotificationsService.php +++ b/src/ExpoNotificationsService.php @@ -23,6 +23,8 @@ final class ExpoNotificationsService implements ExpoNotificationsServiceInterfac { public const SEND_NOTIFICATION_ENDPOINT = '/send'; + public const USE_FCM_LEGACY_API_QUERY_PARAM = 'useFcmV1'; + private PendingRequest $http; private ?Collection $expoMessages; @@ -50,6 +52,13 @@ public function __construct( 'content-type' => 'application/json', ])->baseUrl($apiUrl); + // https://expo.dev/blog/expo-adds-support-for-fcm-http-v1-api + if (config('expo-notifications.service.use_fcm_legacy_api')) { + $this->http->withQueryParameters([ + self::USE_FCM_LEGACY_API_QUERY_PARAM => true, + ]); + } + $this->tickets = collect(); }