inaka/apns4erl — pull request #4 by pnc (2013-01-28 18:28:23+00:00)
Title: Function to calculate remaining bytes in a payload

This patch adds a function `apns:estimate_available_bytes(#apns_msg{}) -> integer()` that can be used to determine how much additional data can be included without going over Apple's 256-byte limit.

If you like the idea of exposing this functionality, I will write tests and clean up this patch up at your direction.

For instance, I'm using this as follows:

BaseMessage = #apns_msg{badge = InboxCount,
sound = sound_for_message(Message),
alert = ""},
%% Use all the remaining space for alert text
AvailableBytes = apns:estimate_available_bytes(BaseMessage)

I then use `AvailableBytes` to truncate the alert string (if needed) so it fits.

I was not able to get Dialyzer to run. Can you provide any pointers on how to get `rebar dialyze` to work?

$ rebar version
rebar 2.1.0-pre R15B01 20130111_211911 No VCS info available.
$ make analyze
rebar get-deps && rebar compile
==> apns (get-deps)
==> apns (compile)
rebar dialyze
Command 'dialyze' not understood or not applicable
make: *** [analyze] Error 1