release/2.0.0: Migrate from legacy FCM API
Now you need to use service account credentials instead api key.
To generate a private key file for your service account:
-
In the Firebase console, open Settings > Service Accounts.
-
Click Generate New Private Key, then confirm by clicking Generate Key.
-
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
}
}
)