nomad/houston — pull request #63 by emrekutlu (2014-06-29 14:24:56+00:00)
Title: Alert Truncation

I implemented alert truncation for invalid payloads. It will truncate the alert if the payload exceeds the maximum payload size. Notification takes two more parameters truncation and omission.

truncation may be true, false or nil. Default is false.
omission may be any string, false or nil. Default is ....

By default it won't truncate the alert. It will truncate if truncation is true.

Usage:
```ruby
require 'houston'

APN = Houston::Client.development
APN.certificate = File.read("/path/to/apple_push_notification.pem")

token = ""

notification = Houston::Notification.new(device: token)
notification.alert = "Really long message which will exceed the 256 bytes maximum payload size. So it will be truncated and omission will be added to the end of the alert."

notification.badge = 57
notification.sound = "sosumi.aiff"
notification.content_available = true
notification.custom_data = {foo: "bar"}

notification.truncation = true

APN.push(notification)
# Alert will be sent as:
# Really long message which will exceed the 256 bytes maximum payload size. So it will be truncated and omission will be added to the end of th...
```

What do you think?