---
title: Ionic
description: Capacitor 플러그인을 사용하여 Ionic 앱에 Human Token Journey를 통합하세요 — Android에서는 Custom Tabs, iOS에서는 ASWebAuthenticationSession.
canonical: https://developer.unico.io/ko/human-token/integrations/app/ionic
locale: ko
generated_by: markdown-export
---

- [/ko/](/ko/)
- [통합](/ko/human-token/integrations)
- 앱
- Ionic

**이 페이지에서IonicCapacitor 플러그인을 사용하여 Ionic 앱에 Human Token Journey를 통합하세요.

통합은 Android에서는 Custom Tabs, iOS에서는 `ASWebAuthenticationSession`에 위임하는 로컬 Capacitor 플러그인을 사용합니다. 여정이 완료되면 딥 링크가 `@capacitor/app`을 통해 돌아옵니다.
### 사전 요구 사항​

Ionic(Capacitor v4+)
`@capacitor/app` 설치됨
Xcode 14+ 및 Android Studio
앱의 고유한 URL 스킴 (예: `myapp`)

### 단계 1: URL 스킴 정의​

고유한 스킴을 선택하세요 (예: `myapp`). 프로세스 생성 시 `callbackUri`로 사용됩니다:
```
callbackUri: myapp://callback
```

### 단계 2: Capacitor 플러그인 인터페이스 생성​

```
import { registerPlugin } from '@capacitor/core';export interface UnicoPlugin {  openSession(options: { url: string }): Promise<{ callbackUrl: string }>;}const Unico = registerPlugin<UnicoPlugin>('UnicoPlugin');export default Unico;
```

### 단계 3: iOS 플러그인 구현​

```
import Capacitorimport AuthenticationServices@objc(UnicoPlugin)public class UnicoPlugin: CAPPlugin, ASWebAuthenticationPresentationContextProviding {    private var session: ASWebAuthenticationSession?    @objc func openSession(_ call: CAPPluginCall) {        guard let urlString = call.getString("url"),              let url = URL(string: urlString) else {            call.reject("Invalid URL")            return        }        DispatchQueue.main.async {            let newSession = ASWebAuthenticationSession(                url: url,                callbackURLScheme: "myapp"            ) { callbackURL, error in                self.session = nil                if let callbackURL = callbackURL {                    call.resolve(["callbackUrl": callbackURL.absoluteString])                } else {                    call.reject(error?.localizedDescription ?? "Session cancelled")                }            }            newSession.presentationContextProvider = self            newSession.prefersEphemeralWebBrowserSession = true            newSession.start()            self.session = newSession        }    }    public 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    }}
```

### 단계 4: Android 플러그인 구현​

```
import android.content.Intentimport android.net.Uriimport androidx.browser.customtabs.CustomTabsIntentimport com.getcapacitor.Pluginimport com.getcapacitor.PluginCallimport com.getcapacitor.PluginMethodimport com.getcapacitor.annotation.CapacitorPlugin@CapacitorPlugin(name = "UnicoPlugin")class UnicoPlugin : Plugin() {    private var pendingCall: PluginCall? = null    @PluginMethod    fun openSession(call: PluginCall) {        val url = call.getString("url") ?: return call.reject("Missing URL")        pendingCall = call        activity.runOnUiThread {            CustomTabsIntent.Builder().build()                .launchUrl(activity, Uri.parse(url))        }    }    override fun handleOnNewIntent(intent: Intent) {        super.handleOnNewIntent(intent)        intent.data?.let { uri ->            if (uri.scheme == "myapp") {                pendingCall?.resolve(com.getcapacitor.JSObject().put("callbackUrl", uri.toString()))                pendingCall = null            }        }    }}
```

### 단계 5: URL 스킴 구성​

iOSAndroid`Info.plist`에 추가:```
<key>CFBundleURLTypes</key><array>    <dict>        <key>CFBundleURLSchemes</key>        <array>            <string>myapp</string>        </array>    </dict></array>
```

메인 `<activity>` 내부의 `AndroidManifest.xml`에 추가:```
<intent-filter>    <action android:name="android.intent.action.VIEW" />    <category android:name="android.intent.category.DEFAULT" />    <category android:name="android.intent.category.BROWSABLE" />    <data android:scheme="myapp" android:host="callback" /></intent-filter>
```

`build.gradle`에 추가:```
implementation("androidx.browser:browser:1.5.0")
```

### 단계 6: Angular 서 비스 생성​

```
import { Injectable } from '@angular/core';import Unico from '../plugins/unico-plugin';@Injectable({ providedIn: 'root' })export class UnicoService {  async openSession(url: string): Promise<string | null> {    try {      const result = await Unico.openSession({ url });      const params = new URL(result.callbackUrl).searchParams;      return params.get('id');    } catch {      return null;    }  }}
```

### 단계 7: 딥 링크 리스닝​

`AppComponent`에서:
```
import { App } from '@capacitor/app';App.addListener('appUrlOpen', (event) => {  // Handle the callback URL if needed  console.log('Deep link received:', event.url);});
```

### 파일 요약​

파일목적`unico-plugin.ts`Capacitor 플러그인 인터페이스`UnicoPlugin.swift`iOS — ASWebAuthenticationSession`UnicoPlugin.kt`Android — Custom Tabs`Info.plist`iOS URL 스킴`AndroidManifest.xml`Android Intent 필터`unico.service.ts`Angular 서비스 래퍼마지막 업데이트 2026년 10월 21일**에