Local Notifications fire if scheduled in the foreground. If the app is in the background, local notifications are not scheduled, but I want them to schedule and immediately fire. Posts on this topic discuss how apps in iOS 10+ are suspended quickly and therefore local notifications will not be scheduled, however, apple docs say
You schedule local notifications at a time when your app is running either in the foreground or background.
Does this mean that in iOS 10+, there is no way for local notifications to schedule if the user has closed the app (ie: suspended)? How do "big" apps do it?
I've seen some people consider enabling 'Background Modes.' My app allows people to connect like on social media, and I want the connect 'requests' to prompt the immediate notification. Is this appropriate for enabling Background modes?
Lastly, what is the point of a notification if it cant be sent when the user has the app closed? It sounds like in iOS10+, apps that don't have background modes are either 'in the foreground' or 'suspended.' Therefore, a local notification would never even send unless "shouldAlwaysAlertWhileAppIsForeground" was enabled. Even then, what good is getting a notification only in the foreground.
Just as reference, here is how I schedule local notifications:
let center = UNUserNotificationCenter.current()
center.removeDeliveredNotifications(withIdentifiers: idsToBeCancelled)
let content = UNMutableNotificationContent()
content.title = title
content.body = text
content.categoryIdentifier = category
content.userInfo = map
content.sound = UNNotificationSound.default()
content.setValue("YES", forKeyPath: "shouldAlwaysAlertWhileAppIsForeground")
let request = UNNotificationRequest(identifier: "testing", content: content, trigger: nil)
center.add(request)