调试 ios 的推送,想发的时候在命令里输入内容,然后回车。“啪”的一下就过去了
#!/usr/bin/env ruby
# encoding: utf-8
require 'APNS'
#APNS.host = 'gateway.push.apple.com'
APNS.host = 'gateway.sandbox.push.apple.com'
#gateway.sandbox.push.apple.com is default
APNS.pem = '/Users/me/push/rapns/my_push.pem'
# this is the file you just created
APNS.port = 2195
# this is also the default. Shouldn't ever have to set this, but just in case Apple goes crazy, you can.
device_token = '1c47f5a74714b28a00014684a64f02c7f60426e6c9a6ee6b068efddb57c9d6a9'
print "please enter the news content:"
while gets.chomp
puts "The news is :#{$_} \n-----------------------\n"
APNS.send_notification(device_token, :alert => "#{$_}", :badge => 1, :sound => 'default', :other => {:hash => 'zlrltPL'})
end