Skip to content

Instantly share code, notes, and snippets.

@fra3il

fra3il/0.rb Secret

Last active January 29, 2016 02:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fra3il/bf73826daa2ba0d9f611 to your computer and use it in GitHub Desktop.
Save fra3il/bf73826daa2ba0d9f611 to your computer and use it in GitHub Desktop.
[WP/1475] Houston 을 이용한 Feedback service 맛보기
# Houston
# https://github.com/nomad/houston
# Local and Remote Notification Programming Guide - The Feedback Service
# https://goo.gl/vEhEJE
require 'houston'
APN = Houston::Client.development
APN.certificate = File.read("development.pem")
# APN = Houston::Client.production
# APN.certificate = File.read("production.pem")
devices = APN.unregistered_devices
# devices = [{:token=>"86bfff30 b8e3e0a4 d6829cca d9e5204e 333c57cd 5b17d189 06412b87 8b07496f", :timestamp=>1453961808}]
if devices.any?
directory = "./feedback"
Dir.mkdir(directory) if !Dir.exist?(directory)
file_name = Time.now.strftime("%Y-%m-%d")
# ./feedback/2016-01-28.txt
file_path = File.join(directory, "#{file_name}.txt")
File.open(file_path, "a") do |file|
devices.each do |feedback|
# 2016-01-28 15:16:48 +0900, 86bfff30 b8e3e0a4 d6829cca d9e5204e 333c57cd 5b17d189 06412b87 8b07496f
file.puts "#{Time.at(feedback[:timestamp])}, #{feedback[:token]}"
end
end
puts "+ #{devices.length} feedback"
else
puts "No feedback available"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment