Skip to content

release/2.0.0: Migrate from legacy FCM API

Compare
Choose a tag to compare
@oyakovlev oyakovlev released this 08 Feb 10:51
· 3 commits to master since this release
c068d35

Now you need to use service account credentials instead api key.

To generate a private key file for your service account:

  1. In the Firebase console, open Settings > Service Accounts.

  2. Click Generate New Private Key, then confirm by clicking Generate Key.

  3. Securely store the JSON file containing the key.

Migration guide:
Before:

PushService(
        coroutineScope = fcmScope,
        config = FCMConfig(
            serverKey = appConf.getString("fcm.serverKey")
        ),
        pushRepository = object : IPushRepository {
            override fun deleteByTokenList(tokenList: List<String>): Int {
                // remove wrong tokens here
                return 0
            }
        }
    )

After:
NOTE: in "fcm.googleServiceAccountJson" use content of saved JSON file as string

    PushService(
        coroutineScope = fcmScope,
        config = FCMConfig(
            googleServiceAccountJson = appConf.getString("fcm.googleServiceAccountJson")
        ),
        pushRepository = object : IPushRepository {
            override fun deleteByTokenList(tokenList: List<String>): Int {
                // remove wrong tokens here
                return 0
            }
        }
    )