Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions lib/pushmeup/apns/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,22 @@ def self.send_notification(device_token, message)

def self.send_notifications(notifications)
sock, ssl = self.open_connection

# pushmeLog = ActiveSupport::BufferedLogger.new(Rails.root.join('log/pushmeup.log'))
notifications.each do |n|
ssl.write(n.packaged_notification)
# Write message to APNS
puts ssl.write(n.packaged_notification)
# pushmeLog.info "Send #{n.device_token}"
if IO.select([ssl], nil, nil, 1)
read_buffer = ssl.read(6)
# pushmeLog.info "### Error for: #{n.device_token}"
# puts "read_buffer:#{read_buffer}"
# close and reopen connection in case of error
ssl.close
sock.close
sock, ssl = self.open_connection
# puts "Reopen connection"
end
end

ssl.close
sock.close
Expand Down