Skip to content

Conversation

@codebymini
Copy link
Collaborator

@codebymini codebymini commented Nov 23, 2025

Add Bluetooth/CarPlay Play-Pause Button Snooze Support

Summary

This PR adds the ability to snooze active alarms using the play/pause button on Bluetooth headphones, speakers, and CarPlay interfaces. This provides a convenient hands-free way to snooze alarms, especially useful while driving or when the phone is not easily accessible.

What's New

  • Bluetooth Button Support: Users can now snooze alarms by pressing the play/pause button on their Bluetooth devices
  • CarPlay Integration: The same functionality works seamlessly with CarPlay controls
  • Enhanced Accessibility: Provides an alternative to physical volume buttons for snoozing alarms

Technical Changes

VolumeButtonHandler.swift
Added MPRemoteCommandCenter integration to handle media control commands
Implemented handlers for three command types:

  • pauseCommand - handles pause button presses
  • playCommand - handles play button presses
  • togglePlayPauseCommand - handles toggle button (common on many Bluetooth devices)
    Added setupRemoteCommandCenter() to configure command handlers when monitoring starts
    Added disableRemoteCommandCenter() to properly clean up when monitoring stops
    All commands respect the same activation delay and cooldown period as volume button snoozing
    Added comprehensive logging for debugging Bluetooth interactions
    Simplified audio session configuration by removing deprecated API usage
    Replaced convertFromAVAudioSessionCategory() calls with modern .playback category syntax
    Removed .mixWithOthers option to ensure alarms have full audio control
    Added logging for audio session configuration

Behavior

Remote commands follow the same timing rules as volume buttons:
Activation delay after alarm starts (prevents accidental snoozes)
Cooldown period between presses (prevents multiple rapid snoozes)
Works with any Bluetooth audio device that sends media control commands
Audio route information is logged to help with debugging connectivity issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants