Reputation: 1732
This may be a silly question, but I cannot find a way to send push notifications to all users with Parse.com. I can send notifications to specific channels though.
I tried with
channels: []
but this yields an error.
What's the exact JSON to send push notifications to all users? I'm using the REST API.
Upvotes: 0
Views: 936
Reputation: 3489
Just include "where" and no conditions.
{
"where": {
},
"data": {
"alert": "Willie Hayes injured by own pop fly."
}
}
The full curl commands:
curl -X POST \
-H "X-Parse-Application-Id: YOURID" \
-H "X-Parse-REST-API-Key: YOURKEY" \
-H "Content-Type: application/json" \
-d '{
"where": {
},
"data": {
"alert": "Willie Hayes injured by own pop fly."
}
}' \
https://api.parse.com/1/push
Upvotes: 0
Reputation: 1
vb:
postString = "{""where"": {""deviceType"": ""android""}, ""data"": { ""alert"": """ + pushMessage + """}}"`
c#:
postString == "{\"where\": {\"deviceType\": \"android\"}, \"data\": { \"alert\": \"" + pushMessage + "\"}}"
Upvotes: 0
Reputation: 10572
Below is an example to send to default [all users] or no channels essentially.
{"data": { "alert": "Alert Message", "sound": "somesoundfile", "badge": "Increment" },"where": { "deviceType": "ios" }}
You can check out their documentation for other tags they support like parseVersion, appName, appVersion etc etc
Edit
To send to all devices you simply don't include the where statement: That was just an example for further customization. Because platforms handle notifications differently and offer different functionalities not all instances are translated. However, here is an example to target all platforms without prejudice:
'{ //not mandatory but just another visual for customizing
"channels": [
"Some Channel"
],
"data": {
"alert": "Alert Message", //not platform specific
"badge": "Increment", //platform specific iOS
"sound": "somesoundfile", //platform specific iOS
"title": "We Pushed to Everyone!" //platform specific Android
}
}'
Upvotes: 1