Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
67f3384
Return file snapshot on upload (#88)
urbantumbleweed Mar 24, 2017
5edc780
feat(react-native): react-native and boilerplate support (#90)
prescottprue Mar 24, 2017
2d1bbb7
Added XMLHttpRequest to tests (to fix firebase auth issue)
Mar 24, 2017
0ffacb0
react-native complete example started.
Mar 24, 2017
224de4e
Firebase showing up in react-native example.
Mar 24, 2017
78f3ed4
Home now displays auth in a string.
Mar 25, 2017
2b2f429
react-native now working with firebase js library
prescottprue Mar 25, 2017
cc0ad58
Switched to ReactNative instead of rn
prescottprue Mar 25, 2017
d65aa2f
Version v1.4.0-beta (#97)
prescottprue Mar 26, 2017
04039a2
Version v1.4.0 Beta 2 (#100)
prescottprue Mar 28, 2017
5042759
Version v1.4.0 Beta 3 (#101)
prescottprue Mar 28, 2017
27d64e7
Merge branch 'master' into v1.4.0
prescottprue Mar 30, 2017
acd14f9
Merge branch 'master' into v1.4.0
Apr 1, 2017
c960361
Version 1.4.0 Beta 4 (#105)
prescottprue Apr 3, 2017
459c222
Version v1.4.0 Release Candidate 1 (#110)
prescottprue Apr 5, 2017
23bb32a
Form utils added to example.
prescottprue Apr 10, 2017
bc64cf5
Roadmap updated with info on nested populates and updateProfile method.
Apr 15, 2017
b3c87bd
Merge branch 'master' into v1.4.0
Apr 15, 2017
d4b86d1
Server side rendering notes added.
Apr 26, 2017
d7943f5
Merge branch 'master' into v1.4.0
May 5, 2017
36de200
Support for custom auth parameters added.
May 5, 2017
6b2826c
Merge branch 'master' into v1.4.0
May 5, 2017
e478d03
notParsed query parameter. isLoaded returns true issue (#121)
May 5, 2017
85e968e
Use prop-types package instead of the bundled prop-types (#122)
petetnt May 5, 2017
7dbe7b2
key: true lists support for profileParamsToPopulate (#123)
fej-snikduj May 5, 2017
ff11deb
Fixed typos in material-example
May 6, 2017
e89e381
Fixed the last of the "react" typos within material example.
May 6, 2017
3655517
Firebase updated to v3.9.0. More material example updates.
prescottprue May 6, 2017
4e629a9
Lint removed.
prescottprue May 6, 2017
e53dc19
More lint removal from material-ui example.
prescottprue May 6, 2017
caa9bd4
Added message to clarify home container.
prescottprue May 6, 2017
c964724
Not populated delete working in material-ui example
prescottprue May 6, 2017
c92a563
Pull request template updated. Roadmap updated with react-native-fire…
prescottprue May 16, 2017
90489f6
SSR and Auth sections added to recipes. Roadmap updated for coming v1…
prescottprue May 16, 2017
4404433
Merge branch 'master' into v1.4.0
prescottprue May 16, 2017
12df1e8
Auth Recipes cleaned up.
prescottprue May 16, 2017
b49e98f
Version v1.4.0-rc.3 (#128) (#134)
prescottprue May 16, 2017
d86b06d
Exposing Firebase messaging added to roadmap for v1.5.0.
May 16, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(react-native): react-native and boilerplate support (#90)
**NOTE:** [The original pull request](#81) for this feature and its branch have the `dist` files included in git tracking (so the branch could be referenced in package files). This pull request does not include `dist` files.

## Features
* Initial support for `react-native` (should solve #80)
* Import only needed sections of Firebase library ( #72 and #53 )

## Notes About react-native
Support for `react-native` is still in the early testing phases. That means the API and/or functionality may change.

If using `react-native`, make sure you have the following config enabled when creating your store:

```js
import ReactNative from 'react-native'
import { compose, createStore } from 'redux';
import { reactReduxFirebase } from 'react-redux-firebase'
const firebaseConfig = {} // your firebase config object
const initialState = { firebase: { authError: null } };

// then in your config when creating store
const store = createStore(
    makeRootReducer(), 
    initialState,
    compose(
      reactReduxFirebase(
        firebaseConfig,
        {
           rn: ReactNative,
           enableRedirectHandling: false,
           userProfile: 'users' 
         },
      ),
    )
  );
```

Normal authentication methods, such as `firebase.login({provider: 'google', type: 'popup'})`, will not work due to Firebase's js library (used internally) not completely supporting `react-native`. That means you must use `firebase.auth().signInWithCredential(credential)` until there is more support within the Firebase library.

It might look something like this (untested):

```js
let credential = this.props.firebase.auth.GoogleAuthProvider.credential(token);
this.props.firebase.auth().signInWithCredential(credential)
  .then(() => {
    console.log('auth successful')
  })
  .catch((err) => {
    console.log('error: ', err)
  })
```
  • Loading branch information
prescottprue authored Mar 24, 2017
commit 5edc7803e42a84e79aa6265159e397bd5d752c43
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Dependency directory
node_modules
examples/**/node_modules
dist
coverage
_book
dist
es
lib
_book
# Logs
*.log

.DS_Store
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
],
"dependencies": {
"es6-promise": "^4.0.5",
"firebase": "3.6.5",
"firebase": "3.7.1",
"immutable": "^3.8.1",
"jwt-decode": "^2.1.0",
"lodash": "^4.17.4"
Expand Down
58 changes: 36 additions & 22 deletions src/compose.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import Firebase from 'firebase'
// import * as firebase from 'firebase'
import * as firebase from 'firebase/app'
import 'firebase/auth'
import 'firebase/database'
import 'firebase/storage'
import { defaultConfig } from './constants'
import { validateConfig } from './utils'
import { authActions, queryActions, storageActions } from './actions'
Expand Down Expand Up @@ -69,17 +73,27 @@ export default (fbConfig, otherConfig) => next =>

// Initialize Firebase
try {
Firebase.initializeApp(fbConfig)
firebase.initializeApp(fbConfig)
} catch (err) {} // silence reinitialize warning (hot-reloading)

// Enable Logging based on config
if (configs.enableLogging) {
Firebase.database.enableLogging(configs.enableLogging)
firebase.database.enableLogging(configs.enableLogging)
}
if (configs.rn) {
var AsyncStorage = configs.rn.AsyncStorage
firebase.INTERNAL.extendNamespace({
'INTERNAL': {
'reactNative': {
'AsyncStorage': AsyncStorage
}
}
})
}

const rootRef = Firebase.database().ref()
const rootRef = firebase.database().ref()

const firebase = Object.defineProperty(Firebase, '_', {
const instance = Object.defineProperty(firebase, '_', {
value: {
watchers: {},
config: configs,
Expand Down Expand Up @@ -115,40 +129,40 @@ export default (fbConfig, otherConfig) => next =>
})

const uploadFile = (path, file, dbPath) =>
storageActions.uploadFile(dispatch, firebase, { path, file, dbPath })
storageActions.uploadFile(dispatch, instance, { path, file, dbPath })

const uploadFiles = (path, files, dbPath) =>
storageActions.uploadFiles(dispatch, firebase, { path, files, dbPath })
storageActions.uploadFiles(dispatch, instance, { path, files, dbPath })

const deleteFile = (path, dbPath) =>
storageActions.deleteFile(dispatch, firebase, { path, dbPath })
storageActions.deleteFile(dispatch, instance, { path, dbPath })

const watchEvent = (type, path, storeAs) =>
queryActions.watchEvent(firebase, dispatch, { type, path, storeAs })
queryActions.watchEvent(instance, dispatch, { type, path, storeAs })

const unWatchEvent = (eventName, eventPath, queryId = undefined) =>
queryActions.unWatchEvent(firebase, dispatch, eventName, eventPath, queryId)
queryActions.unWatchEvent(instance, dispatch, eventName, eventPath, queryId)

const login = credentials =>
authActions.login(dispatch, firebase, credentials)
authActions.login(dispatch, instance, credentials)

const logout = () =>
authActions.logout(dispatch, firebase)
authActions.logout(dispatch, instance)

const createUser = (credentials, profile) =>
authActions.createUser(dispatch, firebase, credentials, profile)
authActions.createUser(dispatch, instance, credentials, profile)

const resetPassword = (credentials) =>
authActions.resetPassword(dispatch, firebase, credentials)
authActions.resetPassword(dispatch, instance, credentials)

const confirmPasswordReset = (code, password) =>
authActions.confirmPasswordReset(dispatch, firebase, code, password)
authActions.confirmPasswordReset(dispatch, instance, code, password)

const verifyPasswordResetCode = (code) =>
authActions.verifyPasswordResetCode(dispatch, firebase, code)
authActions.verifyPasswordResetCode(dispatch, instance, code)

firebase.helpers = {
ref: path => Firebase.database().ref(path),
instance.helpers = {
ref: path => firebase.database().ref(path),
set,
uniqueSet,
push,
Expand All @@ -165,13 +179,13 @@ export default (fbConfig, otherConfig) => next =>
verifyPasswordResetCode,
watchEvent,
unWatchEvent,
storage: () => Firebase.storage()
storage: () => firebase.storage()
}

authActions.init(dispatch, firebase)
authActions.init(dispatch, instance)

store.firebase = firebase
firebaseInstance = Object.assign({}, firebase, firebase.helpers)
store.firebase = instance
firebaseInstance = Object.assign({}, instance, instance.helpers)

return store
}
Expand Down