O'Reilly logo

Learn iOS 11 Programming with Swift 4 - Second Edition by Craig Clayton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Showing notifications 

Now that we have a time, let's show our notification along with the time selected:

  1. In the RestaurantDetailViewController.swift file, after import LetsEatDataKit, add the following:
import UserNotifications
  1. Next, inside of the showNotification() method, add the following:
let content = UNMutableNotificationContent()if let name = selectedRestaurant?.name { content.title = name }if let time = sender { content.body = "Table for 7, tonight at \(time) " }content.subtitle = "Restaurant Reservation"content.badge = 1content.sound = UNNotificationSound.default()let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 5, repeats: false)let identifier = "letsEatReservation"let request = UNNotificationRequest(identifier: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required