Skip to content

Instantly share code, notes, and snippets.

@sb8244
Created March 29, 2015 02:40
Show Gist options
  • Save sb8244/351d6561b9617546fbb5 to your computer and use it in GitHub Desktop.
Save sb8244/351d6561b9617546fbb5 to your computer and use it in GitHub Desktop.
Grocer in action
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