File tree Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ You must publish the configuration file with:
20
20
php artisan vendor:publish --provider=" YieldStudio\LaravelExpoNotifier\ExpoNotificationsServiceProvider" --tag=" expo-notifications-config" --tag=" expo-notifications-migration"
21
21
```
22
22
23
+ ### Available environment variables
24
+ - ` EXPO_PUSH_NOTIFICATIONS_PER_REQUEST_LIMIT ` : sets the max notifications sent on a bulk request. [ The official documentation says the limit should be 100] ( https://docs.expo.dev/push-notifications/sending-notifications/#request-errors ) but in fact it's failing. You can tweak it by setting a value under 100.
25
+
23
26
## Usage
24
27
25
28
### Send notification
Original file line number Diff line number Diff line change 25
25
'service ' => [
26
26
'api_url ' => 'https://exp.host/--/api/v2/push ' ,
27
27
'host ' => 'exp.host ' ,
28
+ 'limits ' => [
29
+ // https://docs.expo.dev/push-notifications/sending-notifications/#request-errors
30
+ 'push_notifications_per_request ' => (int ) env ('EXPO_PUSH_NOTIFICATIONS_PER_REQUEST_LIMIT ' , 99 ),
31
+ ],
28
32
],
29
33
];
Original file line number Diff line number Diff line change 21
21
22
22
final class ExpoNotificationsService implements ExpoNotificationsServiceInterface
23
23
{
24
- public const PUSH_NOTIFICATIONS_PER_REQUEST_LIMIT = 100 ;
25
-
26
24
public const SEND_NOTIFICATION_ENDPOINT = '/send ' ;
27
25
28
26
private PendingRequest $ http ;
@@ -35,12 +33,16 @@ final class ExpoNotificationsService implements ExpoNotificationsServiceInterfac
35
33
36
34
private Collection $ tickets ;
37
35
36
+ private int $ pushNotificationsPerRequestLimit ;
37
+
38
38
public function __construct (
39
39
string $ apiUrl ,
40
40
string $ host ,
41
41
protected readonly ExpoPendingNotificationStorageInterface $ notificationStorage ,
42
42
protected readonly ExpoTicketStorageInterface $ ticketStorage
43
43
) {
44
+ $ this ->pushNotificationsPerRequestLimit = config ('expo-notifications.service.limits.push_notifications_per_request ' );
45
+
44
46
$ this ->http = Http::withHeaders ([
45
47
'host ' => $ host ,
46
48
'accept ' => 'application/json ' ,
@@ -148,7 +150,7 @@ private function prepareNotificationsToSendNow(): ExpoNotificationsService
148
150
->values ();
149
151
150
152
// Splits into multiples chunks of max limitation
151
- $ this ->notificationChunks = $ this ->notificationsToSend ->chunk (self :: PUSH_NOTIFICATIONS_PER_REQUEST_LIMIT );
153
+ $ this ->notificationChunks = $ this ->notificationsToSend ->chunk ($ this -> pushNotificationsPerRequestLimit );
152
154
153
155
return $ this ;
154
156
}
You can’t perform that action at this time.
0 commit comments