Reputation: 6742
I want to run some code and then send a notification accordingly, after the user closes my ios app manually ... how can I do that in react-native?
Any help is very much appreciated.
Upvotes: 1
Views: 851
Reputation: 13791
This question and any answer is not really specific to React Native.
It is not possible to detect when the system or the user kills your app unless you opt out of multitasking with an Info.plist
key. If you do that, the system terminates your app any time the user presses the home button and calls your app delegate's applicationWillTerminate(_:)
function.
You probably don't want to opt out of multitasking, though, so your best bet is to schedule a local notification whenever the app transitions into the background and cancel that notification when it transitions back into the foreground. This isn't quite what you asked (your app may or may not have been terminated), but it's as close as you can get.
Upvotes: 2