Create a gist now

Instantly share code, notes, and snippets.

@fra3il /0.rb Secret
Last active Jan 29, 2016

What would you like to do?
[WP/1475] Houston 을 이용한 Feedback service 맛보기
# Houston
# Local and Remote Notification Programming Guide - The Feedback Service
require 'houston'
APN = Houston::Client.development
APN.certificate ="development.pem")
# APN = Houston::Client.production
# APN.certificate ="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 ="%Y-%m-%d")
# ./feedback/2016-01-28.txt
file_path = File.join(directory, "#{file_name}.txt"), "a") do |file|
devices.each do |feedback|
# 2016-01-28 15:16:48 +0900, 86bfff30 b8e3e0a4 d6829cca d9e5204e 333c57cd 5b17d189 06412b87 8b07496f
file.puts "#{[:timestamp])}, #{feedback[:token]}"
puts "+ #{devices.length} feedback"
puts "No feedback available"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment