---
title: iOS
description: ASWebAuthenticationSession का उपयोग करके अपने iOS ऐप में Human Token Journey को एकीकृत करें — नेटिव, सुरक्षित और बिना WebView के।
canonical: https://developer.unico.io/hi/human-token/integrations/app/ios/link-integration
locale: hi
generated_by: markdown-export
---

# iOS

ASWebAuthenticationSession का उपयोग करके अपने iOS ऐप में Human Token Journey को एकीकृत करें।

`ASWebAuthenticationSession` सिस्टम-प्रबंधित ब्राउज़र में Human Token Journey लॉन्च करता है। जब यात्रा पूरी होती है, तो सत्र पंजीकृत URL स्कीम के माध्यम से आपके ऐप में वापस आता है।

### पूर्वापेक्षाएँ

- iOS 13 या बाद का
- Xcode 14+
- `AuthenticationServices` फ्रेमवर्क (बिल्ट-इन)
- आपके ऐप के लिए एक अद्वितीय URL स्कीम (जैसे `myapp`)

### चरण 1: अपना URL स्कीम परिभाषित करें

एक अद्वितीय स्कीम चुनें (जैसे `myapp`)। प्रोसेस बनाते समय इसे `callbackUri` के रूप में उपयोग किया जाता है:

```
callbackUri: myapp://callback
```

### चरण 2: प्रेजेंटेशन कॉन्टेक्स्ट प्रोवाइडर बनाएँ

```swift
import AuthenticationServices
import UIKit

class UnicoAuthenticationController: NSObject, ASWebAuthenticationPresentationContextProviding {
    func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
        guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
              let window = windowScene.windows.first else {
            return ASPresentationAnchor()
        }
        return window
    }
}
```

### चरण 3: सेशन मैनेजर बनाएँ

```swift
import AuthenticationServices

class AuthenticationSessionManager {
    static let shared = AuthenticationSessionManager()
    private var session: ASWebAuthenticationSession?
    private let contextProvider = UnicoAuthenticationController()

    func start(url: URL, completion: @escaping (String?) -> Void) {
        let newSession = ASWebAuthenticationSession(
            url: url,
            callbackURLScheme: "myapp"
        ) { callbackURL, error in
            self.session = nil
            if let callbackURL = callbackURL {
                let components = URLComponents(url: callbackURL, resolvingAgainstBaseURL: false)
                let processId = components?.queryItems?.first(where: { $0.name == "id" })?.value
                completion(processId)
            } else {
                completion(nil)
            }
        }
        newSession.presentationContextProvider = contextProvider
        newSession.prefersEphemeralWebBrowserSession = true
        newSession.start()
        session = newSession
    }
}
```

### चरण 4: यात्रा शुरू करें

```swift
guard let url = URL(string: processLink) else { return }

AuthenticationSessionManager.shared.start(url: url) { processId in
    if let processId = processId {
        // Journey completed — send processId to your backend via Get Process
    } else {
        // User canceled the session
    }
}
```

> **जानकारी:** `callbackURLScheme` पैरामीटर केवल स्कीम नाम (`myapp`) लेता है, `://` के बिना।

### फ़ाइल सारांश

| फ़ाइल | उद्देश्य |
|---|---|
| `UnicoAuthenticationController.swift` | प्रेजेंटेशन कॉन्टेक्स्ट प्रोवाइडर |
| सेशन मैनेजर (आपका व्यू या सर्विस) | `ASWebAuthenticationSession` लाइफसाइकल |