In a previous tutorial, we looked at how to send a local notification. Using the basic code provided by Apple you can trigger notifications to fire almost immediately as well as at a specified date and time in the future. In this tutorial we’ll expand on this by looking at the associated delegate protocol; UNUserNotificationCenterDelegate; which allows us to detect which notification was swiped, and also detect when a notification is triggered when the app is in the foreground. To begin, download the project from here which we created in the last tutorial.[Read more…]
How to Use the UserNotifications Framework
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…]