How to send Push Notifications with Parse.com Cloudcode

后端 未结 3 858
暖寄归人
暖寄归人 2021-01-07 05:22

I want to send a Push Notification with Cloudcode on Parse.com.

The push notification should be sent to all android devices that are subscribed to a specific channe

3条回答
  •  一整个雨季
    2021-01-07 06:15

    You don't need a query to send a push to a channel. Just call Parse.Push.send and add a channel array to the data object.

    Parse.Push.send({
            channels: [ "channel_name" ],
            data: {
                alert: "Alert message"
            }
        }, {
            success: function () {
                response.success("Push was sent");
            },
            error: function (error) {
                response.error("Could not send push " + error)
            }
        });
    

    Be sure to not use spaces and Capital letters in channel names. The channel will not be added to the subscribed channels in the backend.

提交回复
热议问题