{"templateId":"markdown","sharedDataIds":{},"props":{"metadata":{"markdoc":{"tagList":["CodeBlockCustom","CodeItem"]},"type":"markdown"},"seo":{"title":"iOS Swift advanced setup","siteUrl":"https://developers.frontegg.com/","llmstxt":{"title":"Frontegg Developer Documentation","description":"Authentication, authorization, and user management for Customer Identity, plus Agen for SaaS and Agen for Work. Guides, SDKs, and API references.","sections":[{"title":"Customer Identity (CIAM)","description":"Auth, SSO, SCIM, entitlements, and user management — guides, SDKs, and APIs.","includeFiles":["ciam/**/*.md"],"excludeFiles":[]},{"title":"Agen for SaaS","description":"Agentic access and authorization for SaaS products.","includeFiles":["agen-for-saas/**/*.md"],"excludeFiles":[]},{"title":"Agen for Work","description":"Agentic access and authorization for internal and workforce use.","includeFiles":["agen-for-work/**/*.md"],"excludeFiles":[]},{"title":"Platform","description":"Shared platform overview.","includeFiles":["platform/**/*.md"],"excludeFiles":[]}],"excludeFiles":["internal-docs/**","ciam/guides/env-settings/inject-client-ip.md","CLAUDE.md",".claude/**","**/images/**"],"hide":false}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"ios-swift-advanced-setup","__idx":0},"children":["iOS Swift advanced setup"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In this guide, you'll find an overview and best practices for enabling advanced features and using built in functions for biometric authentication (passkeys) and step-up."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"passkeys-authentication-ios-15","__idx":1},"children":["Passkeys authentication (iOS 15+)"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Passkeys provide a seamless, passwordless login experience using WebAuthn and platform-level biometric authentication."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Prerequisites"]}]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["iOS Version"]},": Ensure your project targets ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["iOS 15 or later"]}," to support the necessary WebAuthn APIs."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Associated Domain"]},": Configure your app's associated domains to enable passkeys functionality."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Frontegg SDK Version"]},": Use Frontegg iOS SDK version ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["1.2.24 or later"]},"."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"configure-associated-domains-in-xcode","__idx":2},"children":["Configure associated domains in Xcode"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Open your project in ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Xcode"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Go to your ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["target"]}," settings"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Open the ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Signing & Capabilities"]}," tab"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Click the ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["+ Capability"]}," button and add ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Associated Domains"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Under ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Associated Domains"]},", click the ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["+"]}," and add: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["webcredentials:your-domain.com"]},". For example, if your domain is ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["https://example.com"]},", use ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["webcredentials:example.com"]},"."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"host-the-well-knownwebauthn-file","__idx":3},"children":["Host the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":[".well-known/webauthn"]}," file"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["On your server, create a JSON file at the following location: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["https://your-domain.com/.well-known/webauthn"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Use the structure below:"]}]},{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"CodeBlockCustom","attributes":{"tabs":["JSON"]},"children":[{"$$mdtype":"Tag","name":"CodeItem","attributes":{},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n  \"origins\": [\n    \"https://your-domain.com\",\n    \"https://subdomain.your-domain.com\"\n  ]\n}\n","lang":"json"},"children":[]}]}]},{"$$mdtype":"Tag","name":"ol","attributes":{"start":3},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Ensure this file is publicly accessible (HTTP 200 OK)."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"test-domain-association","__idx":4},"children":["Test domain association"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Verify that your associated domain configuration works using Apple's ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"https://developer.apple.com/contact/request/associated-domains"},"children":["Associated Domains Validator"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"register-passkeys","__idx":5},"children":["Register passkeys"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Call this method from your app to enable passkeys registration for a user:"]},{"$$mdtype":"Tag","name":"CodeBlockCustom","attributes":{"tabs":["Swift"]},"children":[{"$$mdtype":"Tag","name":"CodeItem","attributes":{},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"swift","header":{"controls":{"copy":{}}},"source":"import FronteggSwift\n\nfunc registerPasskeys() {\n    if #available(iOS 15.0, *) {\n        FronteggAuth.shared.registerPasskeys()\n    } else {\n        print(\"Passkeys are only supported on iOS 15 or later.\")\n    }\n}\n","lang":"swift"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"login-with-passkeys","__idx":6},"children":["Login with passkeys"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To log users in using a stored passkey:"]},{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"CodeBlockCustom","attributes":{"tabs":["Swift"]},"children":[{"$$mdtype":"Tag","name":"CodeItem","attributes":{},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"swift","header":{"controls":{"copy":{}}},"source":"import FronteggSwift\n\nfunc loginWithPasskeys() {\n    if #available(iOS 15.0, *) {\n        FronteggAuth.shared.loginWithPasskeys { result in\n            switch result {\n            case .success(let user):\n                print(\"User logged in: \\(user)\")\n            case .failure(let error):\n                print(\"Error logging in: \\(error)\")\n            }\n        }\n    } else {\n        print(\"Passkeys are only supported on iOS 15 or later.\")\n    }\n}\n","lang":"swift"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"step-up-authentication","__idx":7},"children":["Step-up authentication"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Step-Up Authentication allows you to temporarily elevate a user's authentication level to perform sensitive actions. This is useful for operations like updating credentials, accessing confidential data, or performing secure transactions."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"stepup--","__idx":8},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["stepUp"]}," -"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Starts the step-up authentication flow. This will usually trigger a secondary authentication method ( e.g. biometric, MFA, etc)."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["maxAge"]}," (optional): How long the elevated session is considered valid, in seconds."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["completion"]},": A closure called after authentication finishes. If step-up fails, it receives an error."]},{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"CodeBlockCustom","attributes":{"tabs":["Swift"]},"children":[{"$$mdtype":"Tag","name":"CodeItem","attributes":{},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"Task {\n    await FronteggAuth.shared.stepUp(maxAge: 300) { error in\n        if let error = error {\n            print(\"Step-up failed: \\(error.localizedDescription)\")\n            return\n        }\n\n        // Authentication successful, continue with the secure action\n        self.performSensitiveAction()\n    }\n}\n"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"issteppedup--","__idx":9},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["isSteppedUp"]}," -"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This method hecks whether the user has recently completed a step-up authentication and whether it is still valid."]},{"$$mdtype":"Tag","name":"CodeBlockCustom","attributes":{"tabs":["Swift"]},"children":[{"$$mdtype":"Tag","name":"CodeItem","attributes":{},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"let isSteppedUp = FronteggAuth.shared.isSteppedUp(maxAge: 300) // 300 seconds = 5 minutes\n\nif isSteppedUp {\n    // Proceed with secure operation\n} else {\n    // Trigger step-up flow\n}\n"},"children":[]}]}]},{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Example"]}]},{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"CodeBlockCustom","attributes":{"tabs":["Swift"]},"children":[{"$$mdtype":"Tag","name":"CodeItem","attributes":{},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"func performSensitiveFlow() {\n    let isElevated = FronteggAuth.shared.isSteppedUp(maxAge: 300)\n\n    if isElevated {\n        performSensitiveAction()\n    } else {\n        Task {\n            await FronteggAuth.shared.stepUp(maxAge: 300) { error in\n                if let error = error {\n                    showAlert(\"Authentication Failed\", message: error.localizedDescription)\n                    return\n                }\n                performSensitiveAction()\n            }\n        }\n    }\n}\n\nfunc performSensitiveAction() {\n    // Proceed with a high-security task\n    print(\"Secure action performed.\")\n}\n"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"logout-after-reinstall","__idx":10},"children":["Logout after reinstall"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To force logout when a user reinstalls the app, update your ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Frontegg.plist"]}," file:"]},{"$$mdtype":"Tag","name":"CodeBlockCustom","attributes":{"tabs":["Swift"]},"children":[{"$$mdtype":"Tag","name":"CodeItem","attributes":{},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"xml","header":{"controls":{"copy":{}}},"source":"<plist version=\"1.0\">\n  <dict>\n    <key>keepUserLoggedInAfterReinstall</key>\n    <false/>\n    ...\n  </dict>\n</plist>\n","lang":"xml"},"children":[]}]}]},{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["By default ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["keepUserLoggedInAfterReinstall"]}," is ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["true"]},"."]}]},"headings":[{"value":"iOS Swift advanced setup","id":"ios-swift-advanced-setup","depth":2},{"value":"Passkeys authentication (iOS 15+)","id":"passkeys-authentication-ios-15","depth":2},{"value":"Configure associated domains in Xcode","id":"configure-associated-domains-in-xcode","depth":3},{"value":"Host the .well-known/webauthn file","id":"host-the-well-knownwebauthn-file","depth":3},{"value":"Test domain association","id":"test-domain-association","depth":3},{"value":"Register passkeys","id":"register-passkeys","depth":3},{"value":"Login with passkeys","id":"login-with-passkeys","depth":3},{"value":"Step-up authentication","id":"step-up-authentication","depth":2},{"value":"stepUp -","id":"stepup--","depth":4},{"value":"isSteppedUp -","id":"issteppedup--","depth":4},{"value":"Logout after reinstall","id":"logout-after-reinstall","depth":2}],"frontmatter":{"seo":{"title":"iOS Swift advanced setup"}},"lastModified":"2025-11-04T13:25:50.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/ciam/sdks/mobile/swift/advanced-old","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}