Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect application termination with react native

Is there a way to detect when a react-native application will terminate?

I was thinking of componentWillUnmount at the main component level, do you think that's best way to do it?

I would like to send a "Save" request to the server before. I'm not sure if that's appropriate while the application in terminating, any better suggestion?

Thanks

like image 652
alexmngn Avatar asked May 11 '16 03:05

alexmngn


1 Answers

According to https://github.com/facebook/react-native/issues/9348, it is not possible to do any cleanup on the JS side, you need to do it natively with applicationWillTerminate (which also means sync stuff between js and native code). I have an issue with my app terminating while running in the background, and I'm really looking forward to finding an explanation on how to do that.

like image 51
Jeremie Avatar answered Sep 19 '22 15:09

Jeremie