I am facing a weird issue integrating Firebase Cloud Messaging in a library module. I am working on a library project in which I need to handle notifications right coming from the FCM Server from the library itself. I am not aware if it is possible or not.
Steps I followed:
- I created Project on Firebase Console.
- Inside the project, I created app with package same as my library package.
- I downloaded and put
google-services.json
in library module.
- I have applied the dependency in gradle of library module.
- Now, I have initialized my library module in app module. I am also getting log of generated device token from
FirebaseInstanceIdService
.
Problem: When I try to send push from Firebase Console, I am not receiving any Notification.
Have anyone faced such issue and could help me with this ?
So, after running a lot through trial and error method, I succeeded in getting Notifications.
Things to be noted:
- You cannot just integrate Firebase Cloud Notifications in library module.
- Client app module who will be using this library module will have
google-services.json
file in his directory and not in library module directory.
- Client app module gradle will be having below line in it and not in library module gradle:
apply plugin: 'com.google.gms.google-services'
So, once I made those two changes, I was able to get Notifications.
FCM clients require devices running Android 2.3 or higher that also
have the Google Play Store app installed, or an emulator running
Android 2.3 with Google APIs.
If you are Using an Emulator Please Check whether Google APIs were installed or Not.
Integrating FCM using Android Studio is very easy,
You have to only ,
Tool->>Firebase->>on the Right panel ->>Choose cloud Messaging.
Setup-->Firebase cloud messaging.
Then you have to follow point number 1,2,3.
And you have to also register your app to Firebase console also as you already status.