Ankur Sardar
Ankur Sardar

Reputation: 425

BackHandler.exitApp() is not closing the services of react-native android app

When I am using BackHandler.exitApp() to close the app and not removing the app from task manager window of the android, when I am again opening the app, it seems before it starts the service init, it start to call service functions. So as a result, I am doing init of this.db = new Datastore({ filename: dbPath, autoload: true, ...options }); , But before it happens the database service is already trying to use this.db, so, as a result, it is saying this.db as undefined.

Can anyone tell me how can I do the init first and then start the services everytime I open the app? Or how can I exit a react native app with completely kill all the tasks?

Upvotes: 1

Views: 5227

Answers (1)

Ankur Sardar
Ankur Sardar

Reputation: 425

I solved this by this module react-native-exit-app - https://www.npmjs.com/package/react-native-exit-app

It closes the app completely.

But it would be great if someone can explain the question.

Upvotes: 1

Related Questions