Skip to content
Browse files

fixed payload size check

  • Loading branch information...
1 parent 53c7756 commit f9d4b0ce1d5e1e1ae5ab0fdd1ad07bf17b83b2b3 @chvanikoff committed May 9, 2014
Showing with 5 additions and 4 deletions.
  1. +5 −4 src/apns_connection.erl
View
9 src/apns_connection.erl
@@ -259,12 +259,13 @@ build_payload(#apns_msg{alert = Alert,
P = build_payload([{alert, Alert},
{badge, Badge},
{sound, Sound}] ++ Apns_Extra, Extra, Content_Available),
+ PBin = list_to_binary(P),
if
- byte_size(P) > 256 ->
- Diff = byte_size(P) - 256,
+ byte_size(PBin) > 256 ->
+ Diff = byte_size(PBin) - 256,
if
Diff > byte_size(Alert) ->
- lager:error("Payload size limit exceeded and can't be truncated (~p bytes, 256 allowed)", [byte_size(P)]),
+ lager:error("Payload size limit exceeded and can't be truncated (~p bytes, 256 allowed)", [byte_size(PBin)]),
%% Still send message but it will not be delivered
P;
true ->
@@ -353,6 +354,6 @@ parse_status(3) -> missing_topic;
parse_status(4) -> missing_payload;
parse_status(5) -> missing_token_size;
parse_status(6) -> missing_topic_size;
-parse_status(7) -> missing_payload_size;
+parse_status(7) -> invalid_payload_size;
parse_status(8) -> invalid_token;
parse_status(_) -> unknown.

0 comments on commit f9d4b0c

Please sign in to comment.
Something went wrong with that request. Please try again.