Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- UIApplication.shared.setMinimumBackgroundFetchInterval(30)
- func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
- debugPrint("New notification fired from AppDelegate...!!")
- let notif = UNMutableNotificationContent()
- notif.title = "New notification from App delegate"
- notif.subtitle = "Cool App!"
- notif.body = "I liked it!"
- UNUserNotificationCenter.current().requestAuthorization(options: [.sound, .badge, .alert], completionHandler: { (isGranted, error) in
- DispatchQueue.main.async {
- let notifTrigger = UNTimeIntervalNotificationTrigger(timeInterval: 0.1, repeats: false)
- let request = UNNotificationRequest(identifier: "myNotification", content: notif, trigger: notifTrigger)
- UNUserNotificationCenter.current().add(request) { (error) in
- if error != nil{
- print(error!)
- } else {
- // do something
- }
- }
- }
- })
- }
Add Comment
Please, Sign In to add comment