Tags
In this page you'll learn more about device segmentation. With tags you can categorize devices through your web 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 website 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 retrieve, add or remove them is after device registration.
notificare.didRegisterDevice = (device) => {
//After this it is safe to register tags
}
Add the following to retrieve the list of tags assigned to this device:
notificare.fetchTags().then((tags) => {
console.log(tags);
}).catch((e) => {
//Handle error
});
To assign one single tag to a device, invoke the method below:
notificare.addTag("tag_press").then((response) => {
//Handle success
}).catch((e) => {
//Handle error
});
To assign one or more tags to a device, invoke the method below:
notificare.addTags(["tag_press", "tag_events"]).then((response) => {
//Handle success
}).catch((e) => {
//Handle error
});
Or remove a specific tag from a device:
notificare.removeTag("tag_press").then((response) => {
//Handle success
}).catch((e) => {
//Handle error
});
To remove one or more tags from a device, invoke the method below:
notificare.removeTags(["tag_press", "tag_events"]).then((response) => {
//Handle success
}).catch((e) => {
//Handle error
});
Finally you can also remove all the tags from a device:
notificare.clearTags().then((response) => {
//Handle success
}).catch((e) => {
//Handle error
});
You have now implemented successfully device tags and can start sending push notifications based on these categories.