Mute Push Notifications

Magnet Message provides an easy way for developers to mute and unmute push notifications for mobile devices on a user's subscribed channels. When a channel is muted, an offline user will not receive push notifications as they normally would. This can be really useful when designing an app with a great user experience in mind. For example, perhaps a user may not want to receive notifications while they are at work or while they are sleeping. With Magnet Message you can add time-based mute and unmute functionality to your app on a per channel basis.

Push notifications are not available in web applications. When a channel is muted from the JavaScript SDK, mobile devices owned by the same user will be muted instead.

Mute Channel

To mute a channel simply call the muteUntil method on the target channel.

myChannel.mute().success(function() { // channel has been muted for the current user }).error(function(err) { // handle errors });

Set Mute Duration

Additionally a date can be specified to mute a channel for a specific duration. If no date is specified, the channel will be muted in perpetuity.

var myDate = new Date(); // we are adding 24 hours to the current date myDate.setHours(myDate.getHours() + 24); myChannel.mute(myDate).success(function() { // channel has been muted for the current user }).error(function(err) { // handle errors });

Unmute Channel

Similarly, to unmute a channel simply call unmute on the target channel.

myChannel.unmute().success(function() { // channel has been unmuted for the current user }).error(function(err) { // handle errors });

Channel Mute Status

Each instance of Max.Channel contains attributes to identify a channel's "mute" status.

if (myChannel.isMuted) { // this channel has been muted } else { // this channel is not muted } var date = myChannel.mutedUntil; // if an expiry date was specified, it can be obtained from the channel instance.

Next Steps

See how to create a Private Discussion Group in your app.