Here's an example code snippet in Swift for generating a banner notification with a string body:
main.swift749 chars22 linesThis code imports the UserNotificationsframework and requests authorization for notifications. Then, it creates a UNMutableNotificationContentobject with a title and body text. Finally, it sets up a UNNotificationRequestwith a trigger and identifier, and adds it to the notification center using center.add().
gistlibby LogSnag