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.shared().registerDevice(deviceId, new NotificareCallback<String>() {
@Override
public void onSuccess(String result) {
Notificare.shared().fetchDeviceTags(new NotificareCallback<List<String>>() {
@Override
public void onError(NotificareError error) {
//Handle error
}
@Override
public void onSuccess(List<String> tags) {
//Handle the tags list
}
});
}
}
To assign a tag to a device, invoke the method below:
Notificare.shared().addDeviceTags(tags, new NotificareCallback<Boolean>() {
@Override
public void onError(NotificareError error) {
//Handle error
}
@Override
public void onSuccess(Boolean success) {
//Handle success
}
});
Or remove a specific tag from a device:
Notificare.shared().removeDeviceTag("some_tag", new NotificareCallback<Boolean>() {
@Override
public void onError(NotificareError error) {
//Handle error
}
@Override
public void onSuccess(Boolean success) {
//Handle success
}
});
Finally you can also remove all the tags from a device:
Notificare.shared().clearDeviceTags(new NotificareCallback<Boolean>() {
@Override
public void onError(NotificareError error) {
//Handle error
}
@Override
public void onSuccess(Boolean success) {
//Handle success
}
});
You have now implemented successfully device tags and can start sending push notifications based on these categories.