Merge branch 'master' into v2

# Conflicts:
#	bin/cocoapods.sh
#	docs/installation-ios.md
#	ios/Podfile.template
This commit is contained in:
Chris Bianca 2017-06-16 13:45:45 +01:00
commit 39041637eb
10 changed files with 121 additions and 190 deletions

View File

@ -35,7 +35,28 @@ RNFirebase provides a JavaScript bridge to the native Firebase SDKs for both iOS
The native SDKs also allow us to hook into device sdk's which are not possible with the web SDK, for example crash reporting, offline realtime database support, analyics and more!
<hr>
---
### Supported Firebase Features
> The Web SDK column indicates what modules from the Firebase Web SDK are usable with React Native.
| Firebase Features | v1 | [v2](https://github.com/invertase/react-native-firebase/pull/130) | Web SDK |
| ---------------------- | :---: | :---: | :---: |
| Analytics             | ✅ | ✅ | ❌ |
| Cloud Messaging | ✅ | ✅ | ❌ |
| Authentication | ✅ | ✅ | ✅ |
| Realtime Database | ✅ | ✅ | ✅ |
| - Offline Persistance | ✅ | ✅ | ❌ |
| Storage | ✅ | ✅ | ❌ |
| Performance Monitoring | ✅ | ✅ | ❌ |
| Crash Reporting | ✅ | ✅ | ❌ |
| Remote Config | ✅ | ✅ | ❌ |
| App Indexing           | ❌ | ❌ | ❌ |
| Dynamic Links | ❌ | ❌ | ❌ |
| Invites | ❌ | ❌ | ❌ |
| AdMob | ❌ | ✅ | ❌ |
---
### License

View File

@ -1,63 +0,0 @@
#!/bin/sh
ios_dir=`pwd`/ios
if [ -d ios_dir ]
then
exit 0
fi
podfile="$ios_dir/Podfile"
template=`pwd`/node_modules/react-native-firebase/ios/Podfile.template
project_name=$(node -pe "require('./package.json').name")
echo "Checking Podfile in iOS project $project_name ($podfile)"
if [ -f $podfile ]
then
echo ""
echo "Found an existing Podfile, Do you want to override it? [N/y]"
read generate_env_file
if [ "$generate_env_file" != "y" ]
then
echo "Add the following pods":
echo ""
echo ""
cat $template
echo ""
echo ""
echo "and run 'pod install' to install RNFirebase for iOS"
exit 0
fi
rm -f $podfile
rm -f "$podfile.lock"
fi
echo "Adding Podfile to iOS project"
touch ios/Podfile
cat >ios/Podfile <<EOL
target '${project_name}' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for '${project_name}'
end
# RNFirebase
pod 'Firebase/Auth'
pod 'Firebase/Analytics'
pod 'Firebase/AppIndexing'
pod 'Firebase/Core'
pod 'Firebase/Crash'
pod 'Firebase/Database'
pod 'Firebase/DynamicLinks'
pod 'Firebase/Messaging'
pod 'Firebase/RemoteConfig'
pod 'Firebase/Storage'
EOL
echo "Installing Pods"
pod install --project-directory=ios

View File

@ -1,15 +0,0 @@
#!/bin/sh
## https://github.com/auth0/react-native-lock/blob/master/bin/prepare.sh
echo "Preparing to link react-native-firebase for iOS"
echo "Checking CocoaPods..."
has_cocoapods=`which pod >/dev/null 2>&1`
if [ -z "$has_cocoapods" ]
then
echo "CocoaPods already installed"
else
echo "Installing CocoaPods..."
gem install cocoapods
fi

View File

@ -24,3 +24,24 @@ Although the [Firebase Web SDK](https://www.npmjs.com/package/firebase) library
RNFirebase provides a JavaScript bridge to the native Firebase SDKs for both iOS and Android. Firebase will run on the native thread, allowing the rest of your app to run on the [JS thread](https://facebook.github.io/react-native/docs/performance.html#javascript-frame-rate). The Firebase Web SDK also runs on the JS thread, therefore potentially affecting the frame rate causing jank with animations, touch events etc. All in all, RNFirebase provides much faster performance (~2x) over the web SDK.
The native SDKs also allow us to hook into device sdk's which are not possible with the web SDK, for example crash reporting, offline realtime database support, analyics and more!
---
## Supported Firebase Features
| Firebase Features | v1 | [v2](https://github.com/invertase/react-native-firebase/pull/130) | Web SDK |
| ---------------------- | :---: | :---: | :---: |
| Analytics             | ✅ | ✅ | ❌ |
| Cloud Messaging | ✅ | ✅ | ❌ |
| Authentication | ✅ | ✅ | ✅ |
| Realtime Database | ✅ | ✅ | ✅ |
| - Offline Persistance | ✅ | ✅ | ❌ |
| Storage | ✅ | ✅ | ❌ |
| Performance Monitoring | ✅ | ✅ | ❌ |
| Crash Reporting | ✅ | ✅ | ❌ |
| Remote Config | ✅ | ✅ | ❌ |
| App Indexing           | ❌ | ❌ | ❌ |
| Dynamic Links | ❌ | ❌ | ❌ |
| Invites | ❌ | ❌ | ❌ |
| AdMob | ❌ | ✅ | ❌ |

View File

@ -1,7 +1,7 @@
- Getting started
- [Initial setup](/initial-setup)
- [Installation - iOS](/installation-ios)
- [Installation - Android](/installation-android)
- [Firebase Setup](/firebase-setup.md)
- [Usage](/usage)
- Contributing

View File

@ -1,20 +0,0 @@
# Firebase Setup
The RNFirebase library is intended on making it easy to work with [Firebase](https://firebase.google.com/) 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](https://firebase.google.com/console)
![Create a new project](https://i.imgur.com/KbbamwD.png)
Each platform uses a different setup method after creating the project.
## iOS
For iOS, ensure you've followed the instructions provided by Firebase; adding your [GoogleService-Info.plist](https://github.com/invertase/react-native-firebase/blob/master/tests/ios/GoogleService-Info.plist)
file to the project, and [configuring your AppDelegate](https://github.com/invertase/react-native-firebase/blob/master/tests/ios/ReactNativeFirebaseDemo/AppDelegate.m#L20).
## Android
For Android, ensure you've followed the instructions provided by Firebase; adding your [google-services.json](https://github.com/invertase/react-native-firebase/blob/master/tests/android/app/google-services.json)
file to the project, installing the [google-services](https://github.com/invertase/react-native-firebase/blob/master/tests/android/build.gradle#L9)
plugin and applying **at the end** of your [`build.gradle`](https://github.com/invertase/react-native-firebase/blob/master/tests/android/app/build.gradle#L144).

21
docs/initial-setup.md Normal file
View File

@ -0,0 +1,21 @@
# Install the library
`npm install --save react-native-firebase`
# Initial Setup
The RNFirebase library is intended on making it easy to work with [Firebase](https://firebase.google.com/) 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](https://firebase.google.com/console)
![Create a new project](https://i.imgur.com/KbbamwD.png)
Each platform uses a different setup method after creating the project.
## iOS
For iOS, follow the instructions [here](/installation-ios).
## Android
For Android, follow the instructions [here](/installation-android).

View File

@ -1,90 +1,65 @@
# iOS Installation
## 1) Setup google-services.plist and dependencies
Setup the `google-services.plist` file and Firebase ios frameworks first; check out the relevant Firebase docs [here](https://firebase.google.com/docs/ios/setup#frameworks).
## 1) Setup GoogleService-Info.plist
Setup the `GoogleService-Info.plist` file by following the instructions and adding it to the root of your project at `ios/[YOUR APP NAME]/GoogleService-Info.plist` [here](https://firebase.google.com/docs/ios/setup#add_firebase_to_your_app).
### 1.1) Initialisation
Make sure you've added the following to the top of your `ios/[YOUR APP NAME]]/AppDelegate.m` file:
`#import <Firebase.h>`
and this to the `didFinishLaunchingWithOptions:(NSDictionary *)launchOptions` method:
and this to the `didFinishLaunchingWithOptions:(NSDictionary *)launchOptions` method before the `return` statement:
`[FIRApp configure];`
## 2) Link RNFirebase
There are multiple ways to install RNFirebase depending on how your project is currently setup:
Unfortunately, due to the fact that Firebase is much easier to setup using Cocoapods, `react-native link` is not recommended as it is not customisable enough for our needs and we have had numerous problems reported.
### 2.1) You already use Cocoapods and have React Native installed as a pod
Simply add the following to your `Podfile`:
### 2.0) If you don't already have Cocoapods set up
Follow the instructions to install Cocoapods and create your Podfile [here](https://firebase.google.com/docs/ios/setup#add_the_sdk).
```ruby
# Required by RNFirebase - you should already have some of these from step 1.
pod 'Firebase/Auth'
pod 'Firebase/Analytics'
pod 'Firebase/AppIndexing'
pod 'Firebase/Core'
pod 'Firebase/Crash'
pod 'Firebase/Database'
pod 'Firebase/DynamicLinks'
pod 'Firebase/Messaging'
pod 'Firebase/RemoteConfig'
pod 'Firebase/Storage'
pod 'RNFirebase', :path => '../node_modules/react-native-firebase'
```
**NOTE: The Podfile needs to be initialised in the `ios` directory of your project.**
### 2.2) You're not using Cocoapods or don't have React Native installed as a pod (Automatic install)
#### Troubleshooting
1) When running `pod install` you may encounter an error saying that a `tvOSTests` target is declared twice. This appears to be a bug with `pod init` and the way that react native is set up.
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.
**Resolution:**
- Open your Podfile
- Remove the duplicate `tvOSTests` target nested within the main project target
- Re-run `pod install`.
```bash
react-native link react-native-firebase
```
2) When running `pod install` you may encounter a number of warnings relating to `target overrides 'OTHER_LDFLAGS'`.
#### cocoapods
**Resolution:**
- Open Xcode
- Select your project
- For each target:
-- Select the target
-- Click Build settings
-- Search for `other linker flags`
-- Add `$(inherited)` as the top line if it doesn't already exist
- Re-run `pod install`
We've automated the process of setting up with cocoapods. This will happen automatically upon linking the package with `react-native-cli`.
3) When running `pod install` you may encounter a warning that a default iOS platform has been assigned. If you wish to specify a different minimum version:
Update the newly installed pods once the linking is done:
**Resolution**
- Open your Podfile
- Uncomment the `# platform :ios, '9.0'` line by removing the `#` character
- Change the version as required
```bash
cd ios && pod update --verbose
```
**NOTE: You need to use the `ios/[YOUR APP NAME].xcworkspace` instead of the `ios/[YOUR APP NAME].xcproj` file from now on.**
### 2.3) You're not using Cocoapods or don't have React Native installed as a pod (Manual install)
If you prefer not to use `react-native link`, we can manually link the package together with the following steps, after `npm install`:
**A.** In XCode, right click on `Libraries` and find the `Add Files to [project name]`.
![Firebase.xcodeproj add to files](https://cloud.githubusercontent.com/assets/5347038/24249673/0fccdbec-0fcc-11e7-83eb-c058f8898525.png)
**B.** Add the `node_modules/react-native-firebase/ios/Firebase.xcodeproj`
![Firebase.xcodeproj in Libraries listing](https://cloud.githubusercontent.com/assets/21329063/24249440/9494e19c-0fd3-11e7-95c0-c2baa85092e8.png)
**C.** Ensure that the `Build Settings` of the `RNFirebase.xcodeproj` project is ticked to _All_ and it's `Header Search Paths` include both of the following paths _and_ are set to _recursive_:
1. `$(SRCROOT)/../../react-native/React`
2. `$(SRCROOT)/../node_modules/react-native/React`
3. `${PROJECT_DIR}/../../../ios/Pods`
![Recursive paths](https://cloud.githubusercontent.com/assets/21329063/24250349/da91284c-0fd6-11e7-8328-6008e462039e.png)
**D.** 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 RNFirebase 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:
### 2.1) Add the required pods
Simply add the following to your `Podfile` either at the top level, or within the main project target:
```ruby
# Required by RNFirebase
pod 'Firebase/Auth'
pod 'Firebase/Analytics'
pod 'Firebase/AppIndexing'
pod 'Firebase/Core'
pod 'RNFirebase', :path => '../node_modules/react-native-firebase'
# [OPTIONAL PODS] - comment out pods for firebase products you won't be using.
pod 'Firebase/AdMob'
pod 'Firebase/Analytics'
pod 'Firebase/Auth'
pod 'Firebase/Crash'
pod 'Firebase/Database'
pod 'Firebase/DynamicLinks'
@ -93,10 +68,27 @@ pod 'Firebase/RemoteConfig'
pod 'Firebase/Storage'
```
Then you can run `(cd ios && pod install)` to get the pods opened.
If you are new to Cocoapods or do not already have React installed as a pod, then add Yoga and React to your `Podfile` as follows:
```ruby
pod "Yoga", :path => "../node_modules/react-native/ReactCommon/yoga"
pod 'React', :path => '../node_modules/react-native', :subspecs => [
'BatchedBridge', # Required For React Native 0.45.0+
'Core',
# Add any other subspecs you want to use in your project
]
```
Run `pod install`.
**NOTE: You need to use the `ios/[YOUR APP NAME].xcworkspace` instead of the `ios/[YOUR APP NAME].xcproj` file from now on.**
#### Troubleshooting
1) You receive an error `No podspec found for 'RNFirebase'`
**Resolution**
- Run `npm install --save react-native-firebase` from the root of your project
## 3) Cloud Messaging (optional)
If you plan on using [Firebase Cloud Messaging](https://firebase.google.com/docs/cloud-messaging/) then, you need to:
@ -146,13 +138,13 @@ Add the following methods:
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo
fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
[RNFirebaseMessaging didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}
```
### 3.5) Debugging
If you're having problems with messages not being received, check out the following blog post for help:
https://firebase.googleblog.com/2017/01/debugging-firebase-cloud-messaging-on.html
```

View File

@ -1,14 +0,0 @@
pod 'Firebase/Core'
# [OPTIONAL PODS] - comment out pods for firebase products you won't be using.
pod 'Firebase/Auth'
pod 'Firebase/Crash'
pod 'Firebase/Storage'
pod 'Firebase/Database'
pod 'Firebase/Messaging'
pod 'Firebase/Analytics'
pod 'Firebase/Performance'
pod 'Firebase/RemoteConfig'
# END [OPTIONAL PODS]
pod 'RNFirebase', :path => '../node_modules/react-native-firebase'

View File

@ -56,18 +56,6 @@
"react": "*",
"react-native": ">= 0.40.0"
},
"rnpm": {
"commands": {
"prelink": "node_modules/react-native-firebase/bin/prepare.sh",
"postlink": "node_modules/react-native-firebase/bin/cocoapods.sh"
},
"ios": {
"project": "ios/RNFirebase.xcodeproj"
},
"android": {
"packageInstance": "new RNFirebasePackage()"
}
},
"devDependencies": {
"babel-eslint": "^7.0.0",
"babel-jest": "^14.1.0",