Sha256: b178a8a1ccb6c5cb6fd48d47b94fd12f4965da1fda8c8ceb5d0519086ec68c3c
Contents?: true
Size: 1.01 KB
Versions: 4
Compression:
Stored size: 1.01 KB
Contents
module FwtPushNotificationServer module Notifier class APNS < Notifier::Base def notify_once(message, device_tokens, payload = nil) 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, custom: payload) 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
4 entries across 4 versions & 1 rubygems