カテゴリー : Parse.com

[Parse.com] REST API で Push Notification を送信する方法

Parse.com の REST API でプッシュ通知配信する curl コマンドを用途別にご紹介します。

[参考]: Push Developer Guide | Parse


全てのアプリにプッシュ通知配信

curl -X POST \
  -H "X-Parse-Application-Id: xxxxxxxxxx" \
  -H "X-Parse-REST-API-Key: xxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
        "data": {
          "alert": "This is a notification message!"
        }
      }' \
  https://api.parse.com/1/push

Android アプリにプッシュ通知配信

curl -X POST \
  -H "X-Parse-Application-Id: xxxxxxxxxx" \
  -H "X-Parse-REST-API-Key: xxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
        "where": {
          "deviceType": "android",
        },
        "data": {
          "alert": "This is a notification message!"
        }
      }' \
  https://api.parse.com/1/push

iOS アプリにプッシュ通知配信 [2013年6月26日23時00分(現地時間)]

curl -X POST \
  -H "X-Parse-Application-Id: xxxxxxxxxx" \
  -H "X-Parse-REST-API-Key: xxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
        "where": {
          "deviceType": "ios",
        },
        "push_time": "2013-06-26T23:30:00",
        "data": {
          "alert": "This is a notification message!"
        }
      }' \
  https://api.parse.com/1/push

iOS アプリにプッシュ通知配信 [2013年6月26日23時00分(現地時間)]
かつ、アプリ側で notificationTime を 23:30 を設定するもののみに、プッシュ通知配信

curl -X POST \
  -H "X-Parse-Application-Id: xxxxxxxxxx" \
  -H "X-Parse-REST-API-Key: xxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
        "where": {
          "deviceType": "ios",
          "notificationTime": "23:30"
        },
        "push_time": "2013-06-26T23:30:00",
        "data": {
          "alert": "This is a notification message!"
        }
      }' \
  https://api.parse.com/1/push

[Android][iOS] Parse.com で REST API 経由で Push 通知

Android や iOS アプリに、Parse.com で REST API 経由で Push 通知するには下記のような感じです。

curl -X POST \
  -H "X-Parse-Application-Id: xxxxxx" \
  -H "X-Parse-REST-API-Key: xxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
        "where": {
          "deviceType": "ios"
        },
        "data": {
          "alert": "Hello World!"
        }
      }' \
  https://api.parse.com/1/push

[参考]

REST API | Parse