当App被当地人杀死时,如何调用API? [英] How to call API when App is killed in react native?

查看:133
本文介绍了当App被当地人杀死时,如何调用API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在应用终止时在后台调用API并在AsyncStorage中设置数据.我使用了以下库,但对我不起作用.

I Want to call API in the background when App killed and set the data in AsyncStorage. I used the following library but not working for me.

react-native-background-task

react-native-background-task

react-native-background-fetch

react-native-background-fetch

我想在没有时间安排的情况下调用API.上面两者都使用时间计划.

I want to called the API without time scheduling. The above both use the time Scheduling.

请帮助我.

推荐答案

您需要在应用程序的根目录上实现componentWillUnmount方法,或者使用诸如realm之类的库来保存应用程序使用过程中的状态.

You would need to implement the componentWillUnmount method on the root of your app or use a library like realm to save the state throughout the use of your app.

也许值得检查一下 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆