Reputation: 992
I have tried sending a local notification when my App willTerminate, but this does not seem to schedule my local notification. Any thoughts on how I might make achieve this?
My current setup:
.onReceive(NotificationCenter.default.publisher(for: UIApplication.willTerminateNotification), perform: { _ in
sendLocalNotification()
})
Upvotes: 2
Views: 182
Reputation: 535159
You generally have no way of knowing when your app is about to be terminated. UIApplication.willTerminateNotification
is usually not sent to you. Typically you go into the background, the app is suspended (frozen), and dies in its sleep (because the system needs the memory you're using). You should assume, therefore, that if the app goes into the background, it might be terminated, so if there is something to do, do it then, because if it is terminated you won't get any more code to run.
Upvotes: 2