Configure navigation, analytics, and experience callbacks
Configure how your app handles navigation, analytics events, and experience lifecycle callbacks.
Important (iOS)On iOS, callback instances must be stored in static fields to prevent the .NET garbage collector from finalizing them. The native Swift SDK holds weak Objective-C references to these objects, which the .NET GC cannot see.
Register callbacks before calling Setup() on Android so events fired during initialization are not lost. Register callbacks after calling Setup() on iOS.
public class AppNavigationCallbackiOS : Userpilot.UserpilotNavigationCallback{ public override void OnNavigate(string url) { Console.WriteLine($"[Userpilot] Navigate to: {url}"); // Handle navigation to the URL }}// Store in a static field to prevent GCprivate static AppNavigationCallbackiOS? _navCallback;// Register the callback (after SDK setup)_navCallback = new AppNavigationCallbackiOS();Userpilot.UserpilotSdk.SetNavigationCallback(_navCallback);
public class AppNavigationCallback : Java.Lang.Object, Userpilot.UserpilotSdk.Companion.INavigationCallback{ public void OnNavigate(string url) { Android.Util.Log.Info("Userpilot", $"Navigate to: {url}"); // Handle navigation to the URL }}// Register the callback (before SDK setup)Userpilot.UserpilotSdk.SetNavigationCallback(new AppNavigationCallback());
Receives callbacks whenever the SDK tracks an event, screen, or identifies a user. Use this to integrate with another analytics tool or log events for debugging.