Setting up Geofencing for triggering Push Notifications - [Sample: iOS, Android, 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.

  • Note: 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.


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




A sample app project already configured is available here

For configuring an iOS project for Geofencing see Location-based messaging


For configuring an Android project for Geofencing see Location-based Messaging.

A sample app project already configured is available here

Beware that for Android, in order to have local Push Notification being triggered also 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"/>-->


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

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

Was this article helpful?
Have more questions? Submit a request