Hi, is there any implementation of remote messages with FCM? All the documentation talks about GCM which is somewhat deprecated.
Something in the line of
https://developers.google.com/cloud-messaging/android/android-migrate-fcm
Ok ive done it myself. Here are all the steps needed to be done.. Im posting in 2 parts:
[STEP 1]
Install the latest code of react-native-push-notification from github (as npm install will not get the latest)
npm install git+https://github.com/zo0r/react-native-push-notification.git
Follow the guide to setup AndroidManifest as on the main page:
https://github.com/zo0r/react-native-push-notification
Also follow the other manual installation mentied there.
[Step 2]
Setup FCM in your project:
https://firebase.google.com/docs/android/setup?authuser=0
[Step 3]
Resolve version conflicts between GCM/FCM etc and react-native-push-notification. For example, in the file: android/build.gradle add the following to allprojects
configurations.all {
resolutionStrategy {
force 'com.google.android.gms:play-services-gcm:12.0.1'
}
}
[Step 4]
Confirm everything is fine so far:
CD to the android folder from shell and run the clean
$> gradlew clean
Ensure you have no errors upto here.
[Step 5]
Make sure local notification is working
[Step 6]
Add senderID from the json file received from google into the PushNotification.configure:
senderID: .........project_info.project_number (this is from the json file you received from FCM setup)
At this point, you should be able to receive 'TOKEN at
onRegister: function(token) {
console.log('TOKEN:', token);
}
2nd part will include how to receive remote message, but ensure this is done upto here
[STEP 6]
Implement the following changes in the dependencies as well as manifest only:
https://developers.google.com/cloud-messaging/android/android-migrate-fcm
https://developers.google.com/cloud-messaging/android/android-migrate-gcmlistener
[STEP 7]
This one is a tough one, and I would request @zo0r to implement it in his code.
/node_module/react-native-push-notification/
a) File: build.gradle
add a dependency:
compile "com.google.firebase:firebase-messaging:$firebaseVer"
Ive set the firebase version via ext in android\build.gradle, upto you to fix it however
b) File:
/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationListenerService.js
at the top add:
import java.util.Map;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
Then change the method onMessageReceived
public void onMessageReceived(RemoteMessage message)
{
String from = message.getFrom();
final Bundle bundle = new Bundle();
for(Map.Entry<String, String> entry : message.getData().entrySet()) {
bundle.putString(entry.getKey(), entry.getValue());
}
//rest of the method from the line **JSONObject data** is the same
c) same file as above:
method: handleRemotePushNotification
comment the condition if (!isForeground) {, (i.e. condition and not the whole block - which means that block will always execute)
[Testing]
1) build and install the app, you will get token in console from chrome or anyother dev tool you are using
2) use postman (or anyother tool) to post to FCM with the token. For example:
POST:
https://fcm.googleapis.com/fcm/send
--Headers--
Authorization:key=<KEY>
Content-Type:application/json
--BODY--
{
"to" : "<TOKEN>",
"time_to_live": 86400,
"collapse_key": "test_type_b",
"delay_while_idle": false,
"notification": {},
"data": {
"subText":"sub title R",
"title":"Notification Heading R",
"message":"Short Message R",
"bigText":"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam",
"color":"#3F81C5"
}
}
[Topic implementation]
To receive topics, all you need to do is subscribe the device for particular topic(s) either at onCreate or later down the stage.
File: android/app/src/main/java/com/{appID}/MainApplication.java`
a) import firebase:
import com.google.firebase.messaging.FirebaseMessaging
b) at the end of onCreate()
FirebaseMessaging.getInstance().subscribeToTopic("TopicXYZ");
--
Now for testing, you will POST with topic name in the to instead of token.
"to": "/topics/TopicXYZ",
is there any update on this? is it available in npm in master?
your changes works like a charm. thanks
@Rah1x thank you very much, this indeed works like a charm! 馃槉 I opened a PR with these changements, can you check it to see if there is no weird code? 馃榿I'm a newbie on Java, never tried it before...
Thank you so much! I was pulling my hair out for two days in a row but your changes did the trick :-) Two minor nit picks though:
FirebaseMessagingService instead of GcmListenerService. The class signature becomespublic class RNPushNotificationListenerService extends FirebaseMessagingService {
<service
android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
If you read carefully in the documentation that @Rah1x linked to, you should understand that you need to change it to
<service
android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
In any case, thanks a dozen! Really helped me out...
I am trying to follow the steps which @Rah1x stated. After implementing Steps 1,2 and 3 I am receiving errors in Android Studio while building. Can anyone please help me track the cause of error!
Here is the error:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:debugCompileClasspath'.
> More than one variant of project :react-native-push-notification matches the consumer attributes:
- Configuration ':react-native-push-notification:debugApiElements' variant android-aidl:
- Found artifactType 'android-aidl' but wasn't required.
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
- Required org.gradle.api.attributes.Usage 'java-api' and found compatible value 'java-api'.
- Configuration ':react-native-push-notification:debugApiElements' variant android-classes:
- Found artifactType 'android-classes' but wasn't required.
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
- Required org.gradle.api.attributes.Usage 'java-api' and found compatible value 'java-api'.
- Configuration ':react-native-push-notification:debugApiElements' variant android-manifest:
- Found artifactType 'android-manifest' but wasn't required.
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
- Required org.gradle.api.attributes.Usage 'java-api' and found compatible value 'java-api'.
- Configuration ':react-native-push-notification:debugApiElements' variant android-renderscript:
- Found artifactType 'android-renderscript' but wasn't required.
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
- Required org.gradle.api.attributes.Usage 'java-api' and found compatible value 'java-api'.
- Configuration ':react-native-push-notification:debugApiElements' variant jar:
- Found artifactType 'jar' but wasn't required.
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
- Required org.gradle.api.attributes.Usage 'java-api' and found compatible value 'java-api'.
BUILD FAILED in 16s
Root>build.gradle
buildscript {
repositories {
mavenLocal()
mavenCentral()
jcenter()
google()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.3.1'
}
}
allprojects {
repositories {
mavenLocal()
mavenCentral()
jcenter()
google()
maven {
url "$rootDir/../node_modules/react-native/android"
}
configurations.all {
resolutionStrategy {
force 'com.google.android.gms:play-services-gcm:15.0.1'
}
}
}
}
App>build.gradle
apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.android.js"
]
apply from: "../../node_modules/react-native/react.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 25
buildToolsVersion "26.0.2"
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
defaultConfig {
applicationId "xxx"
minSdkVersion 19
targetSdkVersion 25
versionCode 4
versionName "1.0.1"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
signingConfigs {
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
applicationVariants.all { variant ->
variant.outputs.each { output ->
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
compile project(':react-native-push-notification')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:25.4.0"
compile "com.facebook.react:react-native:+" // From node_modules
compile project(':react-native-navigation')
compile project(':react-native-vector-icons')
compile ('com.google.android.gms:play-services-gcm:15.0.0') {
force = true;
}
implementation 'com.google.firebase:firebase-core:15.0.2'
implementation 'com.google.firebase:firebase-messaging:15.0.2'
}
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
project.ext.vectoricons = [
iconFontNames: [ 'Ionicons.ttf' ] // Name of the font files you want to copy
]
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
apply plugin: 'com.google.gms.google-services'
@mohdabbas Im not using Android Studio so I'm not sure if its a debugger attached to the project by it, or may be you have devDependencies or anything else thats causing the issue. However, up to step 4 it should be very very smooth
@Rah1x Thank you very much for sharing this. I did all the steps and everything works fine (local and remote notifications). The only problem i have now is with the notification tap event, which is not triggered when i tap on the notification on statusbar. Tap event seems to work only if the app is open and there is a local notification triggered. Can you suggest a possible solution?
Also there are 2 types of behavior for notifications:
{
"to" : "XXXTOKEN",
"data" : {
"body" : "Body text",
"title": "Title of notification from push",
"key_1" : "Data for key one",
"key_2" : "data 2"
}
}{
"to" : "XXXTOKEN",
"notification":{
"body":"test body",
"title":"test title",
"sound":"default"
},
"priority":"high",
"data" : {
"body" : "Body text lorem ipsum",
"title": "Title of notification from push",
"key_1" : "Data for key one",
"key_2" : "data2"
}
}The first one triggers onNotification(). The other one doesnt. (case of app NOT being opened)
@Rah1x same problem for me on Android
Thanks for looking deep into it @krisidmisso
When I was working on the project I guess I didnt notice that my app may still be running in the background thats why it worked even when the app was closed.
Secondly, the reason I used data payload instead of notification is that I wasnt able to customise the notification in the status bar as much as I was able with data.
Anyway, ive stopped working on RN projects for a while, so im sorry I cant figure it out. I hope you guys look deep into it, solve it and post it here..
@Rah1x, I went through the whole steps of implementing fcm. But I am getting the following issue.
Dex: Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/iid/zzc;
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/iid/zzc;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
I think your problem is related to this https://stackoverflow.com/questions/31224276/multiple-dex-files-define-lcom-google-android-gms-internal-zzau - and this https://medium.com/@suchydan/how-to-solve-google-play-services-version-collision-in-gradle-dependencies-ef086ae5c75f - basically I think you need to ensure that your dependencies are on the same version number. You can do that by excluding the problematic external dependencies that are defined in the offending package(s), and replacing them with the correct ones.
In my app/build.gradle I have this, for example:
dependencies {
compile(project(':react-native-push-notification')) {
// don't use dependencies from this project's gradle file, override instead (see below)
// reference
// https://medium.com/@suchydan/how-to-solve-google-play-services-version-collision-in-gradle-dependencies-ef086ae5c75f
exclude group: 'com.google.android.gms', module: 'play-services-gcm'
exclude group: 'com.google.firebase', module: 'firebase-messaging'
}
// overrides for react-native-push-notifications
compile('com.google.firebase:firebase-messaging:15.0.2') {
force = true
}
compile('com.google.android.gms:play-services-gcm:15.0.0') {
force = true
}
}
Good luck! I'm not going to help you debug but this might be helpful anyway.
@Rah1x You proposed to comment if (!isForeground) { out which was implemented in PR #717 by @avencat. Can you explain the rationale behind it?
With the current release (v3.1.1) notifications are sent to the notification center even if the app is in foreground. AFAIK, this is not related to Firebase.
@rodrigobdz I wanted the block of code inside this condition to always execute, whether the app is in foreground of not.
@Rah1x I can clearly infer that from the code but this is not always desired. The task was to add Firebase support, not to change the module鈥檚 current behavior.
If this change is unrelated to Firebase, then it should be reverted.
@rodrigobdz You can leave it open if you like, its up to you. I posted a work-around when there was no hope and that to be after spending a week googling and then figuring it out myself eventually (no thanks to react-native-push-notification!).
Secondly, the idea was to handleRemotePushNotification even if the app is in foreground. At that time that part of the code was blocking the notifications when it was in foreground. I hope its been fixed now.
And yes, it was absolutely related to Firebase.
@Rah1x Thank you for your contribution. My intention is not to be ungrateful.
I am just trying to understand how receiving notifications in foreground would contribute to integrating Firebase which was not clear to me from your response.
@Gp2mv3 Is receiving notifications when the app is in foreground desired behavior?
@Rah1x Thanks ! Following your steps solved a bug where the notifications woldnt't show if the app was in foreground (Android)
her @Rah1x
i followed your steps.
but i got this error from the last 2 days,
Please help me to resolve this.
Error:
E/AndroidRuntime: FATAL EXCEPTION: Firebase-RNPushNotificationListenerService
Process: com.goldspring, PID: 21480
java.lang.AbstractMethodError: abstract method "void com.google.firebase.iid.zzb.zzd(android.content.Intent)"
at com.google.firebase.iid.zzg.run(Unknown Source:26)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at com.google.android.gms.common.util.concurrent.zza.run(Unknown Source:6)
at java.lang.Thread.run(Thread.java:764)
My Project/build.gradle file is:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
def DEFAULT_COMPILE_SDK_VERSION = 23
def DEFAULT_BUILD_TOOLS_VERSION = "23.0.1"
def DEFAULT_TARGET_SDK_VERSION = 26
def DEFAULT_SUPPORT_LIB_VERSION = "23.1.1"
def DEFAULT_GOOGLE_PLAY_SERVICES_VERSION = "+"
def DEFAULT_FIREBASE_MESSAGING_VERSION = "9.6.1"
ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 16
compileSdkVersion = 27
targetSdkVersion = 26
supportLibVersion = "27.1.1"
googlePlayServicesVersion = project.hasProperty('googlePlayServicesVersion') ? project.googlePlayServicesVersion : DEFAULT_GOOGLE_PLAY_SERVICES_VERSION
firebaseVersion = project.hasProperty('googlePlayServicesVersion') ? project.googlePlayServicesVersion : DEFAULT_GOOGLE_PLAY_SERVICES_VERSION
androidMapsUtilsVersion = "0.5+"
}
repositories {
mavenLocal()
mavenCentral()
jcenter()
google()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.google.gms:google-services:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
//
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 27 //do this in android/app/build.gradle too
buildToolsVersion '27.0.3' //do this in android/app/build.gradle too
}
}
}
}
allprojects {
repositories {
mavenLocal()
mavenCentral()
google()
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'
}
}
configurations.all {
resolutionStrategy {
force 'com.google.android.gms:play-services-gcm:15.0.1'
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.4'
distributionUrl = distributionUrl.replace("bin", "all")
}
App/build.gradle file is :
apply plugin: "com.android.application"
import com.android.build.OutputFile
def DEFAULT_COMPILE_SDK_VERSION = 27
def DEFAULT_BUILD_TOOLS_VERSION = "27.0.3"
def DEFAULT_TARGET_SDK_VERSION = 27
def DEFAULT_SUPPORT_LIB_VERSION = "27.1.1"
def DEFAULT_GOOGLE_PLAY_SERVICES_VERSION = "+"
def DEFAULT_FIREBASE_MESSAGING_VERSION = "+"
/**
react-native bundle with the correct arguments during the Android buildapply from: "../../node_modules/react-native/react.gradle" line.project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
/**
/**
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.goldspring"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
aaptOptions
{
cruncherEnabled = false
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile project(':react-native-push-notification')
implementation project(':react-native-image-resizer')
implementation project(':react-native-image-picker')
compile project(':react-native-fs')
//map data
implementation(project(':react-native-maps')){
exclude group: 'com.google.android.gms', module: 'play-services-base'
exclude group: 'com.google.android.gms', module: 'play-services-maps'
}
implementation "com.google.android.gms:play-services-base:16.0.1"
implementation "com.google.android.gms:play-services-maps:16.0.0"
// map end
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-messaging:17.3.0'
compile ("com.google.android.gms:play-services-gcm:+") {
force = true
}
compile ("com.google.firebase:firebase-messaging:12.0.1") {
force = true
}
compile project(':react-native-fbsdk')
implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.google.firebase:firebase-messaging:17.1.0'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile project(':react-native-gesture-handler')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
Manifest File is:
<!-- < Only if you're using GCM or localNotificationSchedule() > -->
<service
android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/>
<!-- < Only if you're using GCM or localNotificationSchedule() > -->
<!-- </ Only if you're using GCM or localNotificationSchedule() > -->
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.example.gcm" />
</intent-filter>
</receiver>
<!-- < Else > -->
Can you please help me ?
Hey,
I havent looked into it for about an year, so im not sure if with the latest versions everything will still work. May be someone who recently implemented it can reply to you.
Either its the version problem, or you have implemented too many things one of which is blocking Firebase's RNPushNotificationListenerService.
Try to start a new project just to see if notification is working. Because your build.gradle is way out compared to where I left mine.
Most helpful comment
Ok ive done it myself. Here are all the steps needed to be done.. Im posting in 2 parts:
[STEP 1]
Install the latest code of
react-native-push-notificationfrom github (as npm install will not get the latest)npm install git+https://github.com/zo0r/react-native-push-notification.git
Follow the guide to setup AndroidManifest as on the main page:
https://github.com/zo0r/react-native-push-notification
Also follow the other manual installation mentied there.
[Step 2]
Setup FCM in your project:
https://firebase.google.com/docs/android/setup?authuser=0
[Step 3]
Resolve version conflicts between GCM/FCM etc and react-native-push-notification. For example, in the file:
android/build.gradleadd the following toallprojects[Step 4]
Confirm everything is fine so far:
CD to the android folder from shell and run the clean
$> gradlew cleanEnsure you have no errors upto here.
[Step 5]
Make sure local notification is working
[Step 6]
Add senderID from the json file received from google into the
PushNotification.configure:senderID: .........project_info.project_number(this is from the json file you received from FCM setup)At this point, you should be able to receive
'TOKENat2nd part will include how to receive remote message, but ensure this is done upto here