Guest User

Untitled

a guest
Apr 23rd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. module APNS
  2.  
  3. def self.send_notifications(notifications)
  4. sock, ssl = self.open_connection
  5.  
  6. notifications.each do |n|
  7. ssl.write(self.packaged_notification(n[0], n[1]))
  8. end
  9.  
  10. ssl.close
  11. sock.close
  12. end
  13.  
  14. end
  15.  
  16. # usage
  17.  
  18. notification1 = ['1234-12314-123123-123123', 'Hello Hello']
  19. notification2 = ['1234-12314-123123-123123', {:alert => 'Hello iPhone!', :badge => 1, :sound => 'default'}]
  20.  
  21. notifications = [notification1, notification2]
  22.  
  23. APNS.send_notifications(notifications)
Add Comment
Please, Sign In to add comment