Skip to content

UNNotificationSettings: criticalAlertSetting property ​

The criticalAlertSetting property indicates whether the critical alerts setting — ignoring the mute switch and Do Not Disturb — is currently on.

Value ​

A string, one of the three states (see Three states): 'enabled' (on), 'disabled' (off), 'notSupported' (this app doesn't have this setting: it was never requested, or the device doesn't support it).

  • Read-only. Assigning to it throws TypeError: criticalAlertSetting is read-only.
  • This is a snapshot from the moment the settings were fetched. If the user later changes it in the system Settings app, this value doesn't change; there is no event when settings change either. Call getNotificationSettings() again when the user returns to the app (the active event on application).
  • Corresponds to 'criticalAlert' when requesting authorization.
  • The values in each situation are not verified in the simulator.

Examples ​

js
const center = UNUserNotificationCenter.currentNotificationCenter();
const settings = await center.getNotificationSettings();
console.log(settings.criticalAlertSetting === 'enabled' ? 'On' : 'Off');

Effect: It prints On when this setting is on, otherwise Off. Not verified in the simulator.

Corresponding iOS API ​

UNNotificationSettings.criticalAlertSetting. UNNotificationSettingEnabled is written 'enabled', and the rest likewise.

See also ​