---
title: iOS
description: قم بدمج رحلة Human Token في تطبيق iOS الخاص بك باستخدام ASWebAuthenticationSession — أصلي وآمن وبدون الحاجة إلى WebView.
canonical: https://developer.unico.io/ar/human-token/integrations/app/ios
locale: ar
generated_by: markdown-export
---

- [/ar/](/ar/)
- [التكاملات](/ar/human-token/integrations)
- التطبيق
- iOS

**في هذه الصفحةiOSقم بدمج رحلة Human Token في تطبيق iOS الخاص بك باستخدام ASWebAuthenticationSession.

يقوم `ASWebAuthenticationSession` بتشغيل رحلة Human Token في متصفح يديره النظام. عند انتهاء الرحلة، تعود الجلسة إلى تطبيقك عبر مخطط URL المسجل.
### المتطلبات الأساسية​

iOS 13 أو أحدث
Xcode 14+
إطار عمل `AuthenticationServices` (مدمج)
مخطط URL فريد لتطبيقك (مثل `myapp`)

### الخطوة 1: تحديد مخطط URL الخاص بك​

اختر مخططًا فريدًا (مثل `myapp`). يُستخدم هذا كـ `callbackUri` عند إنشاء العملية:
```
callbackUri: myapp://callback
```

### الخطوة 2: إنشاء مزود سياق العرض​

```
import AuthenticationServicesimport UIKitclass 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: إنشاء مدير الجلسة​

```
import AuthenticationServicesclass 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: بدء الرحلة​

```
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`آخر تحديث في 21 أكتوبر 2026**