OneSignal Help & Documentation

Welcome to the OneSignal New IA developer hub. You'll find comprehensive guides and documentation to help you start working with OneSignal New IA as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    Discussions

Location-Triggered Notifications

Tutorial - Setting up notifications that trigger based on user location.

For Developers
For Marketers

OneSignal supports both sending notifications to devices that have been seen in a specific area, as well as location-triggered (Geofencing) notifications.

We have also partnered with Plot Projects if you want to integrate with their service.

OneSignal automatically tracks a device's country through the IP Address. If you want to convert IP to track by city or designated market area, you can use a 3rd party like MaxMind.

Disable Location Tracking

To disable location tracking in our SDK, you can call the setLocationShared(false) method of our SDK's


Sending notifications based on Location

Mobile Setup

1. Get Location Permissions

To send messages to users by location, make sure you have the location permission set in your app and are prompting for location permissions in your app's code.

Each OneSignal SDK provides a PromptLocation method to help you achieve this.

2. Set up a Segment

Within Segments, create a segment that uses the "Location Radius" filter, and set a distance (in meters) from a set of geo-coordinates (lat,long).

You may skip this step if you pass filters through using the Server REST API.

3. Send to Segment or Filter

Now you can send a message to users in the segment you just created.

You can do this manually via the New Messages Page, automatically via the Server REST API, or automatically via the Automated Messages Page.

Web Setup

Location Tracking on web is only available on HTTPS sites.

1. Determine the user's location

To send messages to users by location, make sure you have the location permission set in your app and are prompting for location permissions in your app's code.

If you need help with this, here is a guide by Mozilla on how to get location permission from a user on your website.

2. Assign location tags

Using the the SendTags method, assign "longitude" and "latitude" tags. For example, you could set "longitude"="37.160" and "latitude"="-117.773".

Here is an example location tracking setup for web.

3. Send to Segment or Filter

Now you can send a message to users in a segment based on these tags.

For example, you could define a segment with tags "longitude" > 37, "longitude" < 38, "latitude" > -118, "latitude" < -117 to create a square target region containing users with location tags in that range.

You can do this manually via the New Messages Page, automatically via the Server REST API, or automatically via the Automated Messages Page.


Sending Notifications automatically based on a Geofence Trigger

iOS

  1. Follow this guide to set up Geofencing on iOS

  2. When a Geofence is triggered, use the OneSignal postNotification method to send a notification to the device.

Android

  1. Follow this guide to set up Geofencing on Android.

  2. When a Geofence is triggered, use the OneSignal postNotification method to send a notification to the device.


Location-Triggered Notifications


Tutorial - Setting up notifications that trigger based on user location.

For Developers
For Marketers

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.