iOS 4
iOS 5
Android
Games
Time-sensitive Discounts
Politics
After figuring out appropriate use cases for push notifications, how do we build the infrastructure to send them?
https://go.urbanairship.com/api/[action]
POST https://go.urbanairship.com/api/push/
GET https://go.urbanairship.com/api/ \
device_tokens/[tokens]/
POST https://go.urbanairship.com/api/push/batch/
PUT https://go.urbanairship.com/api/ \
device_tokens/FE66489F304DC75B8D6E8200DFF \
8A456E8DAEACEC428B427E9518741C92C6660
POST https://go.urbanairship.com/api/push/
{
"device_tokens": [
"ABC...",
"FEG..."
],
"schedule_for": [
"2012-07-27 22:48:00",
"2012-07-28 22:48:00"
],
"aps": {
"alert": "Hello from Urban Airship!"
}
}
import urbanairship
app_key =
UA_KEYS[group_name]['UA_APPLICATION_KEY']
master_key =
UA_KEYS[group_name]['UA_MASTER_SECRET_KEY']
airship = urbanairship.Airship(app_key,
master_key)
android_json = {'android': {'alert':
'Android push notification text.'}}
airship.broadcast(android_json)
ios_json = {'aps': {'alert':
'iOS push notification text.'}}
airship.broadcast(ios_json)
android_json2 = {'android': {'alert':
'Android push notification text.',
'extra': {'url': 'http://example.com/content'}
}}
airship.broadcast(android_json2)
BASE_URL = 'https://go.urbanairship/api'
BROADCAST_URL = BASE_URL + '/push/broadcast/'
def broadcast(self, payload,
exclude_tokens=None):
if exclude_tokens:
payload['exclude_tokens'] = exclude_tokens
body = json.dumps(payload)
status, response = self._request('POST',
body, BROADCAST_URL, 'application/json')
if not status == 200:
raise AirshipFailure(status, response)