Skip to content

2600hz/erlang-fcm

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fcm-erlang

This software provides an Erlang client for Firebase Cloud Messaging to enable notifications to

  • Browser
  • Android
  • iOS notifications

Changelog

1.1.0 [ 10 June 2020 ]

  • Added support for firebase http v1 cloud messaging.

1.0.1

  • Remove qdate dependency

1.0.0

  • Initial Release

How to compile:

fcm-erlang uses erlang.mk as make system. To compile

$ make

To generate release

$ make rel

How to use with rebar:

You can use fcm_app as a dependency in your rebar.config:

{deps , [
    {fcm, ".*", {git, "https://github.com/pankajsoni19/fcm-erlang.git", {tag, "1.1.0"}}}
]}.

How to run the application fcm-erlang:

make rel will create a release under _rel/fcm directory.

$ cd _rel/fcm
$ bin/fcm console

Start FCM Service

Two connection types are supported.

  1. start_pool_with_api_key supports legacy api
  2. start_pool_with_json_service_file supports http v1 api

3> fcm:start_pool_with_api_key(foo, "google_console_server_key").
{ok,<0.60.0>}
4> fcm:start_pool_with_json_service_file(bar, "google_service_file_path.json").
{ok,<0.65.0>}

Stop Service

6> fcm:stop(foo).
6> fcm:stop(bar).

How to send a FCM message using from a specific FCM application:

At any time you can send a FCM message to one or more mobile devices by calling:

7> fcm:push(RegisteredName, RegIds, Message, Retry).

Where

* `RegistereName` is the atom used during registration
* `RegId` is Registration Id specified as Erlang binary (e.g., `<<"APA91bHun4MxP5egoKMwt2KZFBaFUH-1RYqx...">>`)
* `RegIds` is a list (max 1000 elements) of `RegId`	* `Message` is an Erlang Map.
* `Retry` is only valid for legacy api.

In order to understand Message payload see Message Syntax. or Refer to HTTP v1

Credits

The project was inspired from pdincau/gcm-erlang. I would like to thank Paolo for the same.

Packages

No packages published

Languages

  • Erlang 95.8%
  • Makefile 4.2%