> ## Documentation Index
> Fetch the complete documentation index at: https://radarlabs-joeross-add-chain-to-chain-list.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# OneSignal

<Info>
  The OneSignal integration is available on the [**Enterprise plan**](https://radar.com/pricing).
</Info>

Radar can send tags to and trigger notifications in [OneSignal](https://onesignal.com). You can create notifications triggered by tag changes.

Use the OneSignal integration to send location-triggered and location-targeted messages to increase engagement and conversion.

## Configuration

On the OneSignal *Settings* page under *Keys & IDs*, copy your REST API key.

Then, on the Radar [Integrations page](https://dashboard.radar.com/integrations) under *OneSignal*, set *Enabled* to *Yes* and paste your API key. Note that you can set separate API keys for the *Test* and *Live* environments.

Whenever events are generated, Radar will call the [edit device API](https://documentation.onesignal.com/reference/edit-device) and set tags in OneSignal. You can create notifications triggered by tag changes.

By default, Radar `userId` and `deviceId` do not map to OneSignal. To map users in Radar to devices in OneSignal, you must send the OneSignal player ID to Radar by setting `metadata.oneSignalPlayerId`. For example, on iOS:

<CodeGroup>
  ```swift Swift theme={null}
  let playerId = OneSignal.getPermissionSubscriptionState().subscriptionStatus.userId
  Radar.setMetadata(["oneSignalPlayerId": playerId])
  ```

  ```kotlin Kotlin theme={null}
  let playerId = OneSignal.getPermissionSubscriptionState().subscriptionStatus.userId
  Radar.setMetadata(["oneSignalPlayerId": playerId])
  ```
</CodeGroup>

Because OneSignal does not support associating custom events with a user, the most recent event types triggered from a location update are sent as a comma-separated list under the Onesignal tag `radar_events`. For example, if a user has exited a geofence and entered a place, the value for the `radar_events` tag would be `exited_geofence,entered_place`.

| Radar Event | Context Type | Onesignal Tag Value |
| - | - | - |
| `user.entered_geofence` | [Geofences](/geofencing/geofences) | `entered_geofence` |
| `user.exited_geofence` | [Geofences](/geofencing/geofences) | `exited_geofence` |
| `user.dwelled_in_geofence` | [Geofences](/geofencing/geofences) | `dwelled_in_geofence` |
| `user.entered_place` | [Places](/geofencing/places) | `place_entered` |
| `user.exited_place` | [Places](/geofencing/places) | `place_exited` |
| `user.entered_region_country` | [Regions](/geofencing/regions) | `entered_region_country` |
| `user.exited_region_country` | [Regions](/geofencing/regions) | `exited_region_country` |
| `user.entered_region_state` | [Regions](/geofencing/regions) | `entered_region_state` |
| `user.exited_region_state` | [Regions](/geofencing/regions) | `exited_region_state` |
| `user.entered_region_dma` | [Regions](/geofencing/regions) | `entered_region_dma` |
| `user.exited_region_dma` | [Regions](/geofencing/regions) | `exited_region_dma` |
| `user.started_trip` | [Trips](/geofencing/trips) | `started_trip` |
| `user.updated_trip` | [Trips](/geofencing/trips) | `updated_trip` |
| `user.approaching_trip_destination` | [Trips](/geofencing/trips) | `approaching_trip_destination` |
| `user.arrived_at_trip_destination` | [Trips](/geofencing/trips) | `arrived_at_trip_destination` |
| `user.stopped_trip` | [Trips](/geofencing/trips) | `stopped_trip` |
| `user.entered_beacon` | [Beacons](/geofencing/beacons) | `entered_beacon` |
| `user.exited_beacon` | [Beacons](/geofencing/beacons) | `exited_beacon` |

## User mapping

| Radar User Field | OneSignal Tag Name | Type | Example Tag | Context Type |
| - | - | - | - | - |
| `location.coordinates[1]` | `lat` | number | `39.525665` | |
| `location.coordinates[0]` | `long` | number | `-76.350663` | |
| `locationAuthorization` | `radar_location_authorization` | string | `"GRANTED_FOREGROUND"` | |
| `locationAccuracyAuthorization` | `radar_location_accuracy_authorization` | string | `"FULL"` | |
| `segments[*].externalId` | `radar_segment_external_ids` | string (comma-separated) | `"starbucks-visitors"` | |
| `topChains[*].slug` | `radar_top_chain_slugs` | string (comma-separated) | `"starbucks"` | |
| `topChains[*].externalId` | `radar_top_chain_external_ids` | string (comma-separated) | `"123"` | |
| `geofences[*]._id` | `radar_geofence_ids` | string (comma-separated) | `"5b2c0906f5874b001aecfd8e"` | [Geofences](/geofencing/geofences) |
| `geofences[*].description` | `radar_geofence_descriptions` | string (comma-separated) | `"Store #123"` | [Geofences](/geofencing/geofences) |
| `geofences[*].tag` | `radar_geofence_tags` | string (comma-separated) | `"store"` | [Geofences](/geofencing/geofences) |
| `geofences[*].externalId` | `radar_geofence_external_ids` | string (comma-separated) | `"123"` | [Geofences](/geofencing/geofences) |
| `place._id` | `radar_place_id` | string | `"59302bcf8f27e8a156bd4f91"` | [Places](/geofencing/places) |
| `place.name` | `radar_place_name` | string | `"Starbucks"` | [Places](/geofencing/places) |
| `place.categories` | `radar_place_categories` | string | `"coffee-shop"` | [Places](/geofencing/places) |
| `place.chain.slug` | `radar_place_chain_slug` | string | `"starbucks"` | [Places](/geofencing/places) |
| `place.chain.name` | `radar_place_chain_name` | string | `"Starbucks"` | [Places](/geofencing/places) |
| `country.code` | `radar_region_country_code` | string | `"US"` | [Regions](/geofencing/regions) |
| `country.name` | `radar_region_country_name` | string | `"United States"` | [Regions](/geofencing/regions) |
| `state.code` | `radar_region_state_code` | string | `"MD"` | [Regions](/geofencing/regions) |
| `state.name` | `radar_region_state_name` | string | `"Maryland"` | [Regions](/geofencing/regions) |
| `dma.code` | `radar_region_dma_code` | string | `"26"` | [Regions](/geofencing/regions) |
| `dma.name` | `radar_region_dma_name` | string | `"Baltimore"` | [Regions](/geofencing/regions) |
| `postalCode.code` | `radar_region_postal_code` | string | `"21014"` | [Regions](/geofencing/regions) |
| `trip.externalId` | `radar_trip_external_id` | string | `"123"` | [Trip tracking](/geofencing/trips) |
| `trip.destinationGeofenceTag` | `radar_trip_destination_geofence_tag` | string | `"store"` | [Trip tracking](/geofencing/trips) |
| `trip.destinationGeofenceExternalId` | `radar_trip_destination_geofence_external_id` | string | `"123"` | [Trip tracking](/geofencing/trips) |
| `trip.approached` | `radar_trip_approached` | boolean | `true` | [Trip tracking](/geofencing/trips) |
| `trip.arrived` | `radar_trip_arrived` | boolean | `false` | [Trip tracking](/geofencing/trips) |
| `beacons[*]._id` | `radar_beacon_ids` | string (comma-separated) | `"5b2c0906f5874b001aecfd8f"` | [Beacons](/geofencing/beacons) |
| `beacons[*].description` | `radar_beacon_descriptions` | string (comma-separated) | `"Store #123 - Drive-Thru"` | [Beacons](/geofencing/beacons) |
| `beacons[*].tag` | `radar_beacon_tags` | string (comma-separated) | `"drive-thru"` | [Beacons](/geofencing/beacons) |
| `beacons[*].externalId` | `radar_beacon_external_ids` | string (comma-separated) | `"123"` | [Beacons](/geofencing/beacons) |
