Skip to main content

Other alarms

Last updated: April 3, 2026 | 1 minute read

Receive alerts for environmental changes such as entering or exiting tunnels, transitions between day and night, and country border crossings.

Tunnel events

Implement alarmContextOnTunnelEntered(_:) and alarmContextOnTunnelLeft(_:) to receive notifications when entering or exiting a tunnel:

func alarmContext(onTunnelEntered alarmContext: AlarmContext) {
print("Tunnel entered")
}

func alarmContext(onTunnelLeft alarmContext: AlarmContext) {
print("Tunnel left")
}

Day and night transitions

Receive notifications when your location transitions between day and night based on geographical region and seasonal changes:

func alarmContext(onEnterDayMode alarmContext: AlarmContext) {
print("Day mode entered")
}

func alarmContext(onEnterNightMode alarmContext: AlarmContext) {
print("Night mode entered")
}

Country border crossings

Receive notifications when the user crosses a country border:

func alarmContext(_ alarmContext: AlarmContext, onCountryLeft countryCode: String) {
print("Left country: \(countryCode)")
}

func alarmContext(_ alarmContext: AlarmContext, onCountryEntered code: String) {
print("Entered country: \(code)")
}

Country codes are provided in ISO 3166-1 alpha-3 format.