SDK

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.

Common use cases for tags involve creating categories that separated devices by device model, capabilities or properties, like tablet, hasCam or en-GB. You might also allow users to subscribe to a list of pre-defined tags you include in your app. Many use cases for tags, allow users to subscribed to categories like wants_news_for_music or subscribed_newsletter. You can also register tags upon events in your app, like bought_shoes or was_near_beacon_x.

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 the current device:

Notificare.deviceManager.fetchTags(object: NotificareCallback<List<String>> {
    override fun onSuccess(result: List<String>) {

    }

    override fun onFailure(e: Exception) {

    }
})
Notificare.INSTANCE.getDeviceManager().fetchTags(new NotificareCallback<List<String>>() {
    @Override
    public void onSuccess(List<String> result) {

    }

    @Override
    public void onFailure(@NotNull Exception e) {

    }
});

To assign multiple tags to a device, invoke the method below:

val tags = listOf("Android")

Notificare.deviceManager.addTags(tags, object : NotificareCallback<Unit> {
    override fun onSuccess(result: Unit) {

    }

    override fun onFailure(e: Exception) {

    }
})
List<String> tags = new ArrayList<>();
tags.add("Android");

Notificare.INSTANCE.getDeviceManager().addTags(tags, new NotificareCallback<Unit>() {
    @Override
    public void onSuccess(Unit result) {

    }

    @Override
    public void onFailure(@NotNull Exception e) {

    }
});

Or remove a specific tag from a device:

Notificare.deviceManager.removeTag("Android", object : NotificareCallback<Unit> {
    override fun onSuccess(result: Unit) {

    }

    override fun onFailure(e: Exception) {

    }
})
Notificare.INSTANCE.getDeviceManager().removeTag("", new NotificareCallback<Unit>() {
    @Override
    public void onSuccess(Unit result) {

    }

    @Override
    public void onFailure(@NotNull Exception e) {

    }
});

Finally you can also remove all the tags from a device:

Notificare.deviceManager.clearTags(object : NotificareCallback<Unit> {
    override fun onSuccess(result: Unit) {

    }

    override fun onFailure(e: Exception) {

    }
})
Notificare.INSTANCE.getDeviceManager().clearTags(new NotificareCallback<Unit>() {
    @Override
    public void onSuccess(Unit result) {

    }

    @Override
    public void onFailure(@NotNull Exception e) {

    }
});

You have now successfully implemented device tags and can start sending push notifications based on these categories.