Sha256: b981017f6079b78ab5b22da7d77858722111dd8a83867e92936a41c92c4b6db8
Contents?: true
Size: 728 Bytes
Versions: 2
Compression:
Stored size: 728 Bytes
Contents
require 'faraday' require 'multi_json' class PushClient attr_reader :host def initialize(host) @host = host end def connection(host) conn = Faraday::Connection.new(host) do |c| c.use(Faraday::Request::UrlEncoded) c.adapter(Faraday.default_adapter) end end def notify(env, token, data) params = {:token => token} body = MultiJson.encode(data) path = env == 'live' ? '/live' : '/sandbox' response = connection(host).send(:post) do |request| request.path = path request.params = params request.body = body end response.body end end client = PushClient.new('http://localhost:27000') client.notify('live', 'TOKEN', {:alert => "Test Message"})
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
apple_push-0.1.2 | examples/apple_push_client.rb |
apple_push-0.1.1 | examples/apple_push_client.rb |