Setup Leap Callbacks
Whenever end-user interacts with flows or elements events are generated to track the insights. To listen to Leap callbacks, Follow the below steps to do the same.
Listen to all the events in your Application(android) / AppDelegate(iOS) class.
Android
iOS Swift
iOS Objective-C
React Native
Cordova(Android)
Cordova (iOS)
Xamarin Android
Xamarin iOS
Ionic
import is.leap.android.LeapEventListener;
public class MyApplication extends Application {
@Override
public void onCreate() {
LeapEventCallbacks eventListener = new LeapEventCallbacks() {
@Override
public void onEvent(Map<String, String> eventData) {
}
};
Leap.setLeapEventCallbacks(eventListener);
}
}
Leap.shared.callback = self
extension AppDelegate:LeapCallback {
func eventNotification(eventInfo: Dictionary<String, Any>) {
}
}
@interface AppDelegate () <LeapCallback>
Leap.shared.callback = self;
- (void)eventNotificationWithEventInfo:(NSDictionary<NSString *,id> *)eventInfo {
}
import { NativeEventEmitter } from 'react-native';
export class App extends React.Component {
componentDidMount() {
// Register for callbacks
const eventEmitter = new NativeEventEmitter(LeapReactNative);
const onSessionConnect = (event) => {
console.log(event);
}
eventEmitter.addListener('LeapCallbacks', onSessionConnect);
}
}
cordova.plugins.LeapAndroid.setLeapEventCallback((leapEvent)=> {
console.log(JSON.stringify(leapEvent, null, 2))
})
cordova.plugins.LeapiOS.setLeapEventCallback((leapEvent) =>{
console.log(JSON.stringify(leapEvent, null, 2));
})
using static IS.Leap.Android.ILeapEventCallbacks
using IS.Leap.Android;
public class MainActivity : AppCompatActivity, ILeapEventCallbacks
{
protected override void OnCreate(Bundle savedInstanceState){
Leap.SetLeapEventCallbacks(eventCallbacks: this);
}
public void OnEvent(IDictionary<string, string> keyValues)
{
}
}
public class AppDelegate : UIResponder, IUIApplicationDelegate
{
private LeapEventsCallback callback = null;
public bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
Leap.Shared.Start("f4f460a6-9e04-4114-9da4-410659427c6a");
callback = new LeapEventsCallback();
Leap.Shared.SetCallback(callback);
return true;
}
}
public class LeapEventsCallback : LeapCallback
{
public override void EventNotificationWithEventInfo(NSDictionary<NSString, NSObject> eventInfo)
{
System.Diagnostics.Debug.WriteLine(eventInfo);
}
}
Whenever end-user interacts with flows or elements events are generated to track the insights. The steps below will help to listen to the same
Add the following code snippet inside the method where app component is rendered.
LeapPlugin.start({apiKey:"<YOUR_API_KEY>"});
LeapPlugin.addListener("leapCallbacks", (event: LeapCallbacks) => {
console.log("Leap Events: ", event);
})
For more details on each callback, you can refer to the Leap Events (Reference).
Copy link