Firebase Client on ReactNative

When using Firebase on ReactNative, this error message appears:

cannot find a variable process

However, if I require firebase/lib/firebase-web.js manually, it will show:

cannot find document variable

How can i solve this?

+7
reactjs react-native firebase
source share
3 answers

Just think about it. Pavan's answer is useful, but this is not entirely true when used with Firebase.

For firebase follow these steps:

  • Download firebase-debug.js from wsExample . Or you can just install wsExample on npm and require firebase-debug.js inside it.
  • Use badfortrins forked React-Native:

     "react-native": "git://github.com/badfortrains/react-native#WebSocket" 
  • The new Firebase is as follows:

     var firebase = require("../../firebase-debug.js"); var rootRef = new Firebase(Const.FB_ROOT); 

Now everything should work!

+1
source share

I just went through the same problem trying to use sockets.io in my native application, so I hope I can help.

The reason you cannot use the firebase node module is because a polyfill has not yet been created to support webcams (which one depends on firebase) in the native reaction.

If you look at issue # 619 in response to your own repo, you will find the current discussion about creating websockets api polyfill.

The way we solved this is to use a modified version of the Jason socket library and create

enter image description here

The reason the Jason version of the sockets.io client file is running is because action-native is being added as a user agent. You can find the code that makes this change at the top of the file:

 window.navigator = { userAgent: "react-native" } 

Once you complete these steps, you will be able to request / as usual.

+4
source share

I had problems with socket.io on React Native, the solution was to receive notifications of new data, and if the data was large enough, get it with a simple RESTfull request. in my case, the data was small enough to be sent to everyone in the notification API.

I used the GCM service to send notifications to the phone from the nodejs server. BTW, it uses less battery than socket connector and works great :)

0
source share

All Articles