SDK

Segmentation

This is an add-on feature of Notificare. You will need to subscribe to the Users & Authentication add-on and configure this service as described here. Once subscribed, before you can use this functionality, make sure you create User Preferences like explained here.

The following methods are only available when users are authenticated. This functionality will allow you to create a rich user profile based on your users preferences, personal information, etc.

To get a list of preferences for a user, use the following method:

Notificare.authentication().fetchUserPreferences(object : NotificareCallback<List<NotificareUserPreference>> {
    override fun onSuccess(result: List<NotificareUserPreference>) {

    }

    override fun onFailure(e: Exception) {

    }
})

To get a list of user segments, use the following method:

Notificare.authentication().fetchUserSegments(object : NotificareCallback<List<NotificareUserSegment>> {
    override fun onSuccess(result: List<NotificareUserSegment>) {

    }

    override fun onFailure(e: Exception) {

    }
})

To add a user to a segment, invoke one of the methods below:

//
// With a user segment
//
val segment: NotificareUserSegment
Notificare.authentication().addUserSegment(segment, object : NotificareCallback<Unit> {
    override fun onSuccess(result: Unit) {

    }

    override fun onFailure(e: Exception) {

    }
})

//
// With a user preference + option
//
val option: NotificareUserPreference.Option
val preference: NotificareUserPreference
Notificare.authentication().addUserSegmentToPreference(option, preference, object : NotificareCallback<Unit> {
    override fun onSuccess(result: Unit) {

    }

    override fun onFailure(e: Exception) {

    }
})

To remove a user from a segment, invoke one of the methods below:

//
// With a user segment
//
val segment: NotificareUserSegment
Notificare.authentication().removeUserSegment(segment, object : NotificareCallback<Unit> {
    override fun onSuccess(result: Unit) {

    }

    override fun onFailure(e: Exception) {

    }
})

//
// With a user preference + option
//
val option: NotificareUserPreference.Option
val preference: NotificareUserPreference
Notificare.authentication().removeUserSegmentFromPreference(option, preference, object : NotificareCallback<Unit> {
    override fun onSuccess(result: Unit) {

    }

    override fun onFailure(e: Exception) {

    }
})

This functionality will allow you to categorize your users based on their preferences. You can then easily create campaigns using these segments.