Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to inject a repo into FirebaseMessagingService class

I want to send client FCM token to my server when the token is ready, so I need my user repository in MyFirebaseMessagingService.

The problem is FirebaseMessagingService needs default empty constructor. So How can inject my userRepo in the MyFirebaseMessagingService class? I'm using Koin as dependency injection

like image 255
FarshidABZ Avatar asked Oct 26 '25 10:10

FarshidABZ


1 Answers

I found my answer:

class FCMService: FirebaseMessagingService(), KoinComponent {
  private val userRepository: UserRepository by inject()
  ...
}
like image 163
FarshidABZ Avatar answered Oct 29 '25 00:10

FarshidABZ



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!