Firebase Cloud Messaging
Firebase Cloud Messaging server HTTP v1 protocol Erlang implementation
Using rebar3:
{deps, [
{fcm, {git, "https://github.com/SysVisionINT/fcm.git", {branch, "master"}}}
]}.
After starting fcm, the setup function must be called, before messages can be sent.
#!erlang
fcm:setup(ProjectId :: binary(), ClientEmail :: binary(), RsaPrivateKey :: binary()) -> ok | invalid_key.
The RsaPrivateKey must be in the "RSA PRIVATE KEY" format. To convert the key provided by Google use:
openssl rsa -in server.key -out server_new.key
In order to send a message, first include the fcm.hrl file:
#!erlang
-include_lib("fcm/include/fcm.hrl").
Create a #fcm_message{}
according to the Firebase Cloud Messaging message specification, and use the send function.
#!erlang
fcm:send(Message :: #fcm_message{}) -> ok | error.