Realm React-Native:从JS(反应本机代码)和android(java)访问同一领域 [英] Realm React-Native: Access same realm from JS(react native code) and android(java)

查看:113
本文介绍了Realm React-Native:从JS(反应本机代码)和android(java)访问同一领域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用例,我在android代码(本机)中接收一些数据。我想将这些数据插入到由我的反应代码打开或制作的同一个域中。

I have a use case where i am receiving some data in android code(native). I want to insert this data into the same realm which is opened or made by my react code.

或者写在同一个领域。我怎样才能做到这一点?所有的帮助表示赞赏。
P.S.我知道我可以以某种方式创建一个本机模块并将数据发送回我的JS并在那里执行操作..但我不确定如果我的应用程序不在前台会发生。

Or write in the same realm. How can I achieve this? All the help is appreciated. P.S. I know I can somehow make a native module and send data back to my JS and perform operations there.. but I am not sure it will happen if my app is not in foreground.

现在我在后台运行一项服务,它将接收数据并将其保存在领域。

Right now I am running a service in background which will receive data and save it in realm.

我能用这种方式吗?

推荐答案

我有同样的要求,并尝试从android和react-native访问同一个文件,这会破坏我的应用程序。我改为路径文件,以证明其路径文件相关。

I have the same requirement and tried accessing the same file from android and react-native which breaks my application. I changed to pathfile on one side to proof its pathfile related.

如果领域团队中的某个人能够确认这是否应该有效以及我应该采取什么措施来解决这个问题,那就太棒了。我假设更多用户将在android中使用服务,并且需要以react-native访问数据。

It would be great, if someone from the realm team can confirm this is/should work or not and what I should do to fix this issue. I assume more users will use services in android and need to access the data in react-native.

版本js:
realm:^ 2.21。 0,
react-native:0.57.7,

versions js: "realm": "^2.21.0", "react-native": "0.57.7",

版本android:
'com.android.tools.build: gradle:3.2.1'
minSdkVersion = 26

version android: 'com.android.tools.build:gradle:3.2.1' minSdkVersion = 26

这篇关于Realm React-Native:从JS(反应本机代码)和android(java)访问同一领域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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