UNMutableNotificationContent() constructor
The UNMutableNotificationContent() constructor creates empty notification content, for writing fields such as the title and body.
Syntax
new UNMutableNotificationContent()Parameters
None.
Return value
A new UNMutableNotificationContent. The default value of each field:
| Property | Default |
|---|---|
title, subtitle, body, threadIdentifier | '' |
badge | null |
sound | null |
userInfo | {} |
Other fields cannot be added to the created object: adding a field to it in strict mode throws TypeError.
Exceptions
TypeError
Subclassing it and then constructing (new MyContent() after class MyContent extends UNMutableNotificationContent {}):
Illegal constructor: MyContent extends UNMutableNotificationContent, but subclassing native classes is not supported yetExamples
js
const content = new UNMutableNotificationContent();
content.title = 'Time to drink some water';
console.log(content.title, content.badge);Result: Prints Time to drink some water null.
Corresponding iOS API
-[UNMutableNotificationContent init].
See also
UNNotificationRequest.requestWithIdentifier(): creating a request from content- This class belongs to the
@nacrejs/user-notificationspackage; for how to install it, see Install first