Skip to content

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:

PropertyDefault
title, subtitle, body, threadIdentifier''
badgenull
soundnull
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 yet

Examples ​

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 ​