Muting Users
PubNub Access Manager enables you to manage access controls for individual users so they can be muted on specific channels.
Mute user in channels
To mute a user in channels, call the grant method and set the write permissions on the channels to false.
pubnub.grant({
channels: ['ch-1','ch-2'], //channels to allow grant on
authKeys: ['key1'], // the keys we are provisioning
write: false,
}, (status) => {
// handle status
});
pubnub.grant()
.channels(Arrays.asList("ch-1")) //channels to allow grant on
.authKeys(Arrays.asList("key1")) // the keys we are provisioning
.write(false) // allow those keys to write (false by default)
.async(new PNCallback<PNAccessManagerGrantResult>() {
@Override
public void onResponse(PNAccessManagerGrantResult result, PNStatus status) {
// PNAccessManagerGrantResult is a parsed and abstracted response from server
}
});
pubnub.Grant()
.Channels(new string[]{
"ch-1"
})
.AuthKeys(new string[] {
"key1"
})
.Write(false) // allow those keys to write (false by default)
.Execute(new PNAccessManagerGrantResultExt(
(result, status) => {
// PNAccessManagerGrantResult is a parsed and abstracted response from server
}
));
res, status, err := pn.Grant().
Channels([]string{"ch-1"}). // channels to allow grant on
AuthKeys([]string{"key1"}). // the keys we are provisioning
Write(false). // allow those keys to manage channel groups (false by default)
Execute()
fmt.Println(res, status, err)