checkAudienceMembership
Deprecated
This method is no longer recommended. Audience Manager is no longer available in the latest product version.
The checkAudienceMembership() method checks if a user belongs to a specific audience.
Syntax
getTracker().checkAudienceMembership(audienceId, new Tracker.OnCheckAudienceMembership() {
@Override
public void onChecked(boolean isMember) {
// handle result
}
@Override
public void onError(String errorData) {
// handle error
}
});
tracker.checkAudienceMembership(
binding.audienceId.text.toString(),
object : OnCheckAudienceMembership {
override fun onChecked(isMember: Boolean) {
// handle result
}
override fun onError(errorData: String) {
var errorData: String? = errorData
errorData = if (TextUtils.isEmpty(errorData)) "Network error" else errorData
// handle error
}
})
Parameters
audienceId (string, required)
The ID of the audience you want to check. You can find it in Audience Manager > Audiences.
OnCheckAudienceMembership() (required)
The callback to handle a request result. The call is asynchronous. It has two methods void onChecked(boolean isMember)
and void onError(String errorData)
.
isMember (boolean, output)
Whether the user belongs to a specific audience. True: Belongs. False: Doesn’t belong.
errorData (output)
The error string. If an error occurs, only this method will be called.
Examples
To check if a user belongs to an audience:
getTracker().checkAudienceMembership(audienceId, new Tracker.OnCheckAudienceMembership() {
@Override
public void onChecked(boolean isMember) {
// handle result
}
@Override
public void onError(String errorData) {
// handle error
}
});
tracker.checkAudienceMembership(
binding.audienceId.text.toString(),
object : OnCheckAudienceMembership {
override fun onChecked(isMember: Boolean) {
// handle result
}
override fun onError(errorData: String) {
var errorData: String? = errorData
errorData = if (TextUtils.isEmpty(errorData)) "Network error" else errorData
// handle error
}
})
Related methods
- audienceManagerSetProfileAttribute() deprecated
- audienceManagerGetProfileAttributes() deprecated
Updated 2 days ago