Sha256: ea99d992a9abff85117b8e81de3ab1eb007b1570afa1e78475f1c0eca32c00b6
Contents?: true
Size: 998 Bytes
Versions: 6
Compression:
Stored size: 998 Bytes
Contents
module FwtPushNotificationServer module Notifier class APNS < Notifier::Base def notify_once(message, device_tokens) alert = message.byteslice(0, 232) alert += '...' if alert.bytesize > 232 config = FwtPushNotificationServer.apns_config pusher = Grocer.pusher(config) device_tokens = [device_tokens] unless device_tokens.is_a?(Array) device_tokens.each do |device| if device.is_valid token = device.token n = Grocer::Notification.new(device_token: token, alert: alert) pusher.push n end end feedback = Grocer.feedback(config) feedback.each do |attempt| token = attempt.device_token device_token = DeviceToken.find_by_token(token) device_token.update_attribute("is_valid", false) unless device_token.nil? puts "APNS: Device #{token} failed at #{attempt.timestamp}" end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems