I already knew about this code which can be used before iOS 10:
func application(_ application: UIApplication, didReceive notification: UILocalNotification) {
}
However, it's depreciated so I just want to ask is there any method that is equivalent to the UserNotifications
framework or I just have to get by with this warning?
Note that I want the app to do something when app is in the background or is terminated.
The deprecated method was notifying delegate when the app received notification while in foreground. Now UNUserNotificationCenterDelegate
does the same thing:
func userNotificationCenter(
UNUserNotificationCenter,
willPresent: UNNotification,
withCompletionHandler: @escaping (UNNotificationPresentationOptions) -> Void
)
Called when a notification is delivered to a foreground app.