UNNotificationContent: sound property
The sound property is the sound played when the notification is delivered. This is a value read from a request or notification.
Value
A UNNotificationSound, or null.
- Read-only; assigning to it throws
TypeError:sound is read-only. nullif it was never set: no sound.- Usually
UNNotificationSound.defaultSoundornull. - Read from a remote push notification, it may be a
UNNotificationSoundthat isn't equal toUNNotificationSound.defaultSound: this means the server specified a different sound file, whose file name can't be read. Content carrying it can't be used to create a request again;requestWithIdentifier()throwsTypeError(not verified in the simulator). - The content is a copy as of the moment the request was created and doesn't change afterward; there is no change notification.
Examples
js
const content = new UNMutableNotificationContent();
content.title = 'Order shipped';
const request = UNNotificationRequest.requestWithIdentifier('order', { content });
console.log(JSON.stringify(request.content.sound));Result: Prints null. This item was never set, so the default value is read.
Corresponding iOS API
UNNotificationContent.sound.
See also
UNMutableNotificationContent: write this item- This class belongs to the
@nacrejs/user-notificationspackage; for installation, see Installation