Skip to content

Commit

Permalink
feat: adds support for legacy FPM API use
Browse files Browse the repository at this point in the history
Fix #28
  • Loading branch information
joemugen committed Mar 26, 2024
1 parent 8513569 commit 1d35e28
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions config/expo-notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
],
];
9 changes: 9 additions & 0 deletions src/ExpoNotificationsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}

Expand Down

0 comments on commit 1d35e28

Please sign in to comment.