Skip to content

Commit 8f0f97a

Browse files
authored
Geofencing README (#293)
* First pass * Simplify README deferring to native instructions * Explicitly explain iOS requirement * Add troubleshooting for geofencing * Remove extra note
1 parent 9f6cdb2 commit 8f0f97a

2 files changed

Lines changed: 53 additions & 0 deletions

File tree

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@
4040
- [Setup](#setup-1)
4141
- [In-App Forms Session Configuration](#in-app-forms-session-configuration)
4242
- [Unregistering from In-App Forms](#unregistering-from-in-app-forms)
43+
44+
- [Geofencing](#geofencing)
45+
- [Prerequisites](#prerequisites-2)
46+
- [Setup](#setup-2)
47+
- [Unregistering from Geofencing](#unregistering-from-geofencing)
4348
- [Troubleshooting](#troubleshooting)
4449
- [Contributing](#contributing)
4550
- [License](#license)
@@ -591,6 +596,49 @@ Klaviyo.unregisterFromInAppForms(config);
591596

592597
Note that after unregistering, the next call to `registerForInAppForms()` will be considered a new session by the SDK.
593598

599+
## Geofencing
600+
601+
> ℹ️ Support for Geofencing is currently available for early access to select Klaviyo customers. Please contact your CSM to be enrolled.
602+
603+
> Alpha geofencing support is available in SDK version 2.2.0-alpha.1 and higher.
604+
605+
Geofencing allows you to trigger events when users enter or exit geographic regions. The Klaviyo SDK monitors geofences configured in your Klaviyo account and automatically tracks geofence enter and exit events. The SDK automatically handles geofence synchronization with your Klaviyo account—when you add, update, or remove geofences in Klaviyo, the SDK will automatically sync these changes on the next app launch or when the API key changes.
606+
607+
### Prerequisites
608+
609+
Integrating geofencing is highly platform-specific as it utilizes the native monitoring systems. Begin by thoroughly reviewing the setup
610+
instructions for Geofencing in the README from each native Klaviyo SDK:
611+
612+
- [Android](https://github.com/klaviyo/klaviyo-android-sdk/tree/rel/4.2.0-rc.1?tab=readme-ov-file#geofencing)
613+
- [iOS](https://github.com/klaviyo/klaviyo-swift-sdk/tree/rel/5.2.0-alpha.1?tab=readme-ov-file#geofencing)
614+
615+
### Setup
616+
617+
To enable geofencing in your app, you must:
618+
619+
1. Configure location permissions in your app's platform-specific configuration files
620+
2. Call `Klaviyo.registerGeofencing()` after initializing the SDK
621+
622+
4. Register for geofencing after initializing the SDK:
623+
```typescript
624+
import { Klaviyo } from 'klaviyo-react-native-sdk';
625+
626+
// After initializing with your public API key
627+
Klaviyo.registerGeofencing();
628+
```
629+
630+
### Unregistering from Geofencing
631+
632+
If at any point you need to stop monitoring geofences, e.g. when the user logs out or opts out of location tracking, you may call:
633+
634+
```typescript
635+
import { Klaviyo } from 'klaviyo-react-native-sdk';
636+
637+
Klaviyo.unregisterGeofencing();
638+
```
639+
640+
After unregistering, the SDK will stop monitoring geofences and will no longer report geofence transition events. You can call `registerGeofencing()` again to resume monitoring.
641+
594642
## Troubleshooting
595643

596644
Use the [troubleshooting guide](Troubleshooting.md) to resolve common issues with the Klaviyo React Native SDK.

Troubleshooting.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,8 @@ Make sure to use the URL scheme (rntest://) of the example app when testing.
110110
There is an open issue with [`@react-native-firebase/messaging`](https://github.com/invertase/react-native-firebase/issues/8022) where the SDK will uppercase any APNS token returned using `messaging().getAPNSToken()`.
111111
You can verify this by adding a log the `AppDelegate.m` file that prints the deviceToken (you will need to convert to a hex string).
112112
This might have no impact on your use case, but is something to consider when designing.
113+
114+
### iOS Geofencing Events not Firing
115+
116+
The delivery of geofence events to the Klaviyo SDK requires registering for geofences in the native iOS layer in `didFinishLaunchingWithOptions`. If you only call `Klaviyo.registerGeofencing()` in the React Native layer or any later in the lifecycle, triggered enter/exit events may not get delivered in a reliable manner as the native monitoring service relies on that AppDelegate entry point.
117+

0 commit comments

Comments
 (0)