Parseで特定のデバイスにPUSH通知を送信する

Push通知を特定のデバイストークンを持つデバイスに送信するコードのメモ。

CURL

curl -X POST \
  -H "X-Parse-Application-Id: ..." \
  -H "X-Parse-REST-API-Key: ..." \
  -H "Content-Type: application/json" \
  -d '{
        "deviceType": "ios",
        "deviceToken": "...",
        "channels": [
          ""
        ]
      }' \
  https://api.parse.com/1/installations

Python

import json,httplib

connection = httplib.HTTPSConnection('api.parse.com', 443)
connection.request('POST', '/1/push', json.dumps({
    "where": {
        "deviceToken":'SPECIFIC_DEVICE_TOKEN'
    },
    "data": {
        "alert": 'HELLO'
    }
}), {
    "X-Parse-Application-Id": "...",
    "X-Parse-REST-API-Key": "...",
    "Content-Type": "application/json"
})
result = json.loads(connection.getresponse().read())
print u'{}'.format(result)


Related Contents

Pickup Contents