如何使用 rest api 在一个信号中为用户设置标签

How to set a tag for a user in one signal with rest api

根据one signal documentation标签可以设置为rest API:

Tags are data attributes that can be added to users via OneSignal SDKs or the Server REST API.

但是没有更多的数据,关于如何用rest发送标签api! link 仅指创建通知文档,仅此而已。

是否可以从后端发送标签?有人遇到过这种情况吗?

OneSignal 在其文档的 edit device 部分描述了这个问题:

通过在使用 PUT 方法调用此 Web 服务时使用 playerId:

https://onesignal.com/api/v1/players/{playerid}

在正文中:

{
 "app_id": "Your app id",
 "tags" : {
    "add_new_tag":"joined",
    "remove_old_tag" : ""
    }
}

To delete a tag, include its key and set its value to blank. Omitting a key/value will not delete it. For example, if I wanted to delete two existing tanks rank and category while simultaneously adding a new tag class, the tags JSON would look like the following:

"tags": {
           "rank": "",
           "category": "",
           "class": "my_new_value"
        }