@capgo/capacitor-알람을 사용합니다.
Capacitor 알람 플러그인은 네이티브 OS 알람 관리를 위한 인터페이스입니다.
설치
bun add @capgo/capacitor-alarm
bunx cap sync
bunx cap sync code의 네이티브 코드를 프로젝트에 복사합니다. 플러그인 업그레이드 후 다시 실행하세요.
수입
import { CapgoAlarm } from '@capgo/capacitor-alarm';
API의 개요
| 방법 | 설명 |
|---|---|
createAlarm |
Android 및 iOS 플랫폼의 시계 앱을 사용하여 네이티브 OS 알람을 생성합니다. Android에서는 알람 클록 인텐트를 사용하고 iOS에서는 iOS 16 이상에서 사용 가능한 알람 키트를 사용합니다. |
openAlarms |
OS의 네이티브 알람 목록 UI를 열어보세요. (가능한 경우) |
getOSInfo |
OS 및 기능에 대한 정보를 가져오세요. |
requestPermissions |
알람 사용을 위한 관련 권한을 요청하세요. Android에서는 정확한 알람을 위해 설정으로 라우팅할 수 있습니다. |
checkPermissions |
네이티브 알람 접근을 위한 현재 권한 상태를 확인하세요. iOS에서는 알람 키트 준비 상태를, Android에서는 기능 세부 정보를 보고합니다. |
getAlarms |
Get a list of alarms scheduled by this app. On iOS 26+, returns alarms from AlarmKit. On Android, this is not supported as the system does not provide an API to query alarms. |
cancelAlarm |
알람 ID를 사용하여 예약된 알람을 취소하세요. iOS 26 이상에서는 알람 키트에서 알람을 제거합니다. Android/web에서는 지원되지 않습니다. |
예시
createAlarm()
Android 및 iOS 플랫폼의 시계 앱을 사용하여 네이티브 OS 알람을 생성합니다. Android에서는 알람 클록 인텐트를 사용하고 iOS에서는 iOS 16 이상에서 사용 가능한 알람 키트를 사용합니다.
import { CapgoAlarm } from '@capgo/capacitor-alarm';
const result = await CapgoAlarm.createAlarm({
hour: 7,
minute: 30,
label: 'Wake up',
skipUi: false,
vibrate: true
});
console.log('Alarm created:', result.success);
openAlarms()
OS의 네이티브 알람 목록 UI를 열어보세요. (가능한 경우)
import { CapgoAlarm } from '@capgo/capacitor-alarm';
const result = await CapgoAlarm.openAlarms();
if (result.success) {
console.log('Alarms UI opened');
}
getOSInfo()
OS 및 기능에 대한 정보를 가져오세요.
import { CapgoAlarm } from '@capgo/capacitor-alarm';
const info = await CapgoAlarm.getOSInfo();
console.log('Platform:', info.platform);
console.log('Supports native alarms:', info.supportsNativeAlarms);
if (info.platform === 'android') {
console.log('Can schedule exact alarms:', info.canScheduleExactAlarms);
}
requestPermissions()
알람 사용을 위해 플랫폼에서 관련된 권한을 요청하세요. 안드로이드에서는 정확한 알람을 위해 설정으로 라우팅할 수 있습니다.
import { CapgoAlarm } from '@capgo/capacitor-alarm';
const result = await CapgoAlarm.requestPermissions({ exactAlarm: true });
if (result.granted) {
console.log('Permissions granted');
} else {
console.log('Permissions denied');
}
checkPermissions()
native 알람 접근 권한의 현재 상태를 확인하세요. iOS에서는 알람 킷의 준비 상태를, 안드로이드에서는 기능 상세를 보고합니다.
import { CapgoAlarm } from '@capgo/capacitor-alarm';
const status = await CapgoAlarm.checkPermissions();
console.log('AlarmKit allowed?', status.details?.alarmKit);
getAlarms()
이 앱에서 설정된 알람 목록을 가져오세요. iOS 26 이상에서는 알람 킷에서 알람을 반환합니다. 안드로이드에서는 지원되지 않으며 시스템이 알람을 조회하는 API을 제공하지 않습니다.
import { CapgoAlarm } from '@capgo/capacitor-alarm';
const { alarms } = await CapgoAlarm.getAlarms();
console.log('Scheduled alarms:', alarms);
alarms.forEach(alarm => {
console.log(`Alarm ${alarm.id}: ${alarm.hour}:${alarm.minute} - ${alarm.label}`);
});
위 표에는 7개의 핵심 메서드가 나열되어 있습니다. 리스너 및 버전 헬퍼, 각 메서드의 전체 계약은 __CAPGO_KEEP_0__ repository에서 문서화되어 있습니다. GitHub.
전체 참조
Using @capgo/capacitor-alarm
Using @__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-alarm @Capacitor-capgo/capacitor-alarm native 플러그인 작업을 계획하기 위해, 그것을 연결하세요. @capgo/capacitor-알람 @capgo/capacitor-알람의 구현 세부 사항 시작하기 시작하기의 구현 세부 사항 Capgo 플러그인 디렉토리 Capgo 플러그인 디렉토리의 제품 워크플로 Capacitor 플러그인들에 의해 Capgo Capacitor 플러그인들에 의해 Capgo의 구현 세부 사항 플러그인 추가 또는 업데이트 플러그인 추가 또는 업데이트의 구현 세부 사항