Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android: fcm in library module

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 ?

like image 716
Chintan Soni Avatar asked Apr 11 '17 04:04

Chintan Soni


Video Answer


1 Answers

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.

like image 170
Chintan Soni Avatar answered Sep 20 '22 08:09

Chintan Soni