This commit is contained in:
anlicheng 2025-04-07 11:58:14 +08:00
parent 318e3b2f79
commit 53ba52712d
2 changed files with 13 additions and 4 deletions

View File

@ -11,11 +11,14 @@
%% API %% API
-export([push/3]). -export([push/3]).
-export([test/1]). -export([test/1, test/0]).
test() ->
test(<<"3ea61b396cc2455069df01f874f0ffeeb2cfa4937adba5f3af743b08148c8eb0">>).
test(DeviceToken) -> test(DeviceToken) ->
Title = <<"这是一个消息通知"/utf8>>, Title = <<"动物狂响曲"/utf8>>,
Body = jiffy:encode(#{<<"id">> => 1234, <<"name">> => <<"英雄第二季"/utf8>>}, [force_utf8]), Body = <<"第7集(校服与被毛更深处),bilibili已更新"/utf8>>,
push(DeviceToken, Title, Body). push(DeviceToken, Title, Body).
-spec push(DeviceToken :: binary(), Title :: binary(), Body :: binary()) -> Response :: apns:response(). -spec push(DeviceToken :: binary(), Title :: binary(), Body :: binary()) -> Response :: apns:response().

View File

@ -78,12 +78,18 @@ handle_call({push, DeviceToken, Title, Body}, _From, State = #state{apns_pid = A
aps => #{ aps => #{
alert => #{ alert => #{
title => Title, title => Title,
% subtitle => <<"副标题"/utf8>>,
body => Body body => Body
}, },
'mutable-content' => 1,
% %
sound => <<"default">>, sound => <<"default">>,
% App % App
badge => 1 badge => 1,
category => <<"HUB_MESSAGE">>
},
custom_data => #{
<<"drama_id">> => 305
} }
}, },
PushResult = apns:push_notification(ApnsPid, DeviceToken, Notification, Headers), PushResult = apns:push_notification(ApnsPid, DeviceToken, Notification, Headers),