Skip to Main Content

Choosing a React Native Geofencing Library

Choosing a React Native Geofencing Library

Geofences with React Native

Check out A Guide to Geofencing in Mobile Applications if you’d like a refresher on how geofencing works!

There are many options when considering geofencing with React Native. Even with so many choices, each has its advantages and limitations. We’ve compiled a list of geofencing libraries for you that will hopefully meet your needs.

Radar

OS Requirements

Android API 16

iOS 7

Features

* Only offered on Enterprise
** Partially offered free

Radar offers a long list of features - and is definitely the most extensive of the options we’ve compiled. 

Geofences
Radar handles all geofencing and event monitoring server-side rather than on a device. It supports unlimited Circular and Polygonal Geofences with Stop Detection. When Stop Detection is enabled, the library will be able to detect whether the device is moving through a geofence (like driving) or has stopped within the geofence. Entry events will only be triggered if the device stops in the geofence.

Places*
Radar can detect when a user visits a place, chain, or category, without having a geofence registered for it. It uses multiple sources in order to gather and supply place data. When enabled, entry and exit events can be monitored. Radar generates an entry event if a user stops at a place matching filters with sufficient confidence, then an exit event when the user leaves the place.

Insights*
Radar stores and clusters location data for each user. Based on the size, location, and time distribution of clusters, it learns a user's approximate home and office locations. When enabled, entry and exit events for the user’s home and office can be monitored, as well as started traveling and stopped traveling events.

Regions*
Radar can detect a user’s country, state, DMA (designated market area), or postal code. When enabled, entry and exit events for a country, state, and DMA can be monitored.

Integrations**
Radar supports setting up webhooks and server-side integrations that allow you to send events from Radar to other systems. Webhooks are a free integration that can be used on any license, whereas other integrations require an Enterprise license.

Advantages
The feature-full dependency will exceed your needs for geofencing and geolocation monitoring. If your application uses location tracking heavily - whether with just geofences or with location-based insights - then Radar may be a great option for you. Support is also offered on every tier level.

Limitations
The free tier provides a great runway for development, but won’t meet the needs of a production-level application. It’s important to note that an Enterprise license is required to access features other than geofencing.

react-native-background-geolocation

OS Requirements

Android API 16

iOS 8

Features

Geofences
This library supports unlimited circular geofences with monitored enter, exit, and dwell events. All geofences are stored in an SQLite database which uses geospatial queries to find the closest geofence within a predetermined radius. In other words, if you’ve specified a 10,000-meter proximity radius, it only monitors geofences within that 10,000-meter area.

Battery Efficient
It uses motion detection (accelerometer, gyroscope, and magnetometer) to detect when the device is moving and when it is stationary. When the device is moving, the plugin will automatically start recording the location. When the device is stationary, the plugin will automatically stop recording location to conserve energy.

Android Headless Mode
When enabled on an Android device, this will allow the application to continue responding to events after the application has been terminated. This is particularly useful when you want your application to respond to location events (not just geofences) when the application is closed.

Server Integration
When enabled, it can send HTTPS requests to your server with location and geofence data.

Advantages
This library definitely has advantages by allowing unlimited geofences and by being battery efficient. Support is included with a license (only required for Android). The higher the license tier, the better the support level, but the Starter level should be sufficient as it provides the same capabilities.

Limitations
Requires a license for production builds on Android and does not support polygonal geofences.

react-native-boundary

OS Requirements

Android API 16

iOS 8

Features

This library is a very basic geofencing library that supports circular geofences.

Advantages
No license is required (Android and iOS).

Limitations
The typical OS quantity limitations are in place (100 for Android, 20 for iOS). So if you want to support more than that, you will need to handle storing and querying for geofences on your own. This library only monitors enter and exit events.

Supporting Polygonal Geofences

If you decide not to use Radar, which supports polygonal geofences but still needs support for them, you can try point-in-polygon. This algorithm takes in a list of points (latitude and longitude) to describe a polygonal shape.  Determining if a point is in the polygon requires querying a set of coordinates against the shape.

Native

If none of the React Native libraries we’ve mentioned work for your use case - you can always integrate native geofence handling directly in your React Native application.

OS Requirements

Android API 16

iOS 8

Features

This route requires that you write your own native integration for geofencing - which could be an advantage! Only circular geofences are supported.

Limitations
Because this is natively handled, you’ll have quantity restrictions to work around. If you need to handle more geofences, you’ll need to implement your own database and set up geospatial queries to load/unload geofences from your application.

Natively Supporting Polygonal Geofences

iOS
MKPolygon can be used to create polygonal shapes. You can then pass in a location to see if it's within the polygon.

Android
A point-in-polygon algorithm can be used to see if a location is within a polygonal shape.

Comparison

FeaturesRadarrn-background-geolocationrn-boundaryNative
Circular Geofencing
Polygonal Geofencing🚫🚫🚫
Enter & Exit Alerts
Dwell Alerts🚫
Requires License🚫🚫
Support🚫🚫

Conclusion

When choosing a geofencing library, whether by using a React Native dependency or by writing it natively, it's important to think about what feature support you need. If licensing is a big issue, you have two options: react-native-boundary or write it yourself. Both of these options will provide basic geofencing functionality without additional costs. If licensing isn’t an issue, react-native-background-geolocation is a great option. It provides geofencing features and makes battery efficiency a high priority, with only a small licensing cost for Android.

Need expert React Native support for your geo-featured application? We’re ready to help!

Related Posts