Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 36 additions & 37 deletions integrations/onesignal.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ 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.
Whenever events are generated, Radar will call the [edit user API](https://documentation.onesignal.com/reference/update-user) 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:
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 user ID to Radar by setting `metadata.oneSignalPlayerId`. For example, on iOS:

<CodeGroup>

```swift Swift
let playerId = OneSignal.getPermissionSubscriptionState().subscriptionStatus.userId
Radar.setMetadata(["oneSignalPlayerId": playerId])
let oneSignalUserId = OneSignal.getPermissionSubscriptionState().subscriptionStatus.userId
Radar.setMetadata(["oneSignalUserId": oneSignalUserId])
```


Expand All @@ -51,47 +51,46 @@ Because OneSignal does not support associating custom events with a user, the mo
| `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.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.stopped_trip` | [Trips](/geofencing/trips) | `stopped_trip` |
Comment on lines -54 to +57

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

linter? wasnt me

| `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 |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

linter, didnt do anything here

| ------------------------------------ | --------------------------------------------- | ------------------------ | ---------------------------- | ------------------------------- |
| `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) |
| 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) |

| `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) |