使用 Parse Cloud 通过 OneSignal 发送推送通知。
Parse.Cloud.define('push', function(request, response) {
var user = request.params.userId;
var message = request.params.message;
var type = request.params.type;
var jsonBody = {
app_id: "9c618b01-e43d-4a9e-b54e-14f1162dc3c4",
tags: [{"key": "userId", "relation": "=", "value": user}],
contents: {en: message},
data: {"type":type}
};
这就是我向单个用户发送推送的方式。但我需要同时向多人发送推送通知。
要向具有多个标签之一的用户发送通知,您可以使用 OR 运算符指定多个标签。
以下是如何修改代码以执行此操作的示例:
Parse.Cloud.define('push', function(request, response) {
var user1 = request.params.userId1;
var user2 = request.params.userId2;
var user3 = request.params.userId3;
var message = request.params.message;
var type = request.params.type;
var jsonBody = {
app_id: "9c618b01-e43d-4a9e-b54e-14f1162dc3c4",
tags: [{"key": "userId", "relation": "=", "value": user1},{"operator": "OR"},{"key": "userId", "relation": "=", "value": user2},{"operator": "OR"},{"key": "userId", "relation": "=", "value": user2}],
contents: {en: message},
data: {"type":type}
};
关于ios - OneSignal Push for vales 数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38532358/
欢迎光临 OGeek|极客世界-中国程序员成长平台 (https://ogeek.cn/) | Powered by Discuz! X3.4 |