You can send pushes by the last connection, or you can run local notifications. For example, if the user has turned off the application, run the notification,
func applicationDidEnterBackground(_ application: UIApplication) { let content = UNMutableNotificationContent() content.title = "Notification" content.body = "Sample" let trigger = UNTimeIntervalNotificationTrigger.init(timeInterval: 5.0, repeats: false) //покажет через 5 секунд let request = UNNotificationRequest(identifier:requestIdentifier, content: content, trigger: trigger) UNUserNotificationCenter.current().add(request){(error) in if (error != nil){ print(error?.localizedDescription ?? "") } } }
if the user has opened the application, we kill it.
func applicationDidBecomeActive(_ application: UIApplication) { UNUserNotificationCenter.current().removePendingNotificationRequests(withIdentifiers: [requestIdentifier]) }
If you did not run a specific time, it is shown.
GitHub Example