This guide covers the steps to integrate, configure, and use the LeapMobile SDK in an iOS application.
The LeapMobile SDK allows host applications to embed Leap experiences, including navigation, deep link handling, analytics, logging, and SSO authentication.
- Xcode 16+
- iOS 16+
- Access to the private repository (SSH key or GitHub token)
The LeapMobile SDK is distributed as a private Swift Package.
- Open Xcode.
- Go to File > Add Package Dependencies.
- Enter the repository SSH URL:
git@github.com:patrontech/LeapMobileSDK-iOS.git - Add the
-ObjCflag to Build Settings → Other Linker Flags for your target. This is required to support the.nibfiles bundled with the SDK.
The SDK must be initialized before calling any other method. Initialization is asynchronous.
Required parameters:
| Parameter | Type |
|---|---|
metricsProviders |
[AnalyticsProvider] |
logging |
LoggingConfiguration |
- To use a custom logger, implement the
CustomLoggerprotocol from theLeapMobilemodule. - To use a custom analytics provider, implement the
MappedProviderprotocol from theLeapMobileBasemodule.
let logger = DemoLogger()
let analytics = DemoAnalyticsProvider(logger: logger)try await LeapMobileSDK.initialize(
metricsProviders: [analytics],
logging: .logger(logger)
)The SDK exposes an initialization property reflecting its current state:
| State | Description |
|---|---|
uninitialized |
Initialization has not started |
initializing |
Initialization is in progress |
initialized |
Initialization completed successfully |
Retrieve the SDK's rootViewController asynchronously and present it using your preferred method (modal, push, etc.).
func openSDK(style: SDKPresentationStyle) {
Task {
let rootVC = try await LeapMobileSDK.rootViewController
openSDK(with: rootVC, style: style)
}
}
private func openSDK(with viewController: UIViewController, style: SDKPresentationStyle) {
closeActiveSheet()
switch style {
case .bottomSheet:
let nav = UINavigationController(rootViewController: viewController)
activeBottomSheet = Sheet(nav)
case .fullScreen:
activeFullScreenSheet = Sheet(viewController)
}
}Note: Wrapping the root view controller in a
UINavigationControlleris recommended. Some internal SDK features require a navigation controller to function correctly. For deep link flows, it may be omitted, as shown in the next section.
Call resolveDeepLink(_:) asynchronously with the incoming URL. The method returns nil if the URL cannot be resolved by the SDK — handle this case in your implementation.
Task {
let urlResolved = try await LeapMobileSDK.resolveDeepLink(url)
openSDK(with: urlResolved, style: .bottomSheet)
}To share cookies and storage between the host app's web views and SDK web views, use the .default() WKWebsiteDataStore.
func openWebView(urlString: String) -> some View {
let url = URL(string: urlString)!
let dataStore: WKWebsiteDataStore = .default()
return CustomWebView(url: url, dataStore: dataStore)
}Call logoutUser() to notify the SDK that the current user has been logged out.
func logoutUser() async throwsExample:
Task {
try await LeapMobileSDK.logoutUser()
}Documentation for SSO Login and SSO State Listener will be added when these features are available.
All async SDK methods may throw. Handle errors gracefully and provide fallback UI where appropriate.
| Error | Description |
|---|---|
sdkNotInitialized |
A method was called before the SDK was initialized |
noSuchDeepLink |
The provided deep link URL could not be resolved |
sdkInitialized |
A generic error thrown while the SDK was already initialized |
sdkInitializing |
A generic error thrown during initialization |
- Calling SDK methods before initialization completes
- Not wrapping
rootViewControllerin aUINavigationControllerwhen required by internal flows
The demo app includes built-in tools for testing push notifications and deep link handling.
Tapping any of the notification buttons schedules a local push notification with a deep link payload:
| Button | Deep Link |
|---|---|
| 🔔 Schedule | leapfanfest://scheduleList |
| 🔔 Talents | leapfanfest://talents |
| 🔔 Brands | leapfanfest://brands |
| 🔔 Sample | sampleapp://test |
Flow:
- Tap a notification button.
- A local notification is scheduled with a 3-second delay.
- The notification appears in the notification center.
- Tap it to reopen the app — the SDK resolves the deep link and displays the appropriate content.
On first launch the app requests notification permissions. If denied, enable them via:
Settings → Notifications → LeapMobileSDKDemo → Allow Notifications
| Scheme | Handler | Examples |
|---|---|---|
leapfanfest:// |
LeapMobileSDK | leapfanfest://schedule, leapfanfest://talents, leapfanfest://brands |
sampleapp:// |
Demo app | sampleapp://test |
- Build and run the app in the simulator.
- Grant notification permissions when prompted.
- Tap a 🔔 button to schedule a test notification.
- Wait 3 seconds for the notification to appear.
- Tap the notification to test the deep link flow.
- Check console logs for SDK initialization status and deep link resolution results.
- Verify notification permissions in the Settings app.
- Ensure the SDK is fully initialized before testing deep links.
- Use the "Deeplink" button to manually test URL input