> ## Documentation Index
> Fetch the complete documentation index at: https://v0.x-docs.novu.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Onesignal

> Learn how to use the Onesignal provider to send push notifications using Novu

[OneSignal](https://onesignal.com/) is a paid push notification service that supports sending messages via both [Apple Push Notification Service](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server) (APNs) as well as [Firebase Cloud Messaging](https://firebase.google.com/docs/cloud-messaging) (FCM).

To configure the OneSignal integration, you will need an active account which has credentials for APNs, FCM or both, and have access to the `OneSignal App ID` and `Rest API Key` available via your [application's settings page](https://documentation.onesignal.com/docs/keys-and-ids).

# Setting the Device Token

Once OneSignal has been configured with your credentials for APNs/FCM, and the OneSignal SDK has been [set up and configured](https://documentation.onesignal.com/docs/onboarding-with-onesignal#step-1-setup-onesignal-sdk) for your application, your users will begin to be automatically assigned a unique OneSignal [player\_id](https://documentation.onesignal.com/docs/users#player-id) identifier by the SDK.

This identifier allows targeting your user when sending push notifications without having to retrieve the specific Android or iOS device tokens - which are managed by OneSignal.

In order to target the OneSignal user from Novu, you must register the OneSignal `player_id`as the `deviceToken` for your Novu subscriber. This value can be retrieved via the [OneSignal SDK](https://documentation.onesignal.com/docs/users-and-devices#finding-users) for your platform.

Once you have the user's `player_id` value, the `deviceToken` for your Novu subscriber can be set via:

<Tabs>
  <Tab title="Node.js">
    ```javaScript theme={null}
    import {
      Novu,
      ChatProviderIdEnum
    } from '@novu/node';

    const novu = new Novu("<NOVU_API_KEY>");

    await novu.subscribers.setCredentials('subscriberId', PushProviderIdEnum.OneSignal, {
      // Your user's unique 'player_id' from OneSignal
      deviceTokens: ['ad0452ca-3ca7-43b5-bf9b-fa93fd322035'],
    });
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl -L -X PUT 'https://api.novu.co/v1/subscribers/<SUBSCRIBER_ID>/credentials' \
    -H 'Content-Type: application/json' \
    -H 'Accept: application/json' \
    -H 'Authorization: ApiKey <NOVU_API_KEY>' \
    -d '{
      "providerId": "one-signal",
      "deviceTokens": ["ad0452ca-3ca7-43b5-bf9b-fa93fd322035"],
      "integrationIdentifier": "one-signal-MnGLxp8uy"
    }'
    ```
  </Tab>
</Tabs>

Checkout the [API reference](/api-reference/subscribers/update-subscriber-credentials) for more details.

# SDK Trigger Example

```jsx theme={null}
import { Novu } from '@novu/node';

const novu = new Novu("<NOVU_API_KEY>");

novu.trigger('<WORKFLOW_TRIGGER_IDENTIFIER>', {
  to: {
    subscriberId: '<SUBSCRIBER_ID>',
  },
  payload: {
    abc: 'def', // If the notification is a data notification, the payload will be sent as the data
  },
});
```

Device/notification identifiers can be set by using [setCredentials](https://docs.novu.co/channels/email/resend/#set-device-token) or by using the `deviceIdentifiers` field in overrides.
