Requires Coffeescript and Node.js
Use with cake -t 'The Terminal' -s 'message sent!' ping
or any combination of options to send a push notification.
https = require 'https' | |
url = require 'url' | |
querystring = require 'querystring' | |
credentials = 'sekret' | |
option '-m', '--message [MESSAGE]', 'message to send' | |
option '-t', '--title [TITLE]', 'title in the notification' | |
option '-l', '--longmessage [LONGMESSAGE]', 'longmessage to send' | |
option '-s', '--subtitle [SUBTITLE]', 'subtitle of the notification' | |
option '-n', '--notification [SOUND]', 'sound to ring with' | |
request = | |
host: 'www.appnotifications.com' | |
port: 443 | |
path: '/account/notifications.json' + | |
url.format(search: "user_credentials=#{credentials}") | |
method: 'POST' | |
task 'ping', 'ping my iphone something', (options)-> | |
request.path += '&' + querystring.stringify | |
'notification[sound]': options.notification or '02' | |
'notification[message]': options.message or 'message' | |
'notification[title]': options.title or 'title' | |
'notification[long_message]': options.longmessage or 'long_message' | |
'notification[subtitle]': options.subtitle or 'subtitle' | |
'notification[silent]': options.silent or 'false' | |
req = https.request request, (res) -> | |
console.log request | |
res.on 'data', (d) -> | |
process.stdout.write d | |
req.end() |