Alarm framework 怎么使用
Asked on 2025-06-27
1 search
To use the AlarmKit framework, you can follow these steps as outlined in the session "Wake up to the AlarmKit API" from WWDC 2025:
-
Authorization: Before scheduling alarms, you need to obtain user authorization. You can request authorization manually using the
AlarmManager
'sRequest Authorization
API, or it will be requested automatically when you create your first alarm. Make sure to addNSAlarmKitUsageDescription
to your app's info plist to explain the use case for presenting alarms. -
Creating an Alarm:
- Define the countdown duration and schedule. You can set a fixed schedule with a specific date or a relative schedule with a recurrence pattern.
- Customize the alarm's appearance by creating alert buttons using the
AlarmButton
struct. You can specify text, text color, and system images for these buttons. - Set up the alarm attributes and configuration, including the countdown duration, schedule, and any custom metadata.
-
Managing Alarms: Use the
AlarmManager
class to manage the lifecycle of your alarms. You can schedule, cancel, stop, pause, or resume alarms using their unique identifiers. -
Customizing Actions: You can define custom actions for alarm buttons using app intents. For example, you can create a secondary button that opens your app when tapped.
-
Live Activities: If your alarm supports countdown functionality, implement a live activity to show the countdown UI on the lock screen, dynamic island, and in standby mode.
For more detailed guidance, you can refer to the session Wake up to the AlarmKit API from WWDC 2025.

Wake up to the AlarmKit API
Rrrr-rrrrr-innng! From countdown timers in your recipe app to wake-up alarms in your travel planning app, the AlarmKit framework in iOS and iPadOS 26 brings timers and alarms to the Lock Screen, Dynamic Island, and more. Learn how to create and manage your app’s alarms, customize their Live Activities, and offer custom alert actions using the App Intents framework. To get the most from this video, we recommend first watching “Meet ActivityKit” from WWDC23.

Use CloudKit Console to monitor and optimize database activity
Discover the new observability features in CloudKit Console. Learn how to use Telemetry and Logging to troubleshoot and optimize your app. Find out how to set up alerts to monitor your application’s behavior and notifications to stay on top of the container events that are most important to you. To get the most out of this session, we recommend being familiar with CloudKit containers.