How to include GCM / FCM in the Android library module?

I cannot generate json google services for the Android library because I requested the application id. I know how to add it to a project.

+4
source share
1 answer

FCM Client Configuration

Libraries do not have an application identifier. The application identifier is provided by the consumer of your library. Just turn on the addiction and that. Do not use the google services plugin in the library.

https://firebase.google.com/docs/cloud-messaging/android/client. , push- , . :

your.client.app.package.fcm.MyFirebaseMessagingService.kt

class MyFirebaseMessagingService() : FirebaseMessagingService() {
    override fun onMessageReceived(p0: RemoteMessage) {
        super.onMessageReceived(p0)

        // Your client message handling.
        // ...

        // If not handled by client, delegate to library.
        AwesomeLibrary.processPushMessage(this, p0)
}

your.awesome.library.package.fcm.AwesomeLibraryFcm.kt

object AwesomeLibraryFcm {
    fun processPushMessage(context: Context, message: RemoteMessage) {
        // TODO Your job.
    }
}

, Firebase . Firebase .

FCM

FCM . Firebase, . .

- push- , ( IP- ) Google Dev . push-. , , , push mesages .

.

+2

Source: https://habr.com/ru/post/1657844/


All Articles