OneSignal has support for custom tags, to categorize and segment your users. Tags are name-value pairs of strings. More info at https://documentation.onesignal.com/docs/data-tags.
You may get and set these tags programmatically using javascript, or alternatively expose a native UI where users can toggle pre-specified tags on/off.
Javascript method
Get tags
------------
window.location.href = 'gonative://onesignal/tags/get?callback=functionName';
functionName will get called with an object like:
{
success: true,
tags: {
tag1: "value1"
}
}
If there is an error retrieving tags, success will be false.
Set tags
-----------
Example javascript code:
var tags = {
name1: 'value1',
name2: 'value2'
};
window.location.href = 'gonative://onesignal/tags/set?tags=' + encodeURIComponent(JSON.stringify(tags));
You may set value to an empty string to delete an existing tag.
Native UI
Please edit the Import/Export section of your app's configuration as follows. Your tags can be specified in JSON format, with example at https://s3.amazonaws.com/gonativeio/public/tags.json.
"oneSignal": {
"active": true,
"applicationId": "XXXXX",
"tagsJsonUrl": "https://s3.amazonaws.com/gonativeio/public/tags.json"
},
Activate by opening gonative://onesignal/showTagsUI
UI will look like: