Reputation: 53
I'm currently trying to implement push notifications in our application.
So we have three modules.
I gave them obviously names. App 1 and 2 have a dependency on the logic module. This module contains ALL the logic for both apps. Now I want App specific notifications to users that are logged in on App 1 OR App 2.
Problem:
I can't put the firebase logic into the Logic module since this module is configured as a lib module and isn't configured as an App. Now I have to put the firebase logic in App 1 and 2, but I can't access this logic from the Logic module since App 1 and 2 have a dependency on the Logic module and not the other way around.
Firebase requires a google-services.json for every app connected, this file is required to generate a user specific pushtoken.
Is there a way to configure this so that I can generate user specific tokens for push notifications? So after a user logs in a pushtoken has to be generated according to the App and user so this user can get a notifcation on said device which he/she is logged in.
I hope this is clear enough.
Upvotes: 5
Views: 4129
Reputation: 646
A more updated answer: You CAN create a module of Firebase Cloud Notifications separated from an app client To make it work you have to:
On Module (Library):
implementation 'com.google.firebase:firebase-messaging:17.6.0'
in module gradle fileAdd
<service android:name=".firebase.YourNotificationService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
in the Android Manifest file.
On your app client:
apply plugin: 'com.google.gms.google-services'
on the last line in your module gradle fileimplementation 'com.google.firebase:firebase-core:16.0.8'
in your module gradle fileimplementation'com.google.firebase:firebase-messaging:17.6.0'
in your module gradle fileclasspath 'com.google.gms:google-services:4.2.0'
inside "dependencies" block of your project gradle fileAnd that's it. That will work.
Upvotes: 0
Reputation: 317477
There should be nothing stopping you from implementing what you're describing.
You can still add Firebase SDK dependencies to a library module. You just can't use the google-services plugin on it - that belongs only on application modules.
Upvotes: 3