From 4e6b62a202da5af10cd93333c42000305db342c8 Mon Sep 17 00:00:00 2001 From: Ian Thomas Date: Wed, 4 Jul 2018 09:01:47 -0400 Subject: [PATCH] Update README.md Added repo instructions --- README.md | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e773eb5..6a9c5aa 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,36 @@ # FCM Client [![CircleCI](https://circleci.com/gh/ToxicBakery/fcm-client/tree/master.svg?style=svg)](https://circleci.com/gh/ToxicBakery/fcm-client/tree/master) [![codecov](https://codecov.io/gh/ToxicBakery/fcm-client/branch/master/graph/badge.svg)](https://codecov.io/gh/ToxicBakery/fcm-client) -Kotlin library for sending FCM messages. +Kotlin library for sending Firebase Cloud Messages using the v1 HTTP protocol. + +## Requirements +Sending of messages to FCM requires the admin service account credentials. +* Navigate to your project in the Firebase console +* Click the settings gear icon and then `Project settings` in the drop down +* Click the `Service Accounts` tab +* Click `Generate new private key` on the `Firebase Admin SDK` tab + +## Sample Usage +```kotlin +// Create the client using the downloaded google-services.json +val fcmClient = File("google-services.json") + .inputStream() + .let { accountStream -> GoogleServiceAccountResolver(accountStream) } + .let { accountResolver -> HttpUrlFcmClient(accountResolver) } + +// Create a message and give it to the client for delivery to FCM +fcmClient.send( + Message( + data = mapOf( + "Hello" to "World!" + ), + android = AndroidConfig( + restrictedPackageName = "com.sample.package" + ), + condition = "'my-channel' in topics" + ) +) +``` + +## Install +```groovy +implementation "com.ToxicBakery.fcmclient:fcm-client:1.+" +```