diff --git a/apps/roster/src/api/push/roster_apns_api.erl b/apps/roster/src/api/push/roster_apns_api.erl index 88e050dbcc6323f1a15be48eb07544ac1f91c1b6..0a7c00734a0e87765317ee0ff1241fa18b465e06 100644 --- a/apps/roster/src/api/push/roster_apns_api.erl +++ b/apps/roster/src/api/push/roster_apns_api.erl @@ -37,7 +37,7 @@ -define(FKPN_BUNDLE, <<"IOS_BANDLE">>). %% Sic! -define(FKPN_GATEWAY, <<"APNS_GATEWAY">>). -define(FKPN_SERVER_DNS, <<"SERVER_DNS">>). --define(FKPN_GENERIC_TOKEN, <<"GENERIC_TOKEN">>). +-define(FKPN_TOKEN_GENERIC, <<"TOKEN_GENERIC">>). %% Temporary manual interface @@ -109,7 +109,7 @@ notify(A, C, T, VoipToken, SessionSettings, PushType, State) -> pick_connection_type(PushType, SessionSettings, VoipToken) -> %% Note that headers need to be written as strings. %% The payload content should be numbers. - case push_type_and_token(PushType, SessionSettings) of + case push_type_and_token(PushType, SessionSettings, VoipToken) of {background, Token} -> Headers = #{ apns_push_type => <<"background">> , apns_priority => <<"5">>}, @@ -127,18 +127,20 @@ pick_connection_type(PushType, SessionSettings, VoipToken) -> false -> {binary, VoipToken} end; - voip -> + {voip, VoipTokenForDevice} -> Headers = #{ apns_push_type => <<"voip">> , apns_expiration => <<"0">> %% Deliver immediately or not at all. , apns_priority => <<"10">>}, Aps = #{}, - {http, Headers, Aps, VoipToken} + {http, Headers, Aps, VoipTokenForDevice} end. -push_type_and_token(<<"voip">>, _SessionSettings) -> - voip; -push_type_and_token(_PushType, SessionSettings) -> - case get_data_from_feature(SessionSettings, ?FKPN_GENERIC_TOKEN) of +push_type_and_token(<<"voip">>, SessionSettings, []) -> + {voip, get_data_from_feature(SessionSettings, ?FKPN_TOKEN_GENERIC)}; +push_type_and_token(<<"voip">>, _SessionSettings, VoipToken) -> + {voip, VoipToken}; +push_type_and_token(_PushType, SessionSettings, _VoipToken) -> + case get_data_from_feature(SessionSettings, ?FKPN_TOKEN_GENERIC) of [] -> binary; Token -> {background, Token} end.