Created
March 29, 2015 02:40
-
-
Save sb8244/351d6561b9617546fbb5 to your computer and use it in GitHub Desktop.
Grocer in action
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DeviceNotifier = Struct.new(:message, :count) do | |
def call | |
notifications.each do |notif| | |
pusher.push(notif) | |
end | |
end | |
private | |
def pusher | |
@pusher ||= Grocer.pusher( | |
certificate: "config/app-sam-dev.pem", # required | |
passphrase: "XXX", # optional | |
gateway: "gateway.sandbox.push.apple.com", | |
retries: 3 # optional | |
) | |
end | |
def notifications | |
Device.all.map do |device| | |
Grocer::Notification.new( | |
device_token: device.token.gsub(/[<,>,\s]/, ""), | |
alert: message, | |
badge: count || 1 | |
) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment