How can FirebaseMessagingService class can trigger subclass's overrided function?

Viewed 55

I'm developing an SDK and want to develop a logic like Firebase messaging service. For example, if I add the MyMessageingService class which extends FirebaseMessagingService, inside the <service> tags (in this case FirebaseMessagingService is a super class and MyMessagingService is a sub class) here my question arises.

My question is how does firebasemessaging service trigger onNewToken function in subclass?

As a result, what I want to do is to trigger a function of subclass in the application side when people who will use the SDK I developed added my service class to the AndroidManifest.xml folder of their application, just like in FirebaseMessagingService.

Thanks in advance...

1 Answers

The first big hurdle you will have to deal with is how you are going to get your service installed and constantly running on a device (FCM has elevated permissions that a normal application will not have thanks to Google Play Services)

If you somehow manage to get around that then you can take a look at the source of FirebaseMessagingService and you will see that Intents get sent to the service and based on that action the service then calls the methods you see in the FCM API (onMessageReceived etc.)

Related