Skip to content

UNNotificationSettings: carPlaySetting property ​

The carPlaySetting property indicates whether the setting for showing on CarPlay (the in-car screen) 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: carPlaySetting 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 'carPlay' 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.carPlaySetting === 'enabled' ? 'On' : 'Off');

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

Corresponding iOS API ​

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

See also ​