Setting up Geofencing for triggering Push Notifications

Samples for geofence-triggered push notification for iOS, Android, and Unity

In this tutorial we are going to show how to setup Leanplum for receiving Push Notifications being triggered by moving through Geofences.

Configuring the push notification message

In order to be triggered when a specific region is crossed, a Push Notification message needs to be setup with the delivery set to 'Locally triggered' when the user enter (or exit) a region.

📘

Locally triggered push notifications do not work with our Quiet Hours feature. This is because the send is controlled by the local trigger, and not Leanplum's servers.

1256

From here, also Regions can be created passing coordinates and radius or just using the map.

661

iOS

A sample app project already configured is available (here)[https://github.com/Leanplum/Leanplum-iOS-Samples/tree/master/iOS_basicSetup/basicSetup].

For configuring an iOS project for Geofencing see Geofencing and location-based messaging.

Android

A sample app project already configured is available here

❗️

Important note:

For Android, in order to have local push notifications be triggered even when the App is killed and not running even in background, Leanplum.start needs to be placed in the Application class.

Regarding AndroidManifest.xml, make also sure that the permissions are present

<!--<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>-->
<!--<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>-->and Google Play Services 

Permission for using Mock Locations can also be placed for testing purposes:

<!--<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/>-->

Unity

For Unity, you have to make sure that what is being described for iOS and Android is being configured in your project as well.

To do that you have to modify the Xcode or Android Studio projects as generated when exporting the projects from Unity.