Skip to content

OneSignalNotification

Viames Marino edited this page Feb 23, 2026 · 1 revision

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 = []): ?stdClass
  • sendToUser(User $user, ...): ?stdClass
  • sendToUsers(Collection|array $users, ...): ?stdClass
  • sendToSegment(string $segment, ...): ?stdClass
  • cancel(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_ID or ONE_SIGNAL_REST_API_KEY causes silent operational failures.
  • Avoid oversized payloads in data.

See also: PushDispatcher, Notification, PWA.

Clone this wiki locally