Skip to content

UNNotificationSound ​

UNNotificationSound represents the sound played when a notification arrives. For now there is only the system default one: UNNotificationSound.defaultSound. If you want no sound, leave the content's sound as null.

The sound read from a remotely pushed notification may be a different UNNotificationSound: it indicates that the server specified another sound file, and the file name cannot be read (not verified in the simulator).

It is a plain JS value and does not inherit from NSObject.

Install @nacrejs/user-notifications first; for how, see UNUserNotificationCenter, or Core and capability packages.

Inheritance: UNNotificationSound

Constructor ​

It cannot be created with new. new UNNotificationSound() throws TypeError:

Illegal constructor: UNNotificationSound cannot be constructed; use UNNotificationSound.defaultSound

Static properties ​

UNNotificationSound.defaultSound read-only

The system's default notification sound. Every read returns the same object.

Examples ​

js
const content = new UNMutableNotificationContent();
content.title = 'New message';
content.sound = UNNotificationSound.defaultSound;

Effect: A notification sent with this content plays the system's default notification sound when delivered. Not verified in the simulator.

Corresponding iOS API ​

ObjCJS
UNNotificationSound.defaultSoundUNNotificationSound.defaultSound

See also ​

  • sound: the sound goes in this property of the content