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

Plot Projects

OneSignal integration with Plot Projects for targeting notifications by location. Works with iOS and Android apps.

OneSignal supports creating segments and targeting messages based on locations users visit, via an integration with Plot Projects.

For example, you may wish to send a push notification to users that have visited ‘LAX’ or ‘a Walmart in the last 7 days’:

You can create segments that have many options, including:

  • Trigger on geofences, polygons and/or beacons.
  • Trigger on enter, exit or dwell.
  • Define opening hours per location.
  • Define start and end dates of the campaign.

These segments can be defined in the Plot Projects Geo Data Campaigns dashboard, once you've integrated Plot Projects.

How to set up Location Targeting

Setting up Plot Projects will let you create Geo Data Campaigns in the Plot Projects dashboard that will track visits of your users to any geographic location.

1. Add Plot Projects to your app

First, add Plot Projects to your app by following their integration guide for iOS or Android.

Plot Projects has also created code examples on Github for iOS and Android.

2. Forward Plot Projects geotrigger events to OneSignal

After integrating Plot Projects, you can forward geotrigger events from Plot Projects to OneSignal.

iOS Setup

To receive geotrigger events from Plot Projects on your iOS app, add the plotHandleGeotriggers method to your AppDelegate.m file. In that method you will also call the OneSignal API in order to send the event:

- (void)plotHandleGeotriggers:(PlotHandleGeotriggers*) geotriggerHandler {
        for (PlotGeotrigger* geotrigger in geotriggerHandler.geotriggers) {
            NSString* data = [geotrigger.userInfo objectForKey:PlotGeotriggerDataKey];
            NSString *now = [NSString stringWithFormat:@"%.f",[[NSDate date] timeIntervalSince1970]];
            [OneSignal sendTag:data value:now];
            NSLog(@"Sending tag pair:(%@,%@)",data,now);
        }
        [geotriggerHandler markGeotriggersHandled:geotriggerHandler.geotriggers];
}

The plotHandleGeotriggers method, presented above, sends a tag to OneSignal using the data field set in the dashboard as key and the current timestamp as value.

Android Setup

To receive geotrigger events from Plot Projects on your Android app, create a class that extends GeotriggerHandlerReceiver. In that class you call the OneSignal api in order to send the event.


public class SendTagGeotriggerHandlerReceiver extends GeotriggerHandlerReceiver {

   static final String LOG_TAG = "Send tag Handler";

   @Override
   public List<Geotrigger> handleGeotriggers(List<Geotrigger> geotriggers) {

       for (Geotrigger geotrigger : geotriggers) {
           String data = geotrigger.getData();
           String now = String.valueOf(System.currentTimeMillis()/1000);
           OneSignal.sendTag(data,now);
           Log.d(LOG_TAG, "Sent tag " + "(" + data + ", " + now + ")");
       }
       return geotriggers;
   }
}

The SendTagGeotriggerHandler, presented above, sends a tag to OneSignal using the data field set in the dashboard as key and the current timestamp as value.

To let Android find the service, add it to AndroidManifest.xml

<service android:name=".SendTagHandlerReceiver" android:exported="false" />

If you are having any dependency conflicts read about how to fix them here.

3. Set up a Geo Data Campaign in the Plot Projects dashboard

Next, you can create the locations you want to track within Plot Projects. This can be a single location:

Or a large set of locations:

Once your locations are set up, you can create a Plot Projects Geo Data Campaign defining the Segment the user should be added to after visiting the location.

When creating the campaign, set the field ‘Listening campaign Data’ with the tag key value in json format (eg {"key": "visited_walmart"} or {"key": "visited_LAX"} ):

All Done!

Users will now be added automatically to the corresponding segments in your OneSignal dashboard. You can now send messages to these segments to target users.


Plot Projects


OneSignal integration with Plot Projects for targeting notifications by location. Works with iOS and Android apps.

Suggested Edits are limited on API Reference Pages

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