This commit is contained in:
anlicheng 2025-04-03 15:52:17 +08:00
parent ad518db266
commit 318e3b2f79
2 changed files with 5 additions and 7 deletions

View File

@ -6,7 +6,7 @@
%%% @end %%% @end
%%% Created : 03. 4 2025 15:41 %%% Created : 03. 4 2025 15:41
%%%------------------------------------------------------------------- %%%-------------------------------------------------------------------
-module(dimension_spn_pusher). -module(dimension_apn_pusher).
-author("anlicheng"). -author("anlicheng").
%% API %% API
@ -18,8 +18,6 @@ test(DeviceToken) ->
Body = jiffy:encode(#{<<"id">> => 1234, <<"name">> => <<"英雄第二季"/utf8>>}, [force_utf8]), Body = jiffy:encode(#{<<"id">> => 1234, <<"name">> => <<"英雄第二季"/utf8>>}, [force_utf8]),
push(DeviceToken, Title, Body). push(DeviceToken, Title, Body).
-spec push(DeviceToken :: binary(), Title :: binary(), Body :: binary()) -> no_return(). -spec push(DeviceToken :: binary(), Title :: binary(), Body :: binary()) -> Response :: apns:response().
push(DeviceToken, Title, Body) when is_binary(DeviceToken), is_binary(Title), is_binary(Body) -> push(DeviceToken, Title, Body) when is_binary(DeviceToken), is_binary(Title), is_binary(Body) ->
poolboy:transaction(apns_pool, fun(WorkerPid) -> poolboy:transaction(apns_pool, fun(WorkerPid) -> dimension_apn_worker:push(WorkerPid, DeviceToken, Title, Body) end).
dimension_apn_worker:push(WorkerPid, DeviceToken, Title, Body)
end).

View File

@ -29,7 +29,7 @@
%%% API %%% API
%%%=================================================================== %%%===================================================================
-spec push(Pid :: pid(), DeviceToken :: binary(), Title :: binary(), Body :: binary()) -> no_return(). -spec push(Pid :: pid(), DeviceToken :: binary(), Title :: binary(), Body :: binary()) -> Response :: apns:response().
push(Pid, DeviceToken, Title, Body) when is_pid(Pid), is_binary(DeviceToken), is_binary(Title), is_binary(Body) -> push(Pid, DeviceToken, Title, Body) when is_pid(Pid), is_binary(DeviceToken), is_binary(Title), is_binary(Body) ->
gen_server:call(Pid, {push, DeviceToken, Title, Body}). gen_server:call(Pid, {push, DeviceToken, Title, Body}).
@ -88,7 +88,7 @@ handle_call({push, DeviceToken, Title, Body}, _From, State = #state{apns_pid = A
}, },
PushResult = apns:push_notification(ApnsPid, DeviceToken, Notification, Headers), PushResult = apns:push_notification(ApnsPid, DeviceToken, Notification, Headers),
lager:debug("[dimension_apn_pusher] push result is: ~p", [PushResult]), lager:debug("[dimension_apn_pusher] push result is: ~p", [PushResult]),
{reply, ok, State}. {reply, PushResult, State}.
%% @private %% @private
%% @doc Handling cast messages %% @doc Handling cast messages