Instantiating ZenKey in AppDelegate on iOS
To use the ZenKey SDK within your application, instantiate ZenKey in the AppDelegate as follows:
import ZenKeySDK
...
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
ZenKeyAppDelegate.shared.application(
application,
didFinishLaunchingWithOptions: launchOptions
)
// Perform additional application setup.
return true
}
Let the ZenKey SDK handle redirects
If your app does not use a SceneDelegate, use the following code in the AppDelegate:
func application(_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
if ZenKeyAppDelegate.shared.application(app, open: url, options: options) {
return true
}
// Perform any other URL processing your app may need.
return false
}
}
If your app does use a SceneDelegate, use the following code in the SceneDelegate instead:
import ZenKeySDK
...
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let _ = (scene as? UIWindowScene) else { return }
ZenKeySceneDelegate.shared.scene(scene, willConnectTo: session, options: connectionOptions)
}
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
let unhandledContexts = ZenKeySceneDelegate.shared.scene(scene, openURLContexts: URLContexts)
unhandledContexts.forEach { context in
// Handle context
}
}
}
To enable logging for debugging, include the zenKeyOptions parameter and specify a logLevel. See enabling debug logging on iOS.
Updated about 1 year ago
Did this page help you?