Location-triggered notifications

Setting up notifications that trigger based on user location.

Support for location-triggered notifications can be achieved in the following ways.

Target by country

Country is automatically tracked based on the IP Address. Use the country Data Filter in Segments or API filters.


Target by latitude and longitude

If your Mobile App collects location data, OneSignal will automatically update the latitude and longitude for the device based on the location permission granted by user.

  1. Setup the required permissions.
    1. For iOS location settings, see the Apple Developer Guide for Choosing the Location Authorization Level.
    2. For Android location settings, see the Android Developer Guide on Location Permissions.
  2. Allow us to pull location points.
    1. Within our SDK, we provide a setShared method. Set this to true.
  3. Ask for permission.
    1. You can use your own method to ask for location or use the following options we provide:
      1. In-app message: Example: Location Permissions
      2. SDK requestPermission() method .

Once location is set, messages can be sent based on a radius around the location point using the location Data Filter in Segments or API Filters.

Web push latitude and longitude tracking

OneSignal does not automatically collect location points on web push. You can setup your site to prompt users for Location Tracking and add Data Tags to set it within OneSignal. Here is a great Medium Post about this.

If getting and setting the location points with OneSignal sendTags method, assign "longitude" and "latitude" tags. For example, you could set "long"="37.160" and "lat"="-117.773".

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

For example, define a segment with tags "long" > 37, "long" < 38, "lat" > -118, "lat" < -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.


Target By city or provided location

OneSignal does not provide a way to track city or area codes. This data is usually collected in the following ways:

  • User inputs a city or location into a field on your site/app.
  • Prompt User for Location Tracking on Web and use Google Maps Reverse Geocoding API. Here is a great Medium Post about this.

You can send this data to OneSignal as Data Tags.

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


Target based on a Geofence Trigger

We have also partnered with Radar if you want to integrate with their services.

Radar is the leading geofencing and location tracking platform. You can use Radar's SDKs and APIs to build a wide range of location-based product and service experiences, including pickup and delivery tracking, location-triggered notifications, location verification, store locators, address autocomplete, and more. For more information about our integration, visit the Radar Docs or contact the Radar team to learn more.


FAQ

If my app tracks location, how often does OneSignal update this?

Currently OneSignal updates location points around every 5 minute based on the device's location permissions.