{"templateId":"markdown","sharedDataIds":{},"props":{"metadata":{"markdoc":{"tagList":["InteractiveLink","Notification","LightboxImage","CodeBlockCustom","CodeItem"]},"type":"markdown"},"seo":{"title":"iOS Swift quickstart","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-quickstart","__idx":0},"children":["iOS Swift quickstart"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This guide is a walkthrough on how to integrate Frontegg’s authentication magic into your app using the Frontegg Swift SDK. Whether you need to add secure sign-ups, logins, multi-factor authentication, or even social logins, this guide has you covered with simple, step-by-step instructions to get things rolling in no time."]},{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"InteractiveLink","attributes":{"href":"https://github.com/frontegg/frontegg-ios-swift","target":"_blank","justifyContent":"center"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Check out the sample package on GitHub"]}]},{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Notification","attributes":{"title":"Prerequisites","type":"attention"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Frontegg Hosted Login is required, and setting a ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"/ciam/guides/env-settings/custom-domain"},"children":["custom domain"]}," is highly recommended.",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},"iOS ≥ 14",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},"Swift ≥ 5.3"]}]},{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"prepare-frontegg-workspace","__idx":1},"children":["Prepare Frontegg workspace"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Navigate to ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"https://portal.frontegg.com/development/settings"},"children":["Frontegg Portal Settings"]},", If you don't have an application, follow integration steps after signing up."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Copy ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["FronteggDomain"]}," for future steps from ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"https://portal.frontegg.com/development/settings/domains"},"children":["Frontegg Portal Domain"]},":"]},{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"LightboxImage","attributes":{"isLightbox":true},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/new-frontegg-domain.60f517108b4c93feb0326bd54894cfac97dcc0d10d29d12eb2cf4ef068816e5f.14341b2b.png","alt":"frontegg-domain"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"setup-hosted-login","__idx":2},"children":["Setup hosted login"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Navigate to ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"https://portal.frontegg.com/development/authentication/hosted"},"children":["Login Method Settings"]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Toggle on Hosted login method"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Add ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["{{IOS_BUNDLE_IDENTIFIER}}://{{FRONTEGG_BASE_URL}}/ios/oauth/callback"]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Replace ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["IOS_BUNDLE_IDENTIFIER"]}," with your application identifier"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Replace ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["FRONTEGG_BASE_URL"]}," with your frontegg base url, without ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["https"]},", i.e ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["FronteggDomain"]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"add-frontegg-package-to-the-project","__idx":3},"children":["Add Frontegg package to the project"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Open you project"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Choose File -> Add Packages"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Enter ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["https://github.com/frontegg/frontegg-ios-swift"]}," in search field"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Press ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Add Package"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"create-frontegg-plist-file","__idx":4},"children":["Create Frontegg Plist file"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To setup your SwiftUI application to communicate with Frontegg, you have to create a new file named ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Frontegg.plist"]},{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},"under your root project directory, this file will store values to be used variables by Frontegg SDK:"]},{"$$mdtype":"Tag","name":"CodeBlockCustom","attributes":{"tabs":["xml"]},"children":[{"$$mdtype":"Tag","name":"CodeItem","attributes":{},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\">\n<plist version=\"1.0\">\n    <dict>\n        <key>baseUrl</key>\n        <string>https://[DOMAIN_HOST_FROM_PREVIOUS_STEP]</string>\n        <key>clientId</key>\n        <string>[CLIENT_ID_FROM_PREVIOUS_STEP]</string>\n    </dict>\n</plist>\n"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"multi-apps-support","__idx":5},"children":["Multi-apps support"]},{"$$mdtype":"Tag","name":"Notification","attributes":{"title":"Prerequisites","type":"attention"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The use of this feature requires @frontegg/ios-swift@1.2.16"]}]},{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This guide outlines the steps to configure your iOS application to support multiple applications."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Add ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["applicationId"]}," to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Frontegg.plist"]}," file:"]},{"$$mdtype":"Tag","name":"CodeBlockCustom","attributes":{"tabs":["xml"]},"children":[{"$$mdtype":"Tag","name":"CodeItem","attributes":{},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"<plist version=\"1.0\">\n  <dict>\n    <key>applicationId</key>  \n    <string>your-application-id-uuid</string>\n    <key>baseUrl</key>\n    <string>https://your-domain.fronteg.com</string>\n    <key>clientId</key>\n    <string>your-client-id-uuid</string>\n  </dict>\n</plist>\n"},"children":[]}]}]},{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"embedded-webview-vs-aswebauthenticationsession","__idx":6},"children":["Embedded webview vs ASWebAuthenticationSession"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["@frontegg/swift"]}," SDK supports two authentication methods:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Embedded Webview"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["ASWebAuthenticationSession"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["By default Frontegg SDK will use Embedded Webview, to use ASWebAuthenticationSession you have to set ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["embeddedMode"]}," to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["NO"]}," in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Frontegg.plist"]}," file:"]},{"$$mdtype":"Tag","name":"CodeBlockCustom","attributes":{"tabs":["xml"]},"children":[{"$$mdtype":"Tag","name":"CodeItem","attributes":{},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\">\n<plist version=\"1.0\">\n    <dict>\n        <key>baseUrl</key>\n        <string>https://[DOMAIN_HOST_FROM_PREVIOUS_STEP]</string>\n        <key>clientId</key>\n        <string>[CLIENT_ID_FROM_PREVIOUS_STEP]</string>\n\n        <!-- START -->\n        <key>embeddedMode</key>\n        <true/>\n        <!-- END -->\n    </dict>\n</plist>\n"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"configure-ios-associated-domain","__idx":7},"children":["Configure iOS associated domain"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Configuring your iOS associated domain is required for Magic Link authentication / Reset Password / Activate Account."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In order to add your iOS associated domain to your Frontegg application, you will need to update in each of your",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},"integrated Frontegg Environments the iOS associated domain that you would like to use with that Environment. Send a POST request to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["https://api.frontegg.com/vendors/resources/associated-domains/v1/ios"]}," with the following payload:"]},{"$$mdtype":"Tag","name":"CodeBlockCustom","attributes":{"tabs":["xml"]},"children":[{"$$mdtype":"Tag","name":"CodeItem","attributes":{},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"{\n    \"appId\":[YOUR_ASSOCIATED_DOMAIN]\n}\n"},"children":[]}]}]},{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In order to use our API’s, follow [this guide] to  generate a vendor token."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Next, you will need to add your associated domain to your iOS application. To do so, follow the steps below:"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Open your project in Xcode."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Select your project in the Project Navigator."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Select your target."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Select the Signing & Capabilities tab."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Expand the Associated Domains section."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Click the + button."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Enter your associated domain in the format ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["applinks:[YOUR_ASSOCIATED_DOMAIN]"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Enter your associated domain in the format ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["webcredentials:[YOUR_ASSOCIATED_DOMAIN]"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Click Done."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["[YOUR_ASSOCIATED_DOMAIN]"]}," is the associated domain that you would like to use with your iOS application.",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},"For example, if you would like to use ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["https://example.com"]}," as your associated domain, you would",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},"enter ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["applinks:example.com"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["webcredentials:example.com"]},"."]},{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"multi-region-support","__idx":8},"children":["Multi-region support"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This guide outlines the steps to configure your iOS application to support multiple regions."]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Modify the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Frontegg.plist"]}," File - adjust your ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Frontegg.plist"]}," file to handle multiple regions:"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Modifications"]},":"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Remove"]}," the existing ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["baseUrl"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["clientId"]}," keys."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Add"]}," a new array key named ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["regions"]},". This array will hold dictionaries for each region."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Example ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Frontegg.plist"]}," Structure:"]},{"$$mdtype":"Tag","name":"CodeBlockCustom","attributes":{"tabs":["xml"]},"children":[{"$$mdtype":"Tag","name":"CodeItem","attributes":{},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"<key>regions</key>\n<array>\n<dict>\n    <key>key</key>\n    <string>us-region</string>\n    <key>baseUrl</key>\n    <string>https://us-region-api.frontegg.com</string>\n    <key>clientId</key>\n    <string>your-client-id-for-us-region</string>\n</dict>\n<!-- Add additional regions in a similar format -->\n</array>\n"},"children":[]}]}]},{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"ol","attributes":{"start":2},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Add Associated domains for each region"," ","For each region, configure the associated domains in your application's settings. This is vital for proper API routing",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},"and authentication."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Follow ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"#configure-ios-associated-domain"},"children":["Configure iOS associated domain"]}," to add your iOS associated domain to your Frontegg application."]},{"$$mdtype":"Tag","name":"ol","attributes":{"start":3},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Implement Region Selection UI"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The final step is to implement a UI for the user to select their region. ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["This can be done in any way you see fit"]},".",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},"The example application uses a simple picker view to allow the user to select their region."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Important considerations"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Switching regions"]},": To switch regions, update the selection in UserDefaults. If issues arise, a ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["re-installation"]},{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},"of the application might be necessary."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Data isolation"]},": Ensure data handling and APIs are region-specific to prevent data leakage between regions."]}]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"align":"center","data-label":"Select EU Region"},"children":["Select EU Region"]},{"$$mdtype":"Tag","name":"th","attributes":{"align":"center","data-label":"Select US Region"},"children":["Select US Region"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"center"},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/eu-region-example.b43215d2a725f9b73d803a3ee90bb3e87c695825f8767a08e4c31e5477dac47c.14341b2b.gif","alt":"eu-region-example.gif"},"children":[]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"center"},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/us-region-example.ec48d044edc19e458a1bcabe98a0e8cc0e17cbf09a99ea37c0665d648456f715.14341b2b.gif","alt":"us-region-example.gif"},"children":[]}]}]}]}]}]},{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Example region selection UI:"]},{"$$mdtype":"Tag","name":"CodeBlockCustom","attributes":{"tabs":["swift"]},"children":[{"$$mdtype":"Tag","name":"CodeItem","attributes":{},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"import SwiftUI\nimport FronteggSwift\n\nstruct SelectRegionView: View {\n    @EnvironmentObject var fronteggAuth: FronteggAuth\n    \n    var body: some View {\n        VStack(alignment: .leading) {\n            Text(\"Welcome to MyApp\")\n                .font(.largeTitle)\n            \n            Text(\"Select your region:\")\n                .padding(.top, 8)\n                .padding(.bottom, 20)\n                .font(.title2)\n            \n            \n            ForEach(fronteggAuth.regionData, id: \\.key.self) { item in\n                Button(action: {\n                    FronteggApp.shared.initWithRegion(regionKey: item.key)\n                }) {\n                    VStack(alignment: .leading) {\n                        Text(\"Region - \\(item.key.uppercased())\")\n                            .font(.title2)\n                            .padding(.bottom, 1)\n                        Text(\"\\(item.baseUrl)\")\n                            .font(.caption)\n                            .tint(.black)\n                            .padding(.bottom, 8)\n                    }\n                }\n                .frame(maxWidth: .infinity, alignment: .leading)\n                .contentShape(Rectangle())\n            }\n            \n            Spacer()\n            \n        }\n        .padding()\n        .navigationTitle(\"Region\")\n    }\n}\n"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"swiftui-and-uikit-integration","__idx":9},"children":["SwiftUI and UIKit integration"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Add Frontegg wrapper"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To use Frontegg SDK you have to wrap you Application Scene with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["FronteggWrapper"]}]},{"$$mdtype":"Tag","name":"CodeBlockCustom","attributes":{"tabs":["swift"]},"children":[{"$$mdtype":"Tag","name":"CodeItem","attributes":{},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"import SwiftUI\n    import FronteggSwift\n\n    @main\n    struct demoApp: App {\n        var body: some Scene {\n            WindowGroup {\n                FronteggWrapper {\n                    MyApp()\n                }\n            }\n        }\n    }\n"},"children":[]}]}]},{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Modify ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["MyApp.swift"]}," file to render content if user is authenticated:"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Add ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["@EnvironmentObject var fronteggAuth: FronteggAuth"]}," to"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Render your entire application based on ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["fronteggAuth.isAuthenticated"]}]}]},{"$$mdtype":"Tag","name":"CodeBlockCustom","attributes":{"tabs":["swift"]},"children":[{"$$mdtype":"Tag","name":"CodeItem","attributes":{},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"struct MyApp: View {\n      @EnvironmentObject var fronteggAuth: FronteggAuth\n      \n      var body: some View {\n        ZStack {\n          if fronteggAuth.isAuthenticated {\n            [YOU APPLICATION TABS / ROUTER / VIEWS]\n          } else  {\n            \n            Button {\n                fronteggAuth.login()\n            } label: {\n                Text(\"Login Button\")\n            }\n          }\n        }\n      }\n    }\n"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"swiftui---add-sustom-loading-screen","__idx":10},"children":["SwiftUI - add sustom loading screen"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To use your own ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["LoadingView"]}," / ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SplashScreen"]},":"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Build your loading view in separated file"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Pass ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["LoadingView"]}," as AnyView to the FronteggWrapper"]}]},{"$$mdtype":"Tag","name":"CodeBlockCustom","attributes":{"tabs":["swift"]},"children":[{"$$mdtype":"Tag","name":"CodeItem","attributes":{},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"FronteggWrapper(loaderView: AnyView(LoaderView())) {\n      MyApp()\n    }\n"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"uikit---frontegg-uikit-wrapper","__idx":11},"children":["UIKit - Frontegg UIKit wrapper"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Add Frontegg to the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["AppDelegate"]}," file"]}]},{"$$mdtype":"Tag","name":"CodeBlockCustom","attributes":{"tabs":["swift"]},"children":[{"$$mdtype":"Tag","name":"CodeItem","attributes":{},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions:     \n        [UIApplication. LaunchOptionsKey: Any]?) -> Bool {\n          // Override point for customization after application launch.\n\n          FronteggApp.shared.didFinishLaunchingWithOptions()\n        \n          return true\n    }\n"},"children":[]}]}]},{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"ol","attributes":{"start":2},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Create AuthenticationController class that extends ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["AbstractFronteggController"]}," from FronteggSwift"]}]},{"$$mdtype":"Tag","name":"CodeBlockCustom","attributes":{"tabs":["swift"]},"children":[{"$$mdtype":"Tag","name":"CodeItem","attributes":{},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"    //  AuthenticationController.swift\n      \n      import UIKit\n      import FronteggSwift\n      \n      class AuthenticationController: AbstractFronteggController {\n      \n          override func navigateToAuthenticated(){\n              // This function will be called when the user is authenticated\n              // to navigate your application to the authenticated screen\n              \n              let mainStoryboard: UIStoryboard = UIStoryboard(name: \"Main\", bundle: nil)\n              \n              // TODO: Set Storyboard ID 'authenticatedScreen' for your authenticated screen\n              let viewController = mainStoryboard.instantiateViewController(withIdentifier: \"authenticatedScreen\")\n              self.view.window?.rootViewController = viewController\n              self.view.window?.makeKeyAndVisible()\n          }\n      \n      }\n"},"children":[]}]}]},{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"ol","attributes":{"start":3},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Create a new ViewController for ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["AuthenticationController"]},":",{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Change viewController's class to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["AuthenticationController"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Set Storyboard ID to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["fronteggController"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Make sure that the view controller is the initial view controller"]}]}]}]},{"$$mdtype":"Tag","name":"LightboxImage","attributes":{"isLightbox":true},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/swift_authentication_controller.843cb0ddc4083268658aa980384bc82aea44a833f65589d5a7e8288956c9b285.14341b2b.png","alt":"frontegg-domain"},"children":[]}]}]},{"$$mdtype":"Tag","name":"ol","attributes":{"start":4},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Setup ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SceneDelegate"]}," for Frontegg universal links:"]}]},{"$$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 scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {\n          if let url = URLContexts.first?.url,\n              url.startAccessingSecurityScopedResource() {\n              defer  {\n                  url.stopAccessingSecurityScopedResource()\n              }\n              if url.absoluteString.hasPrefix( FronteggApp.shared.baseUrl ) {\n                  if(FronteggApp.shared.auth.handleOpenUrl(url)){\n                      // Display your own Authentication View Controller\n                      // to handle after oauth callback\n                      window?.rootViewController = AuthenticationController()\n                      window?.makeKeyAndVisible()\n                      return\n                  }\n              }\n              \n          }\n      }\n      func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {\n          if let url = userActivity.webpageURL {\n              if(FronteggApp.shared.auth.handleOpenUrl(url)){\n                  // Display your own Authentication View Controller\n                  // to handle after oauth callback\n                  window?.rootViewController = AuthenticationController()\n                  window?.makeKeyAndVisible()\n                  return\n              }\n          }\n      }\n"},"children":[]}]}]},{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"ol","attributes":{"start":5},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Access authenticated user by ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["FronteggApp.shared.auth"]},":"]}]},{"$$mdtype":"Tag","name":"CodeBlockCustom","attributes":{"tabs":["swift"]},"children":[{"$$mdtype":"Tag","name":"CodeItem","attributes":{},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"//  ExampleViewController.swift\n      \n      import UIKit\n      import FronteggSwift\n      \n      class ExampleViewController: UIViewController {\n      \n          // Label to display logged in user's email\n          @IBOutlet weak var label: UILabel!\n          var showLoader: Boolean = true\n          \n          override func viewDidLoad() {\n              super.viewDidLoad()\n              // Do any additional setup after loading the view.\n              \n              // subscribe to isAuthenticated and navigate to login page\n              // if the user is not authenticated\n\n              let fronteggAuth = FronteggApp.shared.auth\n              self.label.text = fronteggAuth.user?.email ?? \"Unknown\"\n          }\n           \n          @IBAction func logoutButton (){\n              FronteggApp.shared.auth.logout() { _ in\n                  window?.rootViewController = AuthenticationController()\n                  window?.makeKeyAndVisible()  \n              }\n          }\n\n      }\n"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"login-with-aswebauthenticationsession","__idx":12},"children":["Login with ASWebAuthenticationSession"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Starting from version 1.2.9, the Frontegg SDK has introduced support for ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ASWebAuthenticationSession"]},", enhancing the login experience. This new feature allows for a more streamlined and secure authentication process."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["A ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["loginWithPopup"]}," method has added with parameters to accommodate the integration of ASWebAuthenticationSession:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["window"]},": Specifies the window where the login view controller will be presented. If this parameter is not provided,",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},"the SDK will default to using the key window."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ephemeralSession"]},": A Boolean flag indicating if the session should be ephemeral. By default, this is set to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["true"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["loginHint"]},": An optional parameter for the login hint to be used during the login process. It is ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["nil"]}," by default."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["loginAction"]},": An optional parameter that defines the login action to be used. It also defaults to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["nil"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["completion"]},": A completion handler that is called once the login process concludes."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Below are examples demonstrating how to utilize ASWebAuthenticationSession with the Frontegg SDK in both UIKit and SwiftUI applications."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"uikit-implementation","__idx":13},"children":["UIKit implementation"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For developers using UIKit, the login process can be initiated as follows:"]},{"$$mdtype":"Tag","name":"CodeBlockCustom","attributes":{"tabs":["swift"]},"children":[{"$$mdtype":"Tag","name":"CodeItem","attributes":{},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"import UIKit\nimport FronteggSwift\n\nclass ViewController: UIViewController {\n    override func viewDidLoad() {\n        super.viewDidLoad()\n    }\n\n    @IBAction func loginButtonTapped() {\n        FronteggAuth.shared.loginWithPopup(window: self.view.window) { 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    }\n}\n"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"swiftui-implementation","__idx":14},"children":["SwiftUI implementation"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For those preferring SwiftUI, the integration is similarly straightforward:"]},{"$$mdtype":"Tag","name":"CodeBlockCustom","attributes":{"tabs":["swift"]},"children":[{"$$mdtype":"Tag","name":"CodeItem","attributes":{},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"import SwiftUI\nimport FronteggSwift\n\nstruct ContentView: View {\n    @EnvironmentObject var fronteggAuth: FronteggAuth\n    \n    var body: some View {\n        VStack {\n            if fronteggAuth.isAuthenticated {\n                Text(\"User Authenticated\")\n            } else {\n                Button(\"Login\") {\n                    fronteggAuth.loginWithPopup()\n                }\n            }\n        }\n    }\n}\n"},"children":[]}]}]},{"$$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":"import SwiftUI\nimport FronteggSwift\n\nstruct ContentView: View {\n    @EnvironmentObject var fronteggAuth: FronteggAuth\n    \n    var body: some View {\n        VStack {\n            if fronteggAuth.isAuthenticated {\n                Text(\"User Authenticated\")\n            } else {\n                Button(\"Login\") {\n                    fronteggAuth.loginWithPopup()\n                }\n            }\n        }\n    }\n}\n"},"children":[]}]}]}]},"headings":[{"value":"iOS Swift quickstart","id":"ios-swift-quickstart","depth":2},{"value":"Prepare Frontegg workspace","id":"prepare-frontegg-workspace","depth":3},{"value":"Setup hosted login","id":"setup-hosted-login","depth":3},{"value":"Add Frontegg package to the project","id":"add-frontegg-package-to-the-project","depth":3},{"value":"Create Frontegg Plist file","id":"create-frontegg-plist-file","depth":3},{"value":"Multi-apps support","id":"multi-apps-support","depth":3},{"value":"Embedded webview vs ASWebAuthenticationSession","id":"embedded-webview-vs-aswebauthenticationsession","depth":3},{"value":"Configure iOS associated domain","id":"configure-ios-associated-domain","depth":3},{"value":"Multi-region support","id":"multi-region-support","depth":3},{"value":"SwiftUI and UIKit integration","id":"swiftui-and-uikit-integration","depth":3},{"value":"SwiftUI - add sustom loading screen","id":"swiftui---add-sustom-loading-screen","depth":4},{"value":"UIKit - Frontegg UIKit wrapper","id":"uikit---frontegg-uikit-wrapper","depth":4},{"value":"Login with ASWebAuthenticationSession","id":"login-with-aswebauthenticationsession","depth":3},{"value":"UIKit implementation","id":"uikit-implementation","depth":4},{"value":"SwiftUI implementation","id":"swiftui-implementation","depth":4}],"frontmatter":{"seo":{"title":"iOS Swift quickstart"}},"lastModified":"2025-11-04T13:25:50.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/ciam/sdks/mobile/swift/login-old","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}