react-native android上的后台服务 [英] Background service on react-native android

查看:278
本文介绍了react-native android上的后台服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以在Android上使用react-native创建后台服务吗? 我想要一种计时器,该计时器每隔一个小时左右就会醒来,并启动一个简单的JavaScript任务.

Is there any way to create a background service with react-native on android? I would like some sort of timer that wakes up every hour or so, and launches a simple javascript task.

推荐答案

是的,可以做到.

React本机在JS桥的本机(java/Objc)之上运行,具有本机"和JS模块的概念(模块可以具有您可以从桥的另一侧"调用的方法).所有的UI东西都建立在桥的顶部(处理生成视图的主要本机"模块称为"UIManager").可以直接使用网桥,唯一的限制是通信必须是异步的.

React native operates on top of the native (java/Objc) to JS bridge with a concept of "native" and JS modules (modules can have methods that you may call from the "other" side of the bridge). All the UI stuff is built on top of the bridge (the main "native" module that handles generating views is called "UIManager"). It is possible to use bridge directly the only restriction is that the communication has to be asynchronous.

您可以从JAVA代码中调用javascript函数. 查看此链接以获取文档.

You can call the javascript function from the JAVA code. Check this link for the documentation.

这篇关于react-native android上的后台服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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