APPush v0.1 documentation
A Ruby interface to talk to the Appush push notifications service. It uses the three levels of Appush authentification: RootUser, Application and Profile.
Data returned using this api may be parsed using a JSON parser: JSON.parse(data.to_s), depending on the http result it might be an array or hash or binary data.
Instantiates an Appush API client
Parameters
- token - required Appush token string (this is the http username)
- secret - required Appush secret string (this is the http password)
- service_url - Appush service URL (not required, default https://appush.com/api)
Example:
>> client = AppushClient::RootUser.new root_token="I6ieYi...", root_secret="48907eb..."
Parameters
- name - required Application name
- env - application environment (dev, prod)
- dev_pem - application development certificate
- prod_pem - application production certificate
Example:
>> root_user = AppushClient::RootUser.new root_token="I6ieYi...", root_secret="48907eb..."
>> root_user.create_application("test")
>> "{"id":"YZgzHWpxdt4emUAYTptovTcfYdW"}"
Parameters
- id - application resource id
- params - a hashed parameters (:name=>”new name”)
Example:
>> root_user = AppushClient::RootUser.new root_token="I6ieYi...", root_secret="48907eb..."
>> root_user.modify_application("YZgzHWpxdt4emUAYTptovTcfYdW", :name=>"new app name", :env=>"dev")
>> ""
Example:
>> root_user = AppushClient::RootUser.new root_token="I6ieYi...", root_secret="48907eb..."
>> root_user.list_applications
>> "["P9haDs2EjJmyuYwEpxio2KPZ4SH"]"
Parameters
- id - application resource id
Example:
>> root_user = AppushClient::RootUser.new root_token="I6ieYi...", root_secret="48907eb..."
>> root_user.get_application("YZgzHWpxd...")
>> {"name":"My New Application", "application_token": "EVtmyITWMKzDRtawXxubVmfIYWU", "application_secret": "e52c6cbd232e2111671953d320ff80a2", "status":"dev","dev_pem":"Bag Attributes\n ...", "active_devices":0}
Parameters
- id - application resource id
Example:
>> root_user = AppushClient::RootUser.new root_token="I6ieYi...", root_secret="48907eb..."
>> icon = root_user.get_application_icon("YZgzHWpxd...")
Parameters
- id - application resource id
- icon - binary icon
Example:
>> root_user = AppushClient::RootUser.new root_token="I6ieYi...", root_secret="48907eb..."
>> icon = File.read('icon.png')
>> root_user.save_application_icon("YZgzHWpxd...", icon)
Parameters
- id - application resource id
Example:
>> root_user = AppushClient::RootUser.new root_token="I6ieYi...", root_secret="48907eb..."
>> root_user.delete_application("YZgzHWpxd...")
Parameters
- id - application resource id
- tags - a list of strings to implicitly include a device in a notification
- devices - the device token string to explicitly include
- exclude - the device token string to explicitly exclude
- alert - a string. the notification to be sent.
- sound - a string. the sound, if available on the client device.
- badge - an integer. The number to set the badge to.
- kv - a hash table of arbitrary key value pairs to send to the device.
Example:
>> root_user = AppushClient::RootUser.new root_token="I6ieYi...", root_secret="48907eb..."
>> root_user.send_notification("YZgzHWpxd...", :tags=>["foo", "bar"])
Parameters
- app_id - application resource id
- notification_id - notification id
Example:
>> root_user = AppushClient::RootUser.new root_token="I6ieYi...", root_secret="48907eb..."
>> root_token.get_notification_status("YZgzHWpxd...", "P9haDs2Ej")
Parameters
- app_id - application resource id
- tag - tag to query the devices
Example:
>> root_user = AppushClient::RootUser.new root_token="I6ieYi...", root_secret="48907eb..."
>> root_user.get_devices_by_tag("YZgzHWpxd...", "tag")
>> "{"devices":["3734cc9af9376b8cba3704bccbd7c5c7f0901476d07c3247ead2b55f479fbd76"]}"
Parameters
- device_token - device identifier
Example:
>> profile = AppushClient::Profile.new profile_token="I6ieYi...", profile_secret="48907eb..."
>> profile.get_device("3734cc9af9376b8cba37")
>> {"tags":["spam","bar","foo"]}
Parameters
- device_token - device identifier
- tags - array of tags
Example:
>> profile = AppushClient::Profile.new profile_token="I6ieYi...", profile_secret="48907eb..."
>> profile.register_device("3734cc9af9376b8cba37", ["foo", "bar"])
Parameters
- device_token - device identifier
Example:
>> profile = AppushClient::Profile.new profile_token="I6ieYi...", profile_secret="48907eb..."
>> profile.unregister_device("3734cc9af9376b8cba37")
Example:
>> application = AppushClient::Application.new application_token="I6ieYi...", application_secret="48907eb..."
>> application.create_profile()
>> "{"token":"38d0f91a99c57d189416439ce377ccdcd92639d0", "secret":"7e734e90f9dfc4def902ecd3c2e81c7dd530448d"}"