在 React Native 中实现不可停止的后台服务
Implement unstoppable background service in react native
我正在尝试 运行 React Native 中不可停止的后台服务,它将通过 Socket.io 从服务器持续侦听消息。
为此我找到了几个有几个问题的解决方案
- 使用 FCM
The problem with method is that first I have to listen for FCM event than connect to my server and get the data(Messages + images + Videos). And I don't want to use firebase for my app as its expensive and don't want to store my user data (Mainly images) and handle user auth.
- 使用react-native-background-fetch
This thing is pretty good but it only allow to run single job every 5 minutes and if your service is killed by android than you are gone
- 使用Headless JS
To be honest I cannot understand its documentation
请告诉我该怎么办 我很困惑也很惊讶没有合适的方法来处理这个问题
TIA
问候
也许你可以实现一个原生模块java/objective-c
https://facebook.github.io/react-native/docs/native-modules-android
和运行像这样的后台线程
为此,您需要学习 native-modules 和 react-native-bridge 以及 android 和 ios 服务的一些基础知识。
这里是link供大家参考。
我正在尝试 运行 React Native 中不可停止的后台服务,它将通过 Socket.io 从服务器持续侦听消息。
为此我找到了几个有几个问题的解决方案
- 使用 FCM
The problem with method is that first I have to listen for FCM event than connect to my server and get the data(Messages + images + Videos). And I don't want to use firebase for my app as its expensive and don't want to store my user data (Mainly images) and handle user auth.
- 使用react-native-background-fetch
This thing is pretty good but it only allow to run single job every 5 minutes and if your service is killed by android than you are gone
- 使用Headless JS
To be honest I cannot understand its documentation
请告诉我该怎么办 我很困惑也很惊讶没有合适的方法来处理这个问题 TIA 问候
也许你可以实现一个原生模块java/objective-c https://facebook.github.io/react-native/docs/native-modules-android
和运行像这样的后台线程
为此,您需要学习 native-modules 和 react-native-bridge 以及 android 和 ios 服务的一些基础知识。 这里是link供大家参考。