가이드
Capacitor에서 App Intents 사용하는 법
@capgo/capacitor-app-intents 사용하기
Capgo App Intents 플러그인 인터페이스
설치
bun add @capgo/capacitor-app-intents
bunx cap sync
bunx cap sync 플러그인의 네이티브 code를 네이티브 프로젝트에 복사합니다. 플러그인을 업그레이드할 때마다 다시 실행하세요.
가져오기
import { CapgoAppIntents } from '@capgo/capacitor-app-intents';
API 한눈에 보기
| 메서드 | 설명 |
|---|---|
getPendingInvocations |
JavaScript가 준비되기 전에 대기열에 쌓인 호출을 반환합니다. |
removePendingInvocation |
핸들러에서 처리를 완료한 후 대기 중인 호출 하나를 제거합니다. |
setEntityCatalog |
지정된 타입 문자열에 대한 엔티티 카탈로그를 영구 저장합니다. |
setHomeScreenShortcutItems |
홈 화면 퀵 액션(UIApplicationShortcutItems)을 교체합니다. |
indexSpotlightEntities |
앱 도메인의 Spotlight 항목을 인덱싱합니다. |
removeSpotlightEntities |
Spotlight 항목을 ID로 삭제합니다. |
performAppleSchemaTemplate |
알파 Apple 스키마 템플릿용 JavaScript 핸들러를 큐에 추가합니다. |
예시
getPendingInvocations()
JavaScript가 준비되기 전에 대기열에 쌓인 호출을 반환합니다.
import { CapgoAppIntents } from '@capgo/capacitor-app-intents';
const result = await CapgoAppIntents.getPendingInvocations();
console.log(result);
removePendingInvocation()
핸들러에서 처리를 완료한 후 대기 중인 호출 하나를 제거합니다.
import { CapgoAppIntents } from '@capgo/capacitor-app-intents';
await CapgoAppIntents.removePendingInvocation({ id: 'id-123' });
setEntityCatalog()
지정된 타입 문자열에 대한 엔티티 카탈로그를 영구 저장합니다.
import { CapgoAppIntents } from '@capgo/capacitor-app-intents';
await CapgoAppIntents.setEntityCatalog({
type: 'type',
entries: [
{
id: 'id-123',
title: 'Hello from Capacitor',
},
],
});
setHomeScreenShortcutItems()
홈 화면 퀵 액션(UIApplicationShortcutItems)을 교체합니다.
import { CapgoAppIntents } from '@capgo/capacitor-app-intents';
await CapgoAppIntents.setHomeScreenShortcutItems({
items: [
{
type: 'type',
title: 'Hello from Capacitor',
},
],
});
indexSpotlightEntities()
앱 도메인의 Spotlight 항목을 인덱싱합니다.
import { CapgoAppIntents } from '@capgo/capacitor-app-intents';
await CapgoAppIntents.indexSpotlightEntities({
entities: [
{
id: 'id-123',
title: 'Hello from Capacitor',
actionName: 'action',
},
],
});
removeSpotlightEntities()
Spotlight 항목을 ID로 삭제합니다.
import { CapgoAppIntents } from '@capgo/capacitor-app-intents';
await CapgoAppIntents.removeSpotlightEntities({ ids: ['ids'] });
위 표에는 7가지 핵심 메서드가 나와 있습니다. 리스너와 버전 헬퍼, 각 메서드의 전체 스펙은 다음 문서에 정리되어 있습니다. GitHub 리포지토리.
이벤트 수신
addListener 핸들을 반환합니다. 호출하세요 handle.remove() 화면이 언마운트될 때, 또는 CapgoAppIntents.removeAllListeners() 모든 리스너를 해제하려면.