diff --git a/lib/pushmeup/apns/core.rb b/lib/pushmeup/apns/core.rb index 5d74778..c60135d 100644 --- a/lib/pushmeup/apns/core.rb +++ b/lib/pushmeup/apns/core.rb @@ -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