Send Custom Notifications from Apex

Use the Messaging.CustomNotification class to create, configure, and send custom notifications directly from Apex code, such as a trigger.

Where: This change applies to Enterprise, Performance, Unlimited, and Developer editions.

Why: Rather than make API callouts from Apex, use CustomNotification to send notifications. It requires fewer lines of code, and avoids API callout and authentication complexity. It’s also more efficient, which is especially helpful when you’re sending notifications from triggers, or sending many notifications.

How: Using the Messaging.CustomNotification class to create and send custom notifications from Apex is easy. Create a new instance of CustomNotification, configure a few notification details, and call the send() method.