简体   繁体   English

如何从 web 应用程序/服务器发送数据以响应本机应用程序?

[英]How to send data from web app/server to react native app?

I am new to React Native and to the whole mobile dev side, to be honest.老实说,我是 React Native 和整个移动开发方面的新手。 I am getting involved in a project where we have a web app and we are now creating a react native app that needs to receive a notification if the user interacts with the web app.我正在参与一个项目,我们有一个 web 应用程序,我们现在正在创建一个反应本机应用程序,如果用户与 web 应用程序交互,该应用程序需要接收通知。

Let's say there is a button on the Web App saying Get Data and if it's pressed, the React Native App needs to know that something has been requested by the Web App so it could respond with the correct course of action.假设 Web 应用程序上有一个按钮说Get Data ,如果按下它,React Native 应用程序需要知道 Web 应用程序已请求某些内容,以便它可以以正确的操作过程响应。

I am looking for possible solutions that I should look into.我正在寻找我应该研究的可能解决方案。 I have been looking into WebSocket and firebase notification services.我一直在研究 WebSocket 和 firebase 通知服务。

I would love to hear from you guys if you have been involved in a similar project or can suggest the best way to approach this.如果您参与了类似的项目,或者可以提出解决此问题的最佳方法,我很想听听你们的意见。

You can use Firebase Realtime Database (it's free) to handle that such case.您可以使用Firebase 实时数据库(它是免费的)来处理这种情况。 With this service, any client subscribe the node (path) will be notified when the node has any change (add, update, remove), so you do not need to care about server side and concentrate to implement client side.有了这个服务,任何订阅节点(路径)的客户端都会在节点有任何变化(添加、更新、删除)时得到通知,因此您无需关心服务器端,专注于实现客户端。 Hope this will help you!希望对你有帮助!

You can send invisible push notifications from server side to mobile and in your app you read this invisible notification (some json), then you can identify the type of request, in your case Get Data , and from that you can fire a request or run some code.您可以将不可见的推送通知从服务器端发送到移动设备,并在您的应用程序中读取此不可见通知(一些 json),然后您可以识别请求的类型,在您的情况下为Get Data ,然后您可以触发请求或运行一些代码。

Check outOne signal , it's really useful查看一个信号,它真的很有用

You can use Expo as a beginner it helps you to get started https://expo.io/learn[Expo get started ][1]您可以使用 Expo 作为初学者,它可以帮助您入门https://expo.io/learn[世博入门][1]

[1]: https://expo.io/learn And it have its own toolhttps://docs.expo.io/versions/latest/guides/push-notifications/ it's easy for beginners with the mobile dev side [1]: https://expo.io/learn并且它有自己的工具https://docs.expo.io/devs/latest/guides为初学者提供移动端的简易指南/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM