---
title: iOS कैप्चर
description: Human Plugin create से लौटे लिंक का उपयोग करके, ASWebAuthenticationSession के साथ iOS ऐप में Journey flow का कैप्चर चलाएं।
canonical: https://developer.unico.io/hi/human-plugin/integrations/ios
locale: hi
generated_by: markdown-export
---

# iOS कैप्चर

कैप्चर को सिस्टम ब्राउज़र सेशन में खोलें और व्यक्ति को आपके ऐप में वापस लाएं।

आपका बैक-एंड Human Plugin में Journey flow और ऐसे `callbackUri` के साथ process बनाता है जो आपके ऐप की URL scheme का उपयोग करता है। ऐप जवाब के `link` को `ASWebAuthenticationSession` में खोलता है। कैप्चर समाप्त होने पर, सेशन आपकी scheme के ज़रिए ऐप में लौट आता है।

create के जवाब से Human Plugin का `id` रखें। आपका बैक-एंड उसी से नतीजा पढ़ता है।

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

- iOS 13 या बाद का
- Xcode 14 या बाद का
- `AuthenticationServices` फ्रेमवर्क (अंतर्निहित)
- आपके ऐप की अपनी यूनीक URL scheme, जैसे `myapp`

## 1. अपनी scheme के साथ process बनाएं

आपका बैक-एंड scheme को `callbackUri` के रूप में भेजता है:

```json
{
  "flow": "humantoken",
  "clientId": "client-a",
  "correlationId": "order-1001",
  "credential": { "type": "DUI_TYPE_NG_BVN", "value": "<document number>" },
  "callbackUri": "myapp://callback"
}
```

और `id` तथा `link` ऐप को लौटाता है।

## 2. presentation context provider बनाएं

```swift
import AuthenticationServices
import UIKit

class CaptureContextProvider: 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 CaptureSessionManager {
    static let shared = CaptureSessionManager()
    private var session: ASWebAuthenticationSession?
    private let contextProvider = CaptureContextProvider()

    /// Calls completion with true when the capture ended, false when the person closed it.
    func start(link: URL, completion: @escaping (Bool) -> Void) {
        let newSession = ASWebAuthenticationSession(
            url: link,
            callbackURLScheme: "myapp"
        ) { callbackURL, _ in
            self.session = nil
            completion(callbackURL != nil)
        }
        newSession.presentationContextProvider = contextProvider
        newSession.prefersEphemeralWebBrowserSession = true
        newSession.start()
        session = newSession
    }
}
```

> **जानकारी:** `callbackURLScheme` में केवल scheme का नाम (`myapp`) दें, `://` के बिना।

## 4. कैप्चर शुरू करें

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

CaptureSessionManager.shared.start(link: url) { ended in
    if ended {
        // The capture ended. Ask your back-end to read the outcome
        // with GET /v1/processes/{id}, using the Human Plugin id.
    } else {
        // The person closed the session.
    }
}
```

## सारांश

| फ़ाइल | उद्देश्य |
|---|---|
| `CaptureContextProvider.swift` | Presentation context provider |
| `CaptureSessionManager.swift` | `ASWebAuthenticationSession` का लाइफ़साइकल |

```mermaid
sequenceDiagram
  participant A as Your app
  participant B as Your back-end
  participant H as Human Plugin
  participant S as Browser session
  A->>B: start the capture
  B->>H: POST /v1/processes (Journey flow, callbackUri myapp://callback)
  H-->>B: 201, id + link
  B-->>A: id + link
  A->>S: open link
  Note over S: capture
  S-->>A: myapp://callback
  A->>B: capture ended (id)
  B->>H: GET /v1/processes/{id}
  H-->>B: 200, final state
```