Updated to work with Xcode 13 and Swift 5.
The UserNotifications framework was introduced with iOS 10 and has been designed to work with iOS, tvOS, and watchOS, and replaces UILocalNotification from the UIKit framework. UILocalNotification and other variants were deprecated in iOS 10.
If you want to send a notification to the lock screen of an iPhone, using the UserNotifications framework is now the way to go.
In this tutorial we’ll look at how to get a basic notification on to the lock screen. In the next tutorial, we’ll look at all the other parts that we do not cover here such as being able to put a notification on screen based on location; without using the CoreLocation framework, and we’ll also look at how to handle specific notifications so that we know which one was tapped or swiped.
[Read more…]