Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Libin Lu authored Jun 13, 2018
1 parent 9b894ef commit 1525b51
Showing 1 changed file with 72 additions and 3 deletions.
75 changes: 72 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,68 @@ https://github.com/evollu/react-native-fcm/blob/master/Examples/simple-fcm-clien
...
```

- Edit `{YOUR_MAIN_PROJECT}/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
// in the individual module build.gradle files
}
}

allprojects {
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
+ compileSdkVersion 27
+ buildToolsVersion "27.0.3"

defaultConfig {
applicationId "com.google.firebase.quickstart.fcm"
minSdkVersion 16
+ targetSdkVersion 27
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}

dependencies {
+ compile project(':react-native-fcm')
+ compile 'com.google.firebase:firebase-core:10.0.1' //this decides your firebase SDK version
+ compile 'com.google.firebase:firebase-messaging:10.0.1'
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
}

//bottom
+ apply plugin: "com.google.gms.google-services"
```
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`
```diff
...
Expand All @@ -122,6 +173,24 @@ public class MainActivity extends ReactActivity {
}
```

- Make sure in `MainApplication.java` you have
```diff
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new MapsPackage(),
+ new FIRMessagingPackage()
);
}

+ @Override
+ public void onCreate() { // <-- Check this block exists
+ super.onCreate();
+ SoLoader.init(this, /* native exopackage */ false); // <-- Check this line exists within the block
+ }
```

### Config for notification and `click_action` in Android

To allow android to respond to `click_action`, you need to define Activities and filter on specific intent. Since all javascript is running in MainActivity, you can have MainActivity to handle actions:
Expand Down

0 comments on commit 1525b51

Please sign in to comment.