项目作者: e4q

项目描述 :
:iphone: Erlang Push Notifications. APNS(Apple Push Notifications) and FCM(Firebase Cloud Messaging) Push Notifications
高级语言: Erlang
项目地址: git://github.com/e4q/epns.git
创建时间: 2019-06-03T15:16:08Z
项目社区:https://github.com/e4q/epns

开源协议:MIT License

下载


Erlang Push Notifications - epns

epns is Erlang Push Notifications. This is a small client library for sending FCM/GCM/APNS Push Notifications

Hex.pm Version

Goals

epns(Erlang Push Notifications) library aims to provide a simple way for push FCM/GCM/APNS notifications.

Documentation

Build & Run

  1. $ git clone https://github.com/vkatsuba/shot.git
  2. $ cd shot
  3. $ wget https://s3.amazonaws.com/rebar3/rebar3
  4. $ chmod u+x ./rebar3
  5. $ ./rebar3 shell

Run dialyzer

  1. $ ./rebar3 dialyzer

Run xref

  1. $ ./rebar3 do xref

Clean epns

  1. $ ./rebar3 clean

Add epns to project: Rebar3

  • Edit file rebar.config:
    1. {deps, [
    2. {epns, "1.1.0"},
    3. ]}.

Send Push Notifications

Send FCM by Erlang

  1. %%% Useful links:
  2. %%% * https://firebase.google.com/docs/cloud-messaging/http-server-ref
  3. %%% * https://developer.clevertap.com/docs/find-your-fcm-sender-id-fcm-server-api-key
  4. FCMData = #{
  5. key => "TheFcmServerApiKey",
  6. url => "https://fcm.googleapis.com/fcm/send",
  7. playload => #{
  8. to => <<"GoogleUserToken">>,
  9. priority => <<"high">>,
  10. data => #{
  11. <<"title">> => <<"Some Title">>,
  12. <<"some_custom_field">> => true
  13. }
  14. }
  15. }.
  16. epns:push(fcm, FCMData).

Send APNS by Erlang

  1. %%% Useful links:
  2. %%% * https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html
  3. %%% * https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/BinaryProviderAPI.html
  4. %%% * https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/LegacyNotificationFormat.html
  5. APNSData = #{
  6. cert => "/full/patch/to/cert.pem",
  7. key => "/full/patch/to/key.key",
  8. url => "gateway.push.apple.com",
  9. token => <<"VoipTokenOfUserDevice">>,
  10. playload => #{
  11. aps => #{alert => <<"Some Title Of Alert APNS">>},
  12. data => #{
  13. <<"title">> => <<"Some Title">>,
  14. <<"custom_field">> => <<"some_data">>
  15. }
  16. }
  17. }.
  18. epns:push(apns, APNSData).

Support

v.katsuba.dev@gmail.com