# iOS

**1- Framework setup**

* Create LocalPods folder if you don't have it.
* Add UAEPPASSClient folder in LocalPods folder.
* Add pod 'UAEPassClient', :path => "LocalPods/UAEPassClient" to your podfile

**2- Should do**

* In AppDelegate add below : import UAEPassClient
* In didFinishLaunchingWithOptions add&#x20;

```
UAEPASSRouter.shared.spConfig = SPConfig(redirectUriLogin: "client redirect url",
                                         scope: "client login scope",
                                         state: "RANDOM 24 alpha numeric",  //Randomly Generated Code 24 alpha numeric.
                                         successSchemeURL: "UUUUU://", //client success url scheme.
                                         failSchemeURL: "CCCCC://", //client failure url scheme.
                                         signingScope: "urn:safelayer:eidas:sign:process:document") // client signing scope
                                         UAEPASSRouter.shared.environmentConfig = UAEPassConfig(clientID: "your client id", env: .production)
--- env (environment can be : .production or .stg)
```

* func application(\_: UIApplication, handleOpen url: URL) -> Bool

```
print("<><><><> appDelegate URL : \(url.absoluteString)")
    if url.absoluteString.contains(HandleURLScheme.externalURLSchemeSuccess()) {
        if let topViewController = UserInterfaceInfo.topViewController() {
            if let webViewController = topViewController as? UAEPassWebViewController {
                webViewController.forceReload()
            } 
        }
        return true
    } else if url.absoluteString.contains(HandleURLScheme.externalURLSchemeFail()) {
        guard let webViewController = UserInterfaceInfo.topViewController() as? UAEPassWebViewController  else { return false}
        webViewController.foreceStop()
        let alertController = UIAlertController(title: "Failed to login with UAE PASS Login", message: "Try again later", preferredStyle: .actionSheet)
        let okAction = UIAlertAction(title: "OK", style: UIAlertAction.Style.default) { _ in
            NSLog("OK Pressed")
            webViewController.navigationController?.popViewController(animated: true)
        }
        alertController.addAction(okAction)
        self.window?.rootViewController?.present(alertController, animated: true, completion: nil)
        return false
    }
    return true
}
```

**3- Should do**

* Add UAE Pass scheme in your project info.plist in LSApplicationQueriesSchemes (Already added in this sample): --  -- **Production**: uaepass\
  \-- **STG**: uaepassstg

**For more understanding:**

**Authentication**

* After press on login with UAE PASS button you will be asked to select which environment you would like to use for login through UIAlertController and from this action you can trace how it works.
* from application(\_: UIApplication, handleOpen url: URL) -> Bool in AppDelegate you can force current web view to reload or stop loading incase if success or failure.
* This sample contains three view controllers : -&#x20;

1. \-- ViewController.swift (main screen which contains login button and UIAlertController to select required environment).
2. UserProfileViewController.swift (Just simple view to show user profile details and it contains sign document scenario as well).
3. UAEPassWebViewController.swift (Resposible for handling webView requests to generate UAE PASS code to use it for token generation).

**Signing flow** :

* you should have valid pdf file and in this sample you will be able to see sample code for downloading pdf file.
* Then we have to generate valid token for signing process from your server
* Your backend must fetch this token using your `CLIENT_ID` and `CLIENT_SECRET` and return it to the app.
* **This is NOT the same token used for authentication.**
* Then we have to upload above valid pdf document to UAE PASS.
* After uploading we have to send our request for signing for (signature type (advanced or qualified), on which page signature will be placed, signature coordinates and signature size)

**Check**&#x20;

* testSignData.json is very important file as this is signing info which you should pass to UAE Pass app and it's expected to be received from the back end and it's required to be reconfigured to add your own app scheme

**Note : This sample supports dark mode as well**


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.uaepass.ae/feature-guides/authentication/mobile-application/guide/sdk/ios.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
