OneSignalNotification - viames/pair GitHub Wiki
Pair framework: OneSignalNotification
Pair\Services\OneSignalNotification sends push notifications through OneSignal APIs.
When to use
Use this service for targeted or segmented push delivery from Pair backend processes.
Main methods
send(array $userUuids, string|array $title, string|array $message, array $data = [], array $options = []): ?stdClasssendToUser(User $user, ...): ?stdClasssendToUsers(Collection|array $users, ...): ?stdClasssendToSegment(string $segment, ...): ?stdClasscancel(string $notificationId): bool
Implementation examples
Send to a user UUID list
$result = \Pair\Services\OneSignalNotification::send(
['u_42', 'u_73'],
['en' => 'Shipment update'],
['en' => 'Your order is on the way'],
['orderId' => 2241],
['url' => '/orders/2241']
);
Send to a segment
\Pair\Services\OneSignalNotification::sendToSegment(
'Active Users',
'Promo',
'Weekend offer is now live',
['campaign' => 'wknd-2026']
);
Common pitfalls
- Missing
ONE_SIGNAL_APP_IDorONE_SIGNAL_REST_API_KEYcauses silent operational failures. - Avoid oversized payloads in
data.
See also: PushDispatcher, Notification, PWA.