-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementation of remote messages with FCM #697
Comments
Ok ive done it myself. Here are all the steps needed to be done.. Im posting in 2 parts: [STEP 1] Follow the guide to setup AndroidManifest as on the main page: Also follow the other manual installation mentied there. [Step 2] [Step 3]
[Step 4] [Step 5] [Step 6] At this point, you should be able to receive
2nd part will include how to receive remote message, but ensure this is done upto here |
[STEP 6] [STEP 7]
b) File: at the top add: Then change the method
c) same file as above: |
[Testing]
--Headers--
--BODY--
|
[Topic implementation] To receive topics, all you need to do is subscribe the device for particular topic(s) either at File: android/app/src/main/java/com/{appID}/MainApplication.java` a) import firebase: b) at the end of onCreate() -- |
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:
public 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:
Root>build.gradle
App>build.gradle
|
@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:
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 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.
:app:transformClassesWithDexForDebug FAILED |
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 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 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’s current behavior. |
@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 And yes, it was absolutely related to Firebase. |
@Rah1x Thank you for your contribution. My intention is not to be ungrateful. @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 Error: E/AndroidRuntime: FATAL EXCEPTION: Firebase-RNPushNotificationListenerService My Project/build.gradle file is: // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript {
} subprojects { allprojects { task wrapper(type: Wrapper) { App/build.gradle file is : apply plugin: "com.android.application" def DEFAULT_COMPILE_SDK_VERSION = 27
project.ext.react = [ apply from: "../../node_modules/react-native/react.gradle" /**
/**
android {
} dependencies {
implementation "com.google.android.gms:play-services-base:16.0.1"
compile project(':react-native-fbsdk') // Run this once to be able to run the application with BUCK apply plugin: 'com.google.gms.google-services' Manifest File is:
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 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. |
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
The text was updated successfully, but these errors were encountered: