CleverTap / clevertap-android-sdk

CleverTap Android SDK

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for a hook/ helper methods for listening FirebaseMessagingService

nakshay opened this issue · comments

Is your feature request related to a problem? Please describe.
Currently the docs https://developer.clevertap.com/docs/react-native-push-notification says include below code in androidmanifest.xml file , the problem is if there is another library using firebase integration or app itself has any custom receiver then it will be a problem , since only one listener can be registered at a time.

<application>
         ....
         ....
        <service android:name="com.clevertap.android.sdk.pushnotification.fcm.FcmMessageListenerService"  android:exported="true">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>

 </application>

Describe the solution you'd like

There should be an additional hook/helper method which can be called from app, and app will have its own subclass that can be registered in androidmanifest.xml, this way app will decide on invoking the desired SDK.

Describe alternatives you've considered

This SO question,

https://stackoverflow.com/questions/47659458/android-can-an-android-app-have-multiple-firebasemessagingservices

Quoting answer here :

Your library's manifest should not have a FirebaseMessagingService subclass. Adding the messa service to the app's manifest should be a part of the integration step, integrating the SDK. Also you should provide a hook in the SDK from where the app can pass the FCM message payload to the SDK.

Essentially if the app does not have its own FirebaseMessagingService subclass it would add your SDK's listener service in the manifest else it will add the hook in its own listener service which passes the payload to your SDK and SDK takes the required action

Additional context

@nakshay If your app has its own FCM Messaging Service class then please follow this documentation -> https://developer.clevertap.com/docs/android-push#custom-android-push-notification-handling