Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
FCM HTTP v1 API sending message using .NET
// Learn more about F# at
open System
open Google.Apis.Auth.OAuth2
open FirebaseAdmin
open FirebaseAdmin.Auth
open FirebaseAdmin.Messaging
open System.Collections.Generic
open System.Collections.ObjectModel
let secretFilename = "path/to/secret_key.json"
let main argv =
let firebaseApp =
Credential = GoogleCredential.FromFile(secretFilename)))
let registrationToken = "device_token"
let message =
Data = (dict [
"title", "Pushy"
"body", "Pushy is alive and well"
] |> ReadOnlyDictionary),
Token = registrationToken)
let response = FirebaseMessaging.DefaultInstance.SendAsync(message) |> Async.AwaitTask |> Async.RunSynchronously
Console.WriteLine("Successfully sent message: " + response)
with e -> printfn "Failed to send message:\n%s\n%s" e.Message e.StackTrace
0 // return an integer exit code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment