Commit 35893bb0 authored by Libin Lu's avatar Libin Lu Committed by GitHub

Merge pull request #1012 from windhamwong/patch-1

Update README.md
parents c35a8539 e165b826
...@@ -39,33 +39,67 @@ I've created [an example project](https://github.com/evollu/react-native-fcm/tre ...@@ -39,33 +39,67 @@ I've created [an example project](https://github.com/evollu/react-native-fcm/tre
### FCM config file ### FCM config file
In [firebase console](https://console.firebase.google.com/), you can: In [firebase console](https://console.firebase.google.com/), you can:
- for **Android**: download `google-services.json` file and place it in `android/app` directory - for **Android**: download `google-services.json` file and place it in `android/app` directory.
- for **iOS**: download `GoogleService-Info.plist` file and place it in `/ios/your-project-name` directory (next to your `Info.plist`) - for **iOS**: download `GoogleService-Info.plist` file and place it in `/ios/your-project-name` directory (next to your `Info.plist`)
Make sure you have certificates setup by following Make sure you have certificates setup by following
https://firebase.google.com/docs/cloud-messaging/ios/certs https://firebase.google.com/docs/cloud-messaging/ios/certs
---
## Android Configuration ## Android Configuration
- As `react-native link` sometimes has glitches, make sure you have this line added - As `react-native link` sometimes has glitches, make sure you have this line added
https://github.com/evollu/react-native-fcm/blob/master/Examples/simple-fcm-client/android/app/src/main/java/com/google/firebase/quickstart/fcm/MainApplication.java#L28 ### Edit `android/build.gradle`:
**NOTE:** The followed line may not be up-to-dated. Please refer to https://firebase.google.com/docs/android/setup
- Edit `android/build.gradle`:
```diff
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
+ classpath 'com.google.gms:google-services:3.0.0'
``` ```
buildscript {
repositories {
// ...
google() // Google's Maven repository
}
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:4.0.2' // google-services plugin
}
}
- Edit `android/app/build.gradle`. Add at the bottom of the file: allprojects {
```diff // ...
apply plugin: "com.android.application" repositories {
... // ...
+ apply plugin: 'com.google.gms.google-services' google() // Google's Maven repository
}
}
``` ```
- Edit `android/app/src/main/AndroidManifest.xml`: ### Edit `android/app/build.gradle`:
**NOTE:** Please refer to https://firebase.google.com/docs/android/setup
```
dependencies {
// ...
compile project(':react-native-fcm')
// ...
// Automatically selecting the latest available version
implementation 'com.google.firebase:firebase-core'
implementation 'com.google.firebase:firebase-messaging'
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
```
### Edit `android/app/src/main/AndroidManifest.xml`:
**NOTE:** The resource `@mipmap/ic_notif` is referring to `android/app/src/res/mipmap-<resolution>/` folder. Feel free to change the filename if you have a customised icon for notification.
```diff ```diff
<application <application
...@@ -90,42 +124,12 @@ https://github.com/evollu/react-native-fcm/blob/master/Examples/simple-fcm-clien ...@@ -90,42 +124,12 @@ https://github.com/evollu/react-native-fcm/blob/master/Examples/simple-fcm-clien
... ...
``` ```
- Edit `{YOUR_MAIN_PROJECT}/build.gradle`: ### Edit `android/app/build.gradle`:
```diff
buildscript {
repositories {
jcenter()
+ maven {
+ url 'https://maven.google.com/'
+ name 'Google'
+ }
}
dependencies {
+ classpath 'com.android.tools.build:gradle:3.1.1'
+ classpath 'com.google.gms:google-services:3.1.2'
// NOTE: Do not place your application dependencies here; they belong **NOTE:** after v16.0.0, Android target SDK has be to >= 26 and build tool has to be >= 26.0.x
// in the individual module build.gradle files
}
}
allprojects { **NOTE:** Make sure the version matches this library.
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
+ maven {
+ url 'https://maven.google.com/'
+ name 'Google'
+ }
}
}
```
- Edit `{YOUR_MAIN_PROJECT}/app/build.gradle`:
```diff ```diff
+ compileSdkVersion 27 + compileSdkVersion 27
+ buildToolsVersion "27.0.3" + buildToolsVersion "27.0.3"
...@@ -152,7 +156,7 @@ allprojects { ...@@ -152,7 +156,7 @@ allprojects {
``` ```
If you are using other firebase libraries, check this for solving dependency conflicts https://github.com/evollu/react-native-fcm/blob/master/Examples/simple-fcm-client/android/app/build.gradle#L133 If you are using other firebase libraries, check this for solving dependency conflicts https://github.com/evollu/react-native-fcm/blob/master/Examples/simple-fcm-client/android/app/build.gradle#L133
- Edit `android/settings.gradle` ### Edit `android/settings.gradle`
```diff ```diff
... ...
+ include ':react-native-fcm' + include ':react-native-fcm'
...@@ -173,7 +177,10 @@ public class MainActivity extends ReactActivity { ...@@ -173,7 +177,10 @@ public class MainActivity extends ReactActivity {
} }
``` ```
- Make sure in `MainApplication.java` you have ### Make sure in `MainApplication.java` you have the code below:
**NOTE:** The packages listed inside should appear once only. `react-native link` sometimes can mess up this part, please remove duplicated packeges.
```diff ```diff
@Override @Override
protected List<ReactPackage> getPackages() { protected List<ReactPackage> getPackages() {
......
...@@ -3,9 +3,9 @@ apply plugin: 'com.android.library' ...@@ -3,9 +3,9 @@ apply plugin: 'com.android.library'
def DEFAULT_COMPILE_SDK_VERSION = 27 def DEFAULT_COMPILE_SDK_VERSION = 27
def DEFAULT_BUILD_TOOLS_VERSION = "27.0.3" def DEFAULT_BUILD_TOOLS_VERSION = "27.0.3"
def DEFAULT_TARGET_SDK_VERSION = 27 def DEFAULT_TARGET_SDK_VERSION = 27
def DEFAULT_GOOGLE_PLAY_SERVICES_VERSION = "12.+" def DEFAULT_GOOGLE_PLAY_SERVICES_VERSION = "+"
def DEFAULT_FIREBASE_CORE_VERSION = "12.+" def DEFAULT_FIREBASE_CORE_VERSION = "+"
def DEFAULT_FIREBASE_MESSAGING_VERSION = "12.+" def DEFAULT_FIREBASE_MESSAGING_VERSION = "+"
android { android {
compileSdkVersion project.hasProperty('compileSdkVersion') ? project.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION compileSdkVersion project.hasProperty('compileSdkVersion') ? project.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment