Sending Location Engine SDK Events to Leanplum

Leanplum is a mobile engagement platform that helps forward-looking brands meet the real-time needs of their customers. By transforming data into an understanding of users’ needs and wants, Leanplum delivers unified experiences that are timely, tested, and relevant. The Factual Engine SDK can be paired with Leanplum to help understand users in the physical world and to build personalized experiences driving user engagement and revenue. The steps below illustrate the simplicity of integrating the two services.


This document assumes an understanding of Leanplum platform. For background please review:


Jump to platform-specific instructions


Before following the steps below please review:

1: Include the Leanplum SDK

After upgrading your gradle file following Leanplum's documentation, include the leanplum-core library

dependencies {
    // Existing dependencies 

    // Engine Library
    implementation 'com.factual:engine-sdk:[ENGINE_VERSION]'

    // Leanplum Library
    implementation 'com.leanplum:leanplum-core:[LEANPLUM_VERSION]'

2: Setup and start the Leanplum SDK

Initialize the Leanplum SDK following Leanplum's documentation

public class MainActivity extends AppCompatActivity {

  protected void onCreate(Bundle savedInstanceState) {
    // Setup Leanplum
    if (BuildConfig.DEBUG) {
      Leanplum.setAppIdForDevelopmentMode("Your App ID", "Your Development Key");
    } else {
      Leanplum.setAppIdForProductionMode("Your App ID", "Your Production Key");
    // Start Leanplum
    // Setup Engine

3: Create a callback to handle circumstance met events

In the below example an event is sent to Leanplum when a circumstance has been met. The track method also includes the circumstance name.

public class LeanplumFactualClientReceiver extends FactualClientReceiver {
  public void onCircumstancesMet(List<CircumstanceResponse> responses) {
    for (CircumstanceResponse circumstanceResponse : responses) {
      Log.e("engine", "tracking circumstances");

4: Register your client receiver

Follow the guidance from the Android Docs


5: Verify your data

When a circumstance is met the onCircumstancesMet will be called. Once an event has been tracked it is available immediately for use in Leanplum's dashboard.


Before following the steps below please review:

1: Include the Leanplum SDK

Install the FactualEngineSDK and Leanplum-iOS-SDK SDKs via Cocoapods

source 'https://github.com/Factual/cocoapods.git'
source 'https://github.com/CocoaPods/Specs.git'


target 'EngineLeanplumExample' do
  pod 'FactualEngineSDK'
  pod 'Leanplum-iOS-SDK', '2.3.0'

2: Setup the SDK

Initialize the Leanplum SDK with proper credentials following Leanplum's documentation

#import "AppDelegate.h"
#import <Leanplum/Leanplum.h>

@interface AppDelegate ()
@property CLLocationManager *manager; // Engine assumes you are managing location permissions


@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // for demonstration, we're requesting location permissions here:
    if (_manager == nil) {
        _manager = [[CLLocationManager alloc] init];
    [_manager requestAlwaysAuthorization];
    // Start the Engine SDK.
    [FactualEngine startWithApiKey:@"FACTUAL_API_KEY"
                          delegate:self]; // FactualEngineDelegate
    // Start the Leanplum SDK
    #ifdef DEBUG
      [Leanplum setAppId:@"APP_ID"
      [Leanplum setAppId:@"APP_ID"
    [Leanplum start];
    return YES;


3: Create a callback to handle circumstance met events

In the circumstancesDidOccur callback of your FactualEngineDelegate, call the track method to send an event to Leanplum

- (void)circumstancesMet:(NSArray<CircumstanceResponse *> *)circumstances{
    for (CircumstanceResponse *myCircumstance in circumstances){
        NSLog(@"Engine circumstance triggered action: %@", [[myCircumstance circumstance] actionId]);
        [Leanplum track:@"circumstance_met" withInfo:[[myCircumstance circumstance] name]];

4: Verify your data

Once an event has been tracked it is available for immediate use in Leanplum's dashboard.