diff --git a/src/fcm.erl b/src/fcm.erl index 01a199b..f7c044b 100644 --- a/src/fcm.erl +++ b/src/fcm.erl @@ -17,11 +17,13 @@ -export([push/4]). --spec start_pool_with_api_key(atom(), string()) -> {ok, pid()}. +-spec start_pool_with_api_key(atom(), string()) -> + {ok, pid()} | {error, {already_started, pid()}} | {error, _}. start_pool_with_api_key(Name, ApiKey) -> fcm_sup:start_child(Name, #{fcm_key => ApiKey}). --spec start_pool_with_json_service_file(atom(), string()) -> {ok, pid()}. +-spec start_pool_with_json_service_file(atom(), string()) -> + {ok, pid()} | {error, {already_started, pid()}} | {error, _}. start_pool_with_json_service_file(Name, FilePath) -> fcm_sup:start_child(Name, #{service_file => FilePath}). @@ -33,7 +35,7 @@ stop(Name) -> atom(), binary() | list(binary()), list(tuple()) | map(), - integer()) -> list(tuple()). + integer()) -> list(tuple()) | {error, term()}. push(Name, RegIds, Message, Retry) when is_list(Message) -> push(Name, RegIds, maps:from_list(Message), Retry); push(Name, RegId, Message, Retry) when is_binary(RegId) -> diff --git a/src/fcm_api_v1.erl b/src/fcm_api_v1.erl index be02a7a..a7f60d7 100644 --- a/src/fcm_api_v1.erl +++ b/src/fcm_api_v1.erl @@ -12,7 +12,7 @@ -define(HTTP_OPTS, [{timeout, 5000}]). -define(REQ_OPTS, [{full_result, false}, {body_format, binary}]). --spec push(list(binary()), map(), string(), string()) -> list(tuple()). +-spec push(list(binary()), map(), map()) -> {ok, list(tuple()), map()}. push(RegIds, Message, State) -> push(RegIds, Message, State, []). diff --git a/src/fcm_sup.erl b/src/fcm_sup.erl index f8161f7..474f61b 100644 --- a/src/fcm_sup.erl +++ b/src/fcm_sup.erl @@ -25,6 +25,6 @@ init([]) -> {ok, {{simple_one_for_one, 5, 10}, [?CHILD(fcm, worker)]}}. -spec start_child(atom(), map()) -> - {'error',_} | {'ok','undefined' | pid()} | {'ok','undefined' | pid(),_}. + {'error',{'already_started',pid()}} | {'error',_} | {'ok',pid()}. start_child(Name, Opts) -> supervisor:start_child(?MODULE, [Name, Opts]).