Giter Site home page Giter Site logo

fullstackreact / react-native-firestack Goto Github PK

View Code? Open in Web Editor NEW
716.0 24.0 141.0 47.79 MB

A firestack v3 react-native implementation

License: MIT License

JavaScript 20.56% Objective-C 36.17% Ruby 1.64% Shell 0.82% Java 40.82%
react-native react-native-firebase firebase react-native-app

react-native-firestack's Introduction


This library is no longer maintained, use at your own risk or please seek alternatives on npm.


Firestack

Firestack makes using the latest Firebase straight-forward.

Gitter

What

Firestack is a light-weight layer sitting atop the native Firebase libraries for iOS and Android and mirrors the React Native JS api as closely as possible.

For a detailed discussion of how Firestack works as well as how to contribute, check out our contribution guide.

Features

  • Nearly automatic, rapid setup on Firebase
  • Covers lots of awesome features of Firebase:
    • authentication
      • username and password
      • social auth (implemented in conjunction with react-native-oauth)
        • Facebook
        • Github
        • Google
        • Twitter
    • storage handling
      • upload files
      • download urls
      • download files
    • real-time database
    • presence out-of-the-box
    • analytics
    • Remote configuration
    • FCM (in-progress)
  • Redux support built-in (but not required)
  • Android and iOS support
  • Community supported and professionally backed
  • Intended on being as drop-dead simple as possible
  • And so much more

Example app

We have a working application example available in at fullstackreact/FirestackApp. Check it out for more details about how to use Firestack.

Why?

Firebase is awesome and it's combination with the Google Cloud Platform makes it super awesome. Sadly, the latest version of Firebase requires the window object. That's where Firestack comes in! Firestack provides a really thin layer that sits on top of the native Firebase SDKs and attempts to use the JavaScript library as much as possible rather than reinventing the wheel.

Installing

Getting react-native-firestack up and running in your app should be a 2 step process + 1 for each platform.

  1. Install the npm package
  2. Link the project with react-native link react-native-firestack
  3. To ensure Android is setup, check your MainApplication.java for the FirestackPackage() line.

Those steps in more detail:

Install the npm package with:

npm install react-native-firestack --save

To use Firestack, we'll need to have a development environment that includes the same prerequisites of Firebase.

iOS (with cocoapods)

Unfortunately, due to AppStore restrictions, we currently do not package Firebase libraries in with Firestack. However, the good news is we've automated the process (with many thanks to the Auth0 team for inspiration) of setting up with cocoapods. This will happen automatically upon linking the package with react-native-cli.

Remember to use the ios/[YOUR APP NAME].xcworkspace instead of the ios/[YOUR APP NAME].xcproj file from now on.

We need to link the package with our development packaging. We have two options to handle linking:

Automatically with react-native-cli

React native ships with a link command that can be used to link the projects together, which can help automate the process of linking our package environments.

react-native link react-native-firestack

Update the newly installed pods once the linking is done:

cd ios && pod update --verbose

Manually

If you prefer not to use rnpm, we can manually link the package together with the following steps, after npm install:

  1. In XCode, right click on Libraries and find the Add Files to [project name].

Add library to project

  1. Add the node_modules/react-native-firestack/ios/Firestack.xcodeproj

Firebase.xcodeproj in Libraries listing

  1. Ensure that the Build Settings of the Firestack.xcodeproj project is ticked to All and it's Header Search Paths include both of the following paths and are set to recursive:

  2. $(SRCROOT)/../../react-native/React

  3. $(SRCROOT)/../node_modules/react-native/React

  4. ${PROJECT_DIR}/../../../ios/Pods

Recursive paths

  1. Setting up cocoapods

Since we're dependent upon cocoapods (or at least the Firebase libraries being available at the root project -- i.e. your application), we have to make them available for Firestack to find them.

Using cocoapods is the easiest way to get started with this linking. Add or update a Podfile at ios/Podfile in your app with the following:

source 'https://github.com/CocoaPods/Specs.git'
[
  'Firebase/Core',
  'Firebase/Auth',
  'Firebase/Storage',
  'Firebase/Database',
  'Firebase/RemoteConfig',
  'Firebase/Messaging'
].each do |lib|
  pod lib
end

target '[project name]' do
end

# target '[project test name]' do
# end

Then you can run (cd ios && pod install) to get the pods opened. If you do use this route, remember to use the .xcworkspace file.

If you don't want to use cocoapods, you don't need to use it! Just make sure you link the Firebase libraries in your project manually. For more information, check out the relevant Firebase docs at https://firebase.google.com/docs/ios/setup#frameworks.

Android

Full Android support is coming soon, as it currently supports a smaller feature-set than the iOS version. Just as we do with iOS, we'll need to install the library using npm and call link on the library:

react-native link react-native-firestack

Firestack includes the Firebase libraries and will link those directly into our project automatically.

Manually

To install react-native-firestack manually in our project, we'll need to import the package from io.fullstack.firestack in our project's android/app/src/main/java/com/[app name]/MainApplication.java and list it as a package for ReactNative in the getPackages() function:

package com.appName;
// ...
import io.fullstack.firestack.FirestackPackage;
// ...
public class MainApplication extends Application implements ReactApplication {
    // ...

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
            new FirestackPackage()
      );
    }
  };
  // ...
}

We'll also need to list it in our android/app/build.gradle file as a dependency that we want React Native to compile. In the dependencies listing, add the compile line:

dependencies {
  compile project(':react-native-firestack')
}

Add to AndroidManifest.xml file

  <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
+   <service android:name="io.fullstack.firestack.FirestackMessagingService">
+     <intent-filter>
+       <action android:name="com.google.firebase.MESSAGING_EVENT"/>
+     </intent-filter>
+   </service>

+   <service android:name="io.fullstack.firestack.FirestackInstanceIdService" android:exported="false">
+     <intent-filter>
+       <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
+     </intent-filter>
+   </service>

Firebase setup

The Firestack library is intended on making it easy to work with Firebase and provides a small native shim to the Firebase native code.

To add Firebase to your project, make sure to create a project in the Firebase console

Create a new project

Each platform uses a different setup method after creating the project.

iOS

After creating a Firebase project, click on the Add Firebase to your iOS app and follow the steps from there to add the configuration file. You do not need to set up a cocoapods project (this is already done through firestack). Make sure not to forget the Copy Files phase in iOS.

Download the Firebase config file and place it in your app directory next to your app source code:

GoogleService-Info.plist

Once you download the configuration file, make sure you place it in the root of your Xcode project. Every different Bundle ID (aka, even different project variants needs their own configuration file).

Lastly, due to some dependencies requirements, Firestack supports iOS versions 8.0 and up. Make sure to update the minimum version of your iOS app to 8.0.

Android

There are several ways to setup Firebase on Android. The easiest way is to pass the configuration settings in JavaScript. In that way, there is no setup for the native platform.

google-services.json setup

If you prefer to include the default settings in the source of your app, download the google-services.json file provided by Firebase in the Add Firebase to Android platform menu in your Firebase configuration console.

Next you'll have to add the google-services gradle plugin in order to parse it.

Add the google-services gradle plugin as a dependency in the project level build.gradle android/build.gradle

buildscript {
  // ...
  dependencies {
    // ...
    classpath 'com.google.gms:google-services:3.0.0'
  }
}

In your app build.gradle file, add the gradle plugin at the VERY BOTTOM of the file (below all dependencies) android/app/build.gradle

apply plugin: 'com.google.gms.google-services'

Usage

After creating a Firebase project and installing the library, we can use it in our project by importing the library in our JavaScript:

import Firestack from 'react-native-firestack'

We need to tell the Firebase library we want to configure the project. Firestack provides a way to configure both the native and the JavaScript side of the project at the same time with a single command:

const firestack = new Firestack();

We can pass custom options by passing an object with configuration options. The configuration object will be generated first by the native configuration object, if set and then will be overridden if passed in JS. That is, all of the following key/value pairs are optional if the native configuration is set.

option type Default Value Description
debug bool false When set to true, Firestack will log messages to the console and fire debug events we can listen to in js
bundleID string Default from app [NSBundle mainBundle] The bundle ID for the app to be bundled with
googleAppID string "" The Google App ID that is used to uniquely identify an instance of an app.
databaseURL string "" The database root (i.e. https://my-app.firebaseio.com)
deepLinkURLScheme string "" URL scheme to set up durable deep link service
storageBucket string "" The Google Cloud storage bucket name
androidClientID string "" The Android client ID used in Google AppInvite when an iOS app has it's android version
GCMSenderID string "" The Project number from the Google Developer's console used to configure Google Cloud Messaging
trackingID string "" The tracking ID for Google Analytics
clientID string "" The OAuth2 client ID for iOS application used to authenticate Google Users for signing in with Google
APIKey string "" The secret iOS API key used for authenticating requests from our app

For instance:

const configurationOptions = {
  debug: true
};
const firestack = new Firestack(configurationOptions);
firestack.on('debug', msg => console.log('Received debug message', msg))

API documentation

Firestack is broken up into multiple parts, based upon the different API features that Firebase provides.

All methods return a promise.

Authentication

Firestack handles authentication for us out of the box, both with email/password-based authentication and through oauth providers (with a separate library to handle oauth providers).

Android requires the Google Play services to installed for authentication to function.

listenForAuth()

Firebase gives us a reactive method for listening for authentication. That is we can set up a listener to call a method when the user logs in and out. To set up the listener, call the listenForAuth() method:

firestack.auth.listenForAuth(function(evt) {
  // evt is the authentication event
  // it contains an `error` key for carrying the
  // error message in case of an error
  // and a `user` key upon successful authentication
  if (!evt.authenticated) {
    // There was an error or there is no user
    console.error(evt.error)
  } else {
    // evt.user contains the user details
    console.log('User details', evt.user);
  }
})
.then(() => console.log('Listening for authentication changes'))

unlistenForAuth()

We can remove this listener by calling the unlistenForAuth() method. This is important to release resources from our app when we don't need to hold on to the listener any longer.

firestack.auth.unlistenForAuth()

createUserWithEmail()

We can create a user by calling the createUserWithEmail() function. The createUserWithEmail() accepts two parameters, an email and a password.

firestack.auth.createUserWithEmail('[email protected]', '123456')
  .then((user) => {
    console.log('user created', user)
  })
  .catch((err) => {
    console.error('An error occurred', err);
  })

signInWithEmail()

To sign a user in with their email and password, use the signInWithEmail() function. It accepts two parameters, the user's email and password:

firestack.auth.signInWithEmail('[email protected]', '123456')
  .then((user) => {
    console.log('User successfully logged in', user)
  })
  .catch((err) => {
    console.error('User signin error', err);
  })

signInWithCustomToken()

To sign a user using a self-signed custom token, use the signInWithCustomToken() function. It accepts one parameter, the custom token:

firestack.auth.signInWithCustomToken(TOKEN)
  .then((user) => {
    console.log('User successfully logged in', user)
  })
  .catch((err) => {
    console.error('User signin error', err);
  })

signInWithProvider()

We can use an external authentication provider, such as twitter/facebook for authentication. In order to use an external provider, we need to include another library to handle authentication.

By using a separate library, we can keep our dependencies a little lower and the size of the application down.

OAuth setup with library

[Currently undergoing updates]

socialLogin with custom Library

If you don't want to use react-native-oauth, you can use other library such as react-native-facebook-login.

var {FBLogin, FBLoginManager} = require('react-native-facebook-login');

var Login = React.createClass({
  render: function() {
    return (
      <FBLogin
        onLogin={function(data){
          console.log("Logged in!");
          console.log(data);
          let token = data.credentials.token
          firestack.auth.signInWithProvider('facebook', token, '') // facebook need only access token.
            .then((user)=>{
              console.log(user)
            })
        }}
      />
    );
  }
});

If the signInWithProvider() method resolves correct and we have already set up our listenForAuth() method properly, it will fire and we'll have a logged in user through Firebase.

reauthenticateWithCredentialForProvider()

When the auth token has expired, we can ask firebase to reauthenticate with the provider. This method accepts the same arguments as signInWithProvider() accepts.

updateUserEmail()

We can update the current user's email by using the command: updateUserEmail(). It accepts a single argument: the user's new email:

firestack.auth.updateUserEmail('[email protected]')
  .then((res) => console.log('Updated user email'))
  .catch(err => console.error('There was an error updating user email'))

updateUserPassword()

We can update the current user's password using the updateUserPassword() method. It accepts a single parameter: the new password for the current user

firestack.auth.updateUserPassword('somethingReallyS3cr3t733t')
  .then(res => console.log('Updated user password'))
  .catch(err => console.error('There was an error updating your password'))

sendPasswordResetWithEmail()

To send a password reset for a user based upon their email, we can call the sendPasswordResetWithEmail() method. It accepts a single parameter: the email of the user to send a reset email.

firestack.auth.sendPasswordResetWithEmail('[email protected]')
  .then(res => console.log('Check your inbox for further instructions'))
  .catch(err => console.error('There was an error :('))

updateUserProfile()

To update the current user's profile, we can call the updateUserProfile() method.

It accepts a single parameter:

  • object which contains updated key/values for the user's profile. Possible keys are listed here.
firestack.auth.updateUserProfile({
  displayName: 'Ari Lerner'
})
  .then(res => console.log('Your profile has been updated'))
  .catch(err => console.error('There was an error :('))

deleteUser()

It's possible to delete a user completely from your account on Firebase. Calling the deleteUser() method will take care of this for you.

firestack.auth.deleteUser()
.then(res => console.log('Sad to see you go'))
.catch(err => console.error('There was an error - Now you are trapped!'))

getToken()

If you want user's token, use getToken() method.

firestack.auth.getToken()
.then(res => console.log(res.token))
.catch(err => console.error('error'))

signOut()

To sign the current user out, use the signOut() method. It accepts no parameters

firestack.auth.signOut()
.then(res => console.log('You have been signed out'))
.catch(err => console.error('Uh oh... something weird happened'))

getCurrentUser()

Although you can get the current user using the getCurrentUser() method, it's better to use this from within the callback function provided by listenForAuth(). However, if you need to get the current user, call the getCurrentUser() method:

firestack.auth.getCurrentUser()
.then(user => console.log('The currently logged in user', user))
.catch(err => console.error('An error occurred'))

Analytics

Wouldn't it be nice to send analytics about your app usage from your users? Well, you totally can! The Firebase analytics console is incredibly useful and Firestack has a method for interacting with it. You can send any event with contextual information, which automatically includes the currently logged in user using the logEventWithName() method. It accepts two parameters: the name of the event and an object containing any contextual information. The values should be serializable (i.e. no complex instance objects).

logEventWithName()

firestack.analytics.logEventWithName("launch", {
  'screen': 'Main screen'
})
.then(res => console.log('Sent event named launch'))
.catch(err => console.error('You should never end up here'));

Storage

Firebase's integration with the Google platform expanded it's features to include hosting user-generated files, like photos. Firestack provides a thin layer to handle uploading files to Firebase's storage service.

setStorageUrl()

In order to store anything on Firebase, we need to set the storage url provided by Firebase. This can be set by using the setStorageUrl() method. Your storageUrl can be found on the firebase console.

Storage url

The setStorageUrl() method accepts a single parameter: your root storage url (without leading "gs://").

firestack.storage.setStorageUrl(`${config.firebase.storageBucket}`)

If the storageBucket key is passed as a configuration option, this method is automatically called by default.

uploadFile()

We can upload a file using the uploadFile() method. Using the uploadFile() method, we can set the name of the destination file, the path where we want to store it, as well as any metadata along with the file.

firestack.storage.uploadFile(`photos/${auth.user.uid}/${filename}`, path, {
  contentType: 'image/jpeg',
  contentEncoding: 'base64',
})
.then((res) => console.log('The file has been uploaded'))
.catch(err => console.error('There was an error uploading the file', err))

To upload camera photos, we can combine this method with the react-native-camera plugin, for instance:

this.camera.capture()
.then(({path}) => {
  firestack.storage.uploadFile(`photos/${auth.user.uid}/${filename}`, path, {
    contentType: 'image/jpeg',
    contentEncoding: 'base64',
  })
})
.catch(err => console.error(err));

To combine the react-native-camera plugin with firestack, we recommend setting the captureTarget to the temp storage path, like so:

<Camera
  ref={(cam) => {
    this.camera = cam;
  }}
  captureTarget={Camera.constants.CaptureTarget.temp}
  style={styles.preview}
  aspect={Camera.constants.Aspect.fill}>
    <Text style={styles.capture} onPress={this.takePicture.bind(this)}>[CAPTURE]</Text>
</Camera>

Firestack also gives you the ability to listen for database events on upload. The final parameter the uploadFile() function accepts is a callback that will be called anytime a storage event is fired.

The following events are supported:

  • upload_progress
  • upload_paused
  • upload_resumed

For example, the takePicture function from the example above might look something similar to:

takePicture() {
  this.camera.capture()
    .then(({path}) => {
      const filename = 'photo.jpg'
      firestack.storage.uploadFile(`photos/${filename}`, path, {
        contentType: 'image/jpeg',
        contentEncoding: 'base64',
      }, (evt) => {
        console.log('Got an event in JS', evt);
      })
      .then((res) => {
        console.log('result from upload file: ', res);
      })
      .catch((err) => {
        console.log('error happened with uploadFile', err);
      })
    })
    .catch(err => console.error(err));
}

downloadUrl()

The downloadUrl() method allows us to fetch the URL from the storage obejct in Firebase. It's defined on the storageRef object and can be used like so:

const storageRef = data.firestack.storage.ref('photos/photo.jpg');
storageRef.downloadUrl()
.then(res => {
  // res is an object that contains
  // the `url` as well as the path to the file in `path`
})

download()

It's possible to download remote files as well. The download() method will take a remote file and download and save it to the user's device. It is implemented on the storageRef:

const storageRef = data.firestack.storage.ref('photos/photo.jpg');
const localPath = `downloadedFile.jpg`;
storageRef.download(localPath, (msg) => {
  // downloading state callback
})
.then(res => {
  // res contains details about the downloaded file
})
.catch(err => {
  // error contains any errors in downloading
});

The method accepts a callback that gets called with any download events:

  • download_progress ({eventName: 'download_progress', progress: float });
  • download_paused ({eventName: 'download_paused'})
  • download_resumed ({eventName: 'download_resumed'})

As helpful constants, Firestack exports a few storage constants on the firestack.constants getter:

  • MAIN_BUNDLE_PATH
  • CACHES_DIRECTORY_PATH
  • DOCUMENT_DIRECTORY_PATH
  • EXTERNAL_DIRECTORY_PATH
  • EXTERNAL_STORAGE_DIRECTORY_PATH
  • TEMP_DIRECTORY_PATH
  • LIBRARY_DIRECTORY_PATH

And we also export the filetype constants as well:

  • FILETYPE_REGULAR
  • FILETYPE_DIRECTORY

Note: this idea comes almost directory from react-native-fs, so we don't claim credit for coming up with this fantastic idea.

Realtime Database

The native Firebase JavaScript library provides a featureful realtime database that works out of the box. Firestack provides an attribute to interact with the database without needing to configure the JS library.

Ranking strategy

Add a new record with timestamp using this solution:

firebaseApp.database.ref('posts').push().then((res) => {
 let newPostKey = res.key;
 firebaseApp.ServerValue.then(map => {
   const postData = {
     name: name,
     timestamp: map.TIMESTAMP,
     text: this.state.postText,
     title: this.state.postTitle,
     puid: newPostKey
    }
    let updates = {}
    updates['/posts/' + newPostKey] = postData
    firebaseApp.database.ref().update(updates).then(() => {
      this.setState({
                      postStatus: 'Posted! Thank You.',
                      postText: '',
                    });
    }).catch(() => {
      this.setState({ postStatus: 'Something went wrong!!!' });
    })
  })
})

Then retrieve the feed using this:

firebaseApp.database.ref('posts').orderByChild('timestamp').limitToLast(30).once('value')
.then((snapshot) => {
  this.props.savePosts(snapshot.val())
  const val = snapshot.val();
  console.log(val);
})

DatabaseRef

Firestack attempts to provide the same API as the JS Firebase library for both Android and iOS platforms. Check out the firebase guide for more information on how to use the JS library.

Example

function handleValueChange(snapshot) {
  if (snapshot.val()) {
    console.log('The list was updated');
  }
}

const LIST_KEY = 'path/to/data';
firestack.database.ref(LIST_KEY).on('value', handleValueChange);

// Calling `.off` with a reference to the callback function will only remove that specific listener.
// This is useful if multiple components are listening and unlistening to the same ref path.
firestack.database.ref(LIST_KEY).off('value', handleValueChange);

// Calling `.off` without passing the callback function will remove *all* 'value' listeners for that ref
firestack.database.ref(LIST_KEY).off('value');

// TODO: Finish documenting

Offline data persistence

For handling offline operations, you can enable persistence by using the setPersistence() command. You can turn it on and off by passing the boolean of true or false.

firestack.database.setPersistence(true);

The database refs has a keepSynced() function to tell the firestack library to keep the data at the ref in sync.

const ref = firestack.database
            .ref('chat-messages')
            .child('roomId');
ref.keepSynced(true);

Presence

Firestack comes in with a built-in method for handling user connections. We just need to set the presence ref url and tell Firestack to keep track of the user by their child path.

firestack.presence          // the presence api
  .on('users/connections')  // set the users/connections as the
                            // root for presence handling
  .setOnline('auser')       // Set the child of auser as online

While the device is online (the connection), the value of the child object at users/connections/auser will be:

{
  online: true,
  lastOnline: TIMESTAMP
}

When the device is offline, the value will be updated with online: false:

{
  online: false,
  lastOnline: TIMESTAMP
}

To set up your own handlers on the presence object, you can call onConnect() and pass a callback. The method will be called with the connectedDevice database reference and you can set up your own handlers:

const presence = firestack.presence
                          .on('users/connections');
presence.onConnect((ref) => {
  ref.onDisconnect().remove(); // Remove the entry
  // or
  ref.set({
    location: someLocation
  });
  // or whatever you want as it's called with the database
  // reference. All methods on the DatabaseRef object are
  // available here on the `ref`
})

ServerValue

Firebase provides some static values based upon the server. We can use the ServerValue constant to retrieve these. For instance, to grab the TIMESTAMP on the server, use the TIMESTAMP value:

const timestamp = firestack.ServerValue.TIMESTAMP

Cloud Messaging

Access the device registration token

  firestack.cloudMessaging.getToken().then(function (token) {
    console.log('device token', token);
  });

Monitor token generation

  // add listener
  firestack.cloudMessaging.listenForTokenRefresh(function (token) {
    console.log('refresh device token', token);
  });

  // remove listener
  firestack.cloudMessaging.unlistenForTokenRefresh();

Subscribe to topic

  firestack.cloudMessaging.subscribeToTopic("topic_name").then(function (topic) {
      console.log('Subscribe:'+topic);
  }).catch(function(err){
       console.error(err);
  });

Unsubscribe from topic

  firestack.cloudMessaging.unsubscribeFromTopic("topic_name").then(function (topic) {
      console.log('unsubscribe:'+topic);
  }).catch(function(err){
       console.error(err);
  });

Receive Messages

  firestack.cloudMessaging.listenForReceiveNotification((msg) =>{
    console.log('Receive Messages:'+msg.data);
    console.log('Receive Messages:'+msg.notification);

  });

Events

on()

We can listen to arbitrary events fired by the Firebase library using the on() method. The on() method accepts a name and a function callback:

firestack.on('listenForAuth', (evt) => console.log('Got an event'));

off()

To unsubscribe to events fired by Firebase, we can call the off() method with the name of the event we want to unsubscribe.

firestack.off('listenForAuth');

FirestackModule

Firestack provides a built-in way to connect your Redux app using the FirestackModule export from Firestack.

Running with the master branch

Most of our work is committed to the master branch. If you want to run the bleeding-edge version of Firestack, you'll need to follow these instructions.

Since react-native doesn't like symlinks, we need to clone the raw repository into our node_modules/ manually. First, in order to tell react-native we are using the package react-native-firestack, make sure to install the npm version:

npm install --save react-native-firestack

After the npm version is installed, you can either clone the repo directly into our node_modules/ directory:

git clone https://github.com/fullstackreact/react-native-firestack.git ./node_modules/react-native-firestack

Alternatively, you can clone the repo somewhere else and rsync the directory over to the node_modules/ directory.

This is the method I use as it allows me to separate the codebases:

git clone https://github.com/fullstackreact/react-native-firestack.git \
      ~/Development/react-native/mine/react-native-firestack/

## And rsync
rsync -avhW --delete \
      --exclude='node_modules' \
      --exclude='.git' \
      ~/Development/react-native/mine/react-native-firestack/ \
      ./node_modules/react-native-firestack/

Contributing

This is open-source software and we can make it rock for everyone through contributions.

How do you contribute? Check out our contribution guide at CONTRIBUTING.md

TODO

The following is left to be done:

  • Complete FirebaseModule functionality
  • Document FirebaseModule
  • Add Android support
    • auth/analytics/database/storage/presence are feature-complete. remoteconfig/messaging are mostly-there.
  • Add Cloud Messaging
    • Add JS api
  • Move to use swift (cleaner syntax)
  • TODO: Finish Facebook integration

Fullstack React Book

Fullstack React Book

This repo was written and is maintained by the Fullstack React team.

If you're looking to learn React, there's no faster way than by spending a few hours with the Fullstack React book.

react-native-firestack's People

Contributors

advans avatar alanhoff avatar auser avatar beachcamp avatar beskytter avatar bloojeans avatar brianjd avatar chaitanya-bhagavan avatar chrisbianca avatar danvass avatar dvassilev avatar ehesp avatar friedjoff avatar g6ling avatar ghuh avatar gizmodesbois avatar janvogt avatar jashmenn avatar mikelambert avatar mikesurowiec avatar neacsugeorge avatar pedro-ribeiro avatar salakar avatar samer avatar sh3rawi avatar slycoder avatar srijak avatar sujameslin avatar yn5 avatar yofu1234 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-firestack's Issues

Which part of the API is not available on Android ?

The documentation in the README file states that:

Full Android support is coming soon, as it currently supports a smaller feature-set than the iOS version

But doesn't precise which feature-set is supported or not by Android.

Android support

This is a great module! When can we expect android support?

No callback to handle database_error event

I've just been trying to get Firestack set up on a brand new project using the FirestackModule and have found an issue when a database permission error is thrown on iOS.

In database.js, a native success and error listener are added for "database_event" and "database_error". However, in FirestackDatabase.m, both the database events and errors are sent with the "database_event" identifier.

This means that an error is subsequently thrown in database.js as there is no callback registered against a "database_error" type.

I'm happy to submit a PR to make sure that FirestackDatabase.m sends the event as "database_error" but wanted to check there wasn't a reason they're currently sent with the same type before I did?

I'm assuming it's an oversight as the Java code appears to emit the two events separately.

No permission error while using Firebase Database

When I using the firestack.database() to get key object from firebase real time database, it shows error Client doesn't have permission to access Desired data.
When I changed the rules in firebase console to no auth for reading, it works fine.
Does the database object need extra token to access database?

Rules on firebase console

{
  "rules": {
    ".read": "auth == null",
    ".write": "auth == null"
  }
}

Testing code

export const db = async(key) => {
    let snap = await firestack.database.ref(key).once('value');
    let str = JSON.stringify(snap.val());
    if (snap) {
        Alert.alert(snap.key);
        return snap.val();
    };
};

iOS build failed with Xcode 8.0

I followed the whole instruction process but it's giving me weird errors while building the project:

any idea why?

Undefined symbols for architecture arm64:
"___cxa_guard_release", referenced from:
cachedSystemFont(double, double) in libReact.a(RCTFont.o)
"std::terminate()", referenced from:
___clang_call_terminate in libReact.a(RCTJSCExecutor.o)
"std::__1::mutex::lock()", referenced from:
-[RCTModuleData setUpInstanceAndBridge] in libReact.a(RCTModuleData.o)
cachedSystemFont(double, double) in libReact.a(RCTFont.o)
"std::__1::mutex::unlock()", referenced from:
-[RCTModuleData setUpInstanceAndBridge] in libReact.a(RCTModuleData.o)
cachedSystemFont(double, double) in libReact.a(RCTFont.o)

Best way to initialize and use firestack

Hi, I've got a question concerning how to use the library.
According to the config I have to create an firestack instance like this:

const firestack = new Firestack();

However, what if I'm using Firestack in multiple files? Can I create a new instance per file in which I need it? Is this the preferred approach?

// file1.js
import Firestack from 'react-native-firestack';
const firestack = new Firestack();

... do some logic here
// file2.js
import Firestack from 'react-native-firestack';
const firestack = new Firestack();

... do some logic here

Cheers, Hein

[discussion] database.ref().push(); get key of generated child

Hey there!

I was wondering if there's a better way to get the key of the child generated from a push()...

firestack.database.ref('some-path').push({someItem: 'data'}).then((res) => {
  let childKey = _.last(res.name[0].split('/'));
});

Not sure if I'm missing something or if the function should change to include the generated key on the response. Also curious if res.name[0] will always be the correct path

Thanks!

setStoragetUrl

Not really an issue, readme update needed, the gs:// is automatically added.

does not work

firestack.storage.setStorageUrl(`gs://${config.firebase.storageBucket}`)

does work

firestack.storage.setStorageUrl(`${config.firebase.storageBucket}`)

RemoteConfig

What's up with the RemoteConfig?
From what I can see it is still in the WIP state, any news with that?

runtime crash: Symbol not found: _OBJC_CLASS_$_AppDelegate

Hey there, starting with this commit: d737b36 I'm unable to run my project. I get the following error right after the app launches:

dyld: Symbol not found: _OBJC_CLASS_$_AppDelegate
 Referenced from: /Users/michaelsurowiec/Library/Developer/Xcode/DerivedData/Lokel-fyslvyjvsgzbcfeaocpmdtbindow/Build/Products/Debug-iphonesimulator/libFirestack.a
 Expected in: flat namespace
in /Users/michaelsurowiec/Library/Developer/Xcode/DerivedData/Lokel-fyslvyjvsgzbcfeaocpmdtbindow/Build/Products/Debug-iphonesimulator/libFirestack.a

Facebook Auth

When you mention that facebook oauth is not fully implemented, what do you mean exactly? Also are there any plans on extending this to make use of all firebase features?

Thanks!

How to remove unused dependencies?

If I don't need e.g. FirebaseAuth, how can I remove unused Pods dependencies?

Currently I commented out FirebaseAuth in my Podfile and rerun pod install, which removed FirebaseAuth, however Xcode throws me the following error:

screen shot 2016-10-06 at 20 15 48

Please help :) Thank you !

How to use with redux?

I am trying to add this library to my react native app. I successfully set it up but how can I properly make it work with redux? In read me it says there is FirestackModule but can anyone explain better how to implement with redux?

Add googleAuth login

Feature to add googleAuth example/update API to include it through FirestackAuth

Ask - Unable to find a specification for `Firebase` when linking modules

So I try to created a new RN project, then I installed firestack module npm install react-native-firestack --save, everythings worked fine from here.
But when I tried to linking the modules with react-native link react-native-firestack,
Somethings goes wrong

Yogies-MacBook-Pro:firestack_app yogieputra$ react-native link react-native-firestack
Preparing to link react-native-firestack for iOS
Checking CocoaPods...
CocoaPods already installed
rnpm-install info Linking react-native-firestack android dependency 
rnpm-install info Android module react-native-firestack has been successfully linked 
rnpm-install info Linking react-native-firestack ios dependency 
rnpm-install info iOS module react-native-firestack has been successfully linked 
Checking Podfile in iOS project (/Users/yogieputra/Works/firestack_app/ios/Podfile)
Adding Podfile to iOS project
Installing Pods
Analyzing dependencies
[!] Unable to find a specification for `Firebase`
/Users/yogieputra/Works/firestack_app/node_modules/react-native/local-cli/core/makeCommand.js:19
        throw new Error(`Error occured during executing "${ command }" command`);
        ^

Error: Error occured during executing "node_modules/react-native-firestack/bin/cocoapods.sh" command
    at ChildProcess.prelink (/Users/yogieputra/Works/firestack_app/node_modules/react-native/local-cli/core/makeCommand.js:19:15)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:852:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)

Can you guys help me how to solve this issue?
Sorry for this silly questions

Make an example with tests

Feature request:

It would be great to make a canonical example with automated testing to ensure the API is covered and working as expected.

Database ref.on does not work on Android

I have the same exact code on Android and iOS for observing value changes on my database. It works on iOS as expected but does not work on Android. I have placed my code below as a reference:

.ref("shifts")
    .on('value', snapshot => {
    console.log(snapshot)
 })

Analytics Error

Analytics seems to not be functioning correctly. Firebase was added to XCode manually not via Pods.

<FIRAnalytics/ERROR> Unable to insert bundle. Error: Error Domain=com.google.gmp.measurement.ErrorDomain Code=1 "Failed to insert bundle without App ID" UserInfo={NSLocalizedDescription=Failed to insert bundle without App ID} <FIRAnalytics/ERROR> Transaction failed

No visible @interface for FIRMessaging

Hello there,

I'm having troubles compiling my project with the latest react-native-firebase. This is what Xcode complains about:

node_modules/react-native-firestack/ios/Firestack/FirestackCloudMessaging.m:116:29: No visible @interface for 'FIRMessaging' declares the selector 'setRemoteMessageDelegate:'

My Xcode version is Version 8.0 (8A218a), here is my Podfile.lock:

PODS:
  - AWSCore (2.4.7)
  - AWSS3 (2.4.7):
    - AWSCore (= 2.4.7)
  - Crashlytics (3.7.3):
    - Fabric (~> 1.6.3)
  - Fabric (1.6.8)
  - Firebase (3.5.1):
    - Firebase/Core (= 3.5.1)
  - Firebase/Analytics (3.5.1):
    - FirebaseAnalytics (~> 3.3.1)
  - Firebase/Auth (3.5.1):
    - Firebase/Analytics
    - FirebaseAuth (= 3.0.4)
  - Firebase/Core (3.5.1):
    - Firebase/Analytics
  - Firebase/Database (3.5.1):
    - Firebase/Analytics
    - FirebaseDatabase (= 3.0.2)
  - Firebase/Messaging (3.5.1):
    - Firebase/Analytics
    - FirebaseMessaging (= 1.1.1)
  - Firebase/RemoteConfig (3.5.1):
    - Firebase/Analytics
    - FirebaseRemoteConfig (= 1.2.0)
  - Firebase/Storage (3.5.1):
    - Firebase/Analytics
    - FirebaseStorage (= 1.0.3)
  - FirebaseAnalytics (3.3.1):
    - FirebaseInstanceID (~> 1.0)
    - GoogleInterchangeUtilities (~> 1.2)
    - GoogleSymbolUtilities (~> 1.1)
    - GoogleUtilities (~> 1.2)
  - FirebaseAuth (3.0.4):
    - FirebaseAnalytics (~> 3.2)
    - GoogleNetworkingUtilities (~> 1.2)
    - GoogleParsingUtilities (~> 1.1)
    - GoogleUtilities (~> 1.2)
  - FirebaseDatabase (3.0.2):
    - FirebaseAnalytics (~> 3.2)
  - FirebaseInstanceID (1.0.8)
  - FirebaseMessaging (1.1.1):
    - FirebaseAnalytics (~> 3.3)
    - FirebaseInstanceID (~> 1.0)
    - GoogleInterchangeUtilities (~> 1.2)
    - GoogleIPhoneUtilities (~> 1.2)
    - GoogleSymbolUtilities (~> 1.1)
  - FirebaseRemoteConfig (1.2.0):
    - FirebaseAnalytics (~> 3.3)
    - FirebaseInstanceID (~> 1.0)
    - GoogleInterchangeUtilities (~> 1.2)
    - GoogleIPhoneUtilities (~> 1.2)
    - GoogleSymbolUtilities (~> 1.1)
    - GoogleUtilities (~> 1.2)
  - FirebaseStorage (1.0.3):
    - FirebaseAnalytics (~> 3.3)
    - GoogleNetworkingUtilities (~> 1.2)
  - GoogleInterchangeUtilities (1.2.1):
    - GoogleSymbolUtilities (~> 1.0)
  - GoogleIPhoneUtilities (1.2.1):
    - GoogleSymbolUtilities (~> 1.0)
    - GoogleUtilities (~> 1.0)
  - GoogleNetworkingUtilities (1.2.1):
    - GoogleSymbolUtilities (~> 1.0)
  - GoogleParsingUtilities (1.1.1):
    - GoogleNetworkingUtilities (~> 1.0)
    - GoogleSymbolUtilities (~> 1.0)
  - GoogleSymbolUtilities (1.1.1)
  - GoogleUtilities (1.3.1):
    - GoogleSymbolUtilities (~> 1.0)
  - Mixpanel (3.0.2):
    - Mixpanel/Mixpanel (= 3.0.2)
  - Mixpanel/Mixpanel (3.0.2)

DEPENDENCIES:
  - AWSS3
  - Crashlytics
  - Fabric
  - Firebase
  - Firebase/Auth
  - Firebase/Core
  - Firebase/Database
  - Firebase/Messaging
  - Firebase/RemoteConfig
  - Firebase/Storage
  - Mixpanel (= 3.0.2)

SPEC CHECKSUMS:
  AWSCore: 9a729a3c0050a51ece3547d546c327acdac7838a
  AWSS3: 0f3c8ed11e04cd78cf86ed396c06330ab142db7a
  Crashlytics: 76f6beaff70acf226139582c09c78461597c2b98
  Fabric: 5755268d0171435ab167e3d0878a28a777deaf10
  Firebase: 9b3edeffaf60d56e377dc5281e91c4ba935a5ad9
  FirebaseAnalytics: d968d4d5f6aeb795cd64144337bcd233e530efc6
  FirebaseAuth: 26fd291c3b552fc9658420b867520d5ae080421c
  FirebaseDatabase: 59bea2e7dfd81b3b8b2f8e396caf1a52c2ced6f7
  FirebaseInstanceID: ba1e640935235e5fac39dfa816fe7660e72e1a8a
  FirebaseMessaging: 6bc7cd2ecb875c1a9c0f8b94956398aa3145bbb8
  FirebaseRemoteConfig: c5378e689c1edb54ff62061b8f6a908263dd80ae
  FirebaseStorage: 3992817bf405f5c1a4f8349678d22724cd0ef509
  GoogleInterchangeUtilities: def8415a862effc67d549d5b5b0b9c7a2f97d4de
  GoogleIPhoneUtilities: 63f25e93a3ddcb66884d182aab3a660d98f1479b
  GoogleNetworkingUtilities: 3e83269048cfb498dc7ec83ab36813360965c74f
  GoogleParsingUtilities: 30b3896f9ee167dc78747f013d3de157ced1cadf
  GoogleSymbolUtilities: 33117db1b5f290c6fbf259585e4885b4c84b98d7
  GoogleUtilities: 56c5ac05b7aa5dc417a1bb85221a9516e04d7032
  Mixpanel: 0e4f1f9a2ac612b589b2894830038418c2587428

PODFILE CHECKSUM: b15667e7af5f593987509b5f79d907398baa68cc

COCOAPODS: 1.0.1

And I'm using React Native v0.34.1. If I remove that line the project compiles just fine and it's a short term solution for me since we're not using Cloud Messaging.

IOS - FirestackReceiveNotification is not a supported event type

On IOS I get the following error using cloud messages.
The build is fine and the app is running, just the red screen comes up.
Running on emulator or device.

FirestackReceiveNotification is not a supported event type for FirestackCloudMessaging.
Supported events are: messaging_event, messaging_error, messaging_token_refresh, ……

Code I use

FirebaseStack.cloudMessaging.listenForReceiveNotification((msg) =>{
        console.log(msg.data);
        console.log(msg.notification);
    });

FirebaseStack.cloudMessaging.subscribeToTopic("film").then(function (topic) {
        console.log('Subscribed:'+topic);
    }).catch(function(err){
        console.error(err);
    });

download file from storage

Hi! I was wondering if this library can download file from firebase storage
I'll be using this on Android

Thanks!

logEventWithName error

When I try to use Analytics, I get this error:

firestack.logEventWithName is not a function

I have:

firestack.logEventWithName("launch", {
      'screen': 'Main screen'
    })
    .then(res => console.log('Sent event named launch'))
    .catch(err => console.log('You should never end up here'));

In fact I login and retrieve info from Firebase with success

dyld: Library not loaded

Got error loading library with Xcode 7.3.1, which has no Embed Framework
Any ideas of solving this?

dyld: Library not loaded: @rpath/libFirestack.a
  Referenced from: /var/mobile/Containers/Bundle/Application/40EE0D26-A842-4DF5-BD70-6BC020A7F7E4/rnStartKit.app/rnStartKit
  Reason: image not found

Error - 'Firebase.h' file not found

I tried to buid with react-native run-ios for the first time and it gives me error:
Screen Shot 2016-10-13 at 4.51.20 PM.png

here's my package.json:

{
  "name": "firestackApp",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "firebase": "^3.4.1",
    "react": "15.3.2",
    "react-native": "0.35.0",
    "react-native-firestack": "^2.3.0"
  },
  "jest": {
    "preset": "jest-react-native"
  },
  "devDependencies": {
    "babel-jest": "16.0.0",
    "babel-preset-react-native": "1.9.0",
    "jest": "16.0.1",
    "jest-react-native": "16.0.0",
    "react-test-renderer": "15.3.2"
  }
}

Can you guys help me how to solve this issue?

Cannot read property 'debug' of undefined

Hi, I'm trying to use firestack mainly to upload picture onto firebase storage.
My model firestack file:
import Firestack from 'react-native-firestack' const firestack = new Firestack(); firestack.setStorageUrl(someUrl).then(() => console.log("Project configured and ready to boot")); module.exports = firestack;

and in my main file i just require it as normal:
var firestack = require('../../Model/firestack');
But when i run, it keep throwing this error:
screen shot 2016-08-27 at 5 58 50 pm

dependencies i use:
"react-native-firestack": "^2.1.0", "firebase": "^3.3.0", "react": "^15.2.1", "react-native": "0.31.0",
Any help would be greatly appreciated!

Query with startAt / endAt not working?

I'm trying to get pagination working in my app, but it appears the startAt / endAt doesn't affect the queries. I'm using it in conjunction with limitToLast, I'm not sure if that's an issue.

I was playing with a couple different strategies, so let me see if I can boil it down...

let myRef = firestack.database.ref('chat-messages/roomId');

myRef.orderByKey().limitToLast(10).once('value').then((snapshot) => {
  let itemKeys = Object.keys(snapshot.val());
  let lastItemKey = itemKeys[itemKeys.length-1];

  myRef.orderByKey().startAt(lastItemKey).on('child_added', (data) => {
    if (data.key === lastItemKey) {
      return;
    }
    // This fires for all items in the collection, despite the startAt(lastItemKey)
    console.log('got data', data);
  });
});

I'm also pretty new to firebase, so there could just be a logical error in there 😄

Thanks for you time!

Build IOS errors

Using the master branch, I get the following errors on build/run.
I followed the readme, it is working fine on Android.
I guess something is not linked, google service ugraded?

Thanks

Xcode Error Messages

node_modules/react-native-firestack/ios/Firestack/FirestackCloudMessaging.m:102:3: 
Use of undeclared identifier 'UNAuthorizationOptions'

node_modules/react-native-firestack/ios/Firestack/FirestackCloudMessaging.m:106:5:
Unknown receiver 'UNUserNotificationCenter'; did you mean 'NSNotificationCenter'?

React-Native Errors

CompileC ios/build/Build/Intermediates/Firestack.build/Debug-iphonesimulat/Firestack.build
/Objects-normal/x86_64/FirestackCloudMessaging.o  
Firestack/FirestackCloudMessaging.m  normal x86_64 objective-c
com.apple.compilers.llvm.clang.1_0.compiler

Android

I know, this is still in progress.
I am testing a bit at the moment and noticed some stuff.

On IOS the code below works fine, it is getting data and is updating data on change.
The same code does not work on android yet.

_this = this
        this.props.FirebaseStack.database.ref('chat/Zeitkapsel/messages').on('value', function(snapshot) {
            _this.setState({
                dataSource: _this.state.dataSource.cloneWithRows(snapshot.value),
                animating: false
            });
        })

On android, the code below works, so, "once" works

       _this = this;

        this.props.FirebaseStack.database.ref('chat/Zeitkapsel/messages').once('value')
            .then(function(snapshot){
                _this.setState({
                  dataSource: _this.state.dataSource.cloneWithRows(snapshot.value),
                  animating: false
                });
            })
            .catch(function(error){
                console.log(error);
            })

Running configure throws exception

I'm not an iOS developer so I don't know how to debug this.

2016-08-24 04:24:48.811 Proco[60852:8079959] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'GIPReachability should be used from the main thread'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010d94cd85 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010d049deb objc_exception_throw + 48
    2   CoreFoundation                      0x000000010d94cbea +[NSException raise:format:arguments:] + 106
    3   Foundation                          0x000000010af53e1e -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 169
    4   libFirestack.a                      0x000000010cd5f870 -[GIPReachability startWithCompletionHandler:] + 159
    5   libFirestack.a                      0x000000010cd28a0f -[FIRMessaging startWithConfig:] + 212
    6   libFirestack.a                      0x000000010cd287ca __25+[FIRMessaging messaging]_block_invoke + 124
    7   libdispatch.dylib                   0x000000010f2543eb _dispatch_client_callout + 8
    8   libdispatch.dylib                   0x000000010f23fd68 dispatch_once_f + 543
    9   libFirestack.a                      0x000000010cd2874c +[FIRMessaging messaging] + 46
    10  libFirestack.a                      0x000000010cd28393 +[FIRMessaging(FIRApp) didReceiveConfigureSDKNotification:] + 127
    11  CoreFoundation                      0x000000010d916c8c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
    12  CoreFoundation                      0x000000010d9169cb _CFXRegistrationPost + 427
    13  CoreFoundation                      0x000000010d916732 ___CFXNotificationPost_block_invoke + 50
    14  CoreFoundation                      0x000000010d95f1e2 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1986
    15  CoreFoundation                      0x000000010d80e679 _CFXNotificationPost + 633
    16  Foundation                          0x000000010ae95cd9 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
    17  libFirestack.a                      0x000000010cc5e134 +[FIRApp sendNotificationsToSDKs:] + 296
    18  libFirestack.a                      0x000000010cc5d09b +[FIRApp configureDefaultAppWithOptions:sendingNotifications:] + 324
    19  libFirestack.a                      0x000000010cc5ce13 +[FIRApp configureWithOptions:] + 90
    20  libFirestack.a                      0x000000010cc0eac6 -[Firestack configureWithOptions:callback:] + 3366
    21  CoreFoundation                      0x000000010d8355cc __invoking___ + 140
    22  CoreFoundation                      0x000000010d83541e -[NSInvocation invoke] + 286
    23  CoreFoundation                      0x000000010d8c4d26 -[NSInvocation invokeWithTarget:] + 54
    24  Proco                               0x0000000108db702f -[RCTModuleMethod invokeWithBridge:module:arguments:] + 1887
    25  Proco                               0x0000000108e09848 -[RCTBatchedBridge _handleRequestNumber:moduleID:methodID:params:] + 680
    26  Proco                               0x0000000108e0898a __33-[RCTBatchedBridge handleBuffer:]_block_invoke.457 + 1274
    27  libdispatch.dylib                   0x000000010f233d9d _dispatch_call_block_and_release + 12
    28  libdispatch.dylib                   0x000000010f2543eb _dispatch_client_callout + 8
    29  libdispatch.dylib                   0x000000010f23a82c _dispatch_queue_drain + 2215
    30  libdispatch.dylib                   0x000000010f239d4d _dispatch_queue_invoke + 601
    31  libdispatch.dylib                   0x000000010f23c996 _dispatch_root_queue_drain + 1420
    32  libdispatch.dylib                   0x000000010f23c405 _dispatch_worker_thread3 + 111
    33  libsystem_pthread.dylib             0x000000010f5914de _pthread_wqthread + 1129
    34  libsystem_pthread.dylib             0x000000010f58f341 start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

screen shot 2016-08-24 at 04 26 08

Code I'm running:

import Firestack from 'react-native-firestack'

const firestack = new Firestack({
apiKey: '[reducted]',
authDomain: '[reducted].firebaseapp.com',
storageBucket: '[reducted].appspot.com',
databaseURL: 'https://[reducted].firebaseio.com',
});

firestack.configure()
.then(() => console.log("Project configured and ready to boot"));

Invalid Swift Support error occurs when deploying App to the Appstore

Hi,

I've reached the point where I am deploying the App to the iOS app-store, but the app is being rejected because of the following error:

Invalid Swift Support - The SwiftSupport folder is missing.
Rebuild your app using the current public (GM) version of Xcode and resubmit it.

After some investigating and disabling libraries I found that this happens when including firestack. After removing firestack using react-native unlink react-native-firestack the problem disappears.

Has anyone already ran into this, any solutions?

thanks,
Hein

How to download file from the bucket

Hey there, I'm using iOS and the latest version of Firestack. Is there a way to download a file from the bucket instead of only generating the URL?

Linking fails on windows10

After installing the package react-native link react-native-firestack fails.
The bash scripts are causing an error on windows.
After removing the commands prelink/postlink in node_modules/react-native-firestack/package.json as per @auser's recommendation it works on windows10.

Get IOS running - Analytics error

Lexical or Preprocessor Issue Group

I work of the master branch.

Xcode errors

#import <FirebaseCore/FIRAnalyticsConfiguration.h>
include of non-modular header inside framework module FireBaseAnalytics

/.........../ios/Pods/FirebaseAnalytics/Frameworks/frameworks/FirebaseAnalytics.framework/Headers/FIRAnalyticsConfiguration.h:1:9: Include of non-modular header inside framework module 'FirebaseAnalytics'

/............./node_modules/react-native-firestack/ios/Firestack/FirestackAnalytics.m:13:9: While     building module 'FirebaseAnalytics' imported from /Applications/XAMPP/xamppfiles/htdocs/react/stockalert/node_modules/react-native-firestack/ios/Firestack/FirestackAnalytics.m:13:

/.........../ios/Pods/FirebaseAnalytics/Frameworks/frameworks/FirebaseAnalytics.framework/Headers/FirebaseAnalytics.h:5:9: In file included from ../../../ios/Pods/FirebaseAnalytics/Frameworks/frameworks/FirebaseAnalytics.framework/Headers/FirebaseAnalytics.h:5:

Database event 'once' does not fire.

Just going to go ahead and leave this here as I tested a few scenarios using firestack version 2.2.3 and React-native version 0.32.0.

firestack.database.ref('...').once(...)

Will never fire, however calling

firestack.database.ref('...').on(...)

and then deregistering the listener works fine.

EX:

var x = firestack.database.ref('users').on('value', (snapshot) => {
            firestack.database.ref('users').off(x)
            // Handle snapshot
}

The problem with this is that .off() stops execution, so it must be done at the bottom of the chain, which makes it a mess to do with promises, you have to close the listener in a round-about way.

FirebaseApp with name [DEFAULT] doesn't exist

After I added the code below to the android manifest (Readme File), I got the error "FirebaseApp with name [DEFAULT] doesn't exist".

I guess you added that recently with some upgrades to the android messaging.
Anyway, it is not a problem, after removing it was running again.

I assume this will come with the next npm release?

+   <service android:name="io.fullstack.firestack.FirestackMessagingService">
+     <intent-filter>
+       <action android:name="com.google.firebase.MESSAGING_EVENT"/>
+      </intent-filter>
+   </service>

Bitcode is not enabled for real device iOS builds

Hi,

First of all I'd like to thank you for creating this awesome library, kudos! 👍 👍

When building for my actual phone on iOS I'm getting an error that bitcode is not enabled in libFirestack.a. I checked the firestack project and it is indeed disabled there. Is this on purpose and if so what dependency requires that bitcode is not enabled.
I'm currently stuck with my build on this as I really don't want to disable the bitcode option.

image

best regards,
Hein

Incoherence between android and ios

firebaseApp.signInWithEmail(this.state.email, this.state.password)
      .then((user) => {
        console.log(user);

returns in ios:

{ user: 
       { displayName: '',
         uid: 'g7ViniExeONPJcmda5UDywoDFQ32',
         providerID: 'Firebase',
         anonymous: false,
...
}

and returns in android:

{ provider: 'firebase',
uid: 'g7ViniExeONPJcmda5UDywoDFQ32',
email: '[email protected]',
...
}

Are those incoherences normal?

Do not restart the upload entirely

Hello there,

Firebase claims that up/downloads starts where they were stopped, but making a simple test using airplane mode shows that the upload starts all over again. Do you know anything about this feature?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.