Tags
In this page you'll learn more about device segmentation. With tags you can categorize devices through your app. Tags can assume as many forms as you want and a device can have an unlimited number of tags. This will be extremely useful if your app doesn't have any means of authentication and your audience is mainly composed by anonymous devices.
Tags are only available after a device has been successfully registered in Notificare so the best place to access, add or remove them is after device registration. Add the following to retrieve the list of tags assigned to this device:
Notificare.on('deviceRegistered', function(data) {
Notificare.fetchTags(function(tags) {
//Handle success
}, function(e) {
//Handle error
});
});
Notificare.on('deviceRegistered', async (data) => {
const tags = await Notificare.fetchTags();
});
To assign a tag to a device, invoke the method below:
Notificare.addTag("tag_one", function(result) {
//Handle success
}, function(e) {
//Handle error
});
await Notificare.addTag('tag_one');
You can also assign several tags at once by using the method below:
var tags = ["tag_one", "tag_two"];
Notificare.addTags(tags, function(result) {
//Handle success
}, function(e) {
//Handle error
});
const tags = ['tag_one', 'tag_two'];
await Notificare.addTags(tags);
To remove a specific tag from a device, use the following method:
Notificare.removeTag("tag_one", function(result) {
//Handle success
}, function(e) {
//Handle error
});
await Notificare.removeTag('tag_one');
You can also remove several tags at once by using the method below:
var tags = ["tag_one", "tag_two"];
Notificare.removeTags(tags, function(result) {
//Handle success
}, function(e) {
//Handle error
});
const tags = ['tag_one', 'tag_two'];
await Notificare.removeTags(tags);
Finally you can also remove all the tags from a device:
Notificare.clearTags(function(result) {
//Handle success
}, function(e) {
//Handle error
});
await Notificare.clearTags();
You have now implemented successfully device tags and can start sending push notifications based on these device categories.