Cordova (Android/ iOS)

Step by step guide to help you with Leap Cordova Plugin Integration
This guide will help you set up the Leap platform for Android/iOS devices. You can follow the steps below to integrate Leap SDK before using your dashboard to create in-app experiences.

SDK Installation

Note: Ensure that you complete both the steps in order to create and test the in-app experience in your integrated build.

Step 1. Integrate Leap Plugin

1.a Add Leap dependency

Download Leap Cordova Plugin package from npm using the following command
Android
iOS
cordova plugin add leap-cordova-[email protected]1.3.0
cordova plugin add leap-cordova-[email protected]1.2.3
cd platforms/ios && pod install
// To update Leap iOS Plugin once installed, run the following command
pod update

1.b Start Leap SDK

To start Leap add the following inside onDeviceReady() {}
Android
iOS
document.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady() {
if(device.platform === 'Android') {
cordova.plugins.LeapAndroid.start("<YOUR_API_KEY>");
}
}
document.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady() {
if(device.platform === 'iOS') {
cordova.plugins.LeapiOS.start("<YOUR_API_KEY>");
}
}

Step 2. Enable 'Creator mode' in your app

To create in-app experiences in the Leap Studio, you will need to enable the 'Creator mode' in your app. This can be done by integrating the Leap Creator Plugin.
2.a Add Dependencies
Note - The Leap Creator Plugin must be removed before going live to PlayStore
Download Leap Creator Cordova Plugin package from npm using the following command
Android
iOS
cordova plugin add leap-cordova-creator-[email protected]1.3.0
cordova plugin add leap-cordova-creator-[email protected]1.2.3
cd platforms/ios && pod install
// To update Leap creator iOS Plugin once installed, run the following command
pod update
2.b Start Leap Creator Plugin
To start Leap creator add the following inside onDeviceReady() {}
Android
iOS
document.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady() {
if(device.platform === 'Android') {
cordova.plugins.LeapCreatorAndroid.start("<YOUR_API_KEY>");
}
}
document.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady() {
if(device.platform === 'iOS') {
cordova.plugins.LeapCreatoriOS.start("<YOUR_API_KEY>");
}
}