[Solved] How can i convert this code to swift 4? [closed]


UILocalNotification is deprecated. Try this code:

    let gregCalrendar = Calendar(identifier: .gregorian)
    var dateComponent = gregCalrendar.dateComponents([.year, .month, .day, .hour, .minute], from: Date())

    dateComponent.year = 2012
    dateComponent.month = 9
    dateComponent.day = 28
    dateComponent.hour = 16
    dateComponent.minute = 11

    let dd = UIDatePicker()
    dd.setDate(gregCalrendar.date(from: dateComponent)!, animated: true)

    let content = UNMutableNotificationContent()
    content.title = "UMUT CAN ALPARSLAN"

    let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponent, repeats:false)
    let request = UNNotificationRequest(identifier: "uniqueId", content: content, trigger: trigger)

    UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)

Also you need to add import UserNotifications on the top

solved How can i convert this code to swift 4? [closed]