Mute Push Notifications

Magnet Message provides an easy way for developers to mute and unmute push notifications 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.

Mute Channel

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

[channel muteUntil:nil success:^{ //this channel is now muted! } failure:^(NSError *error) { //NSLog(@"%@", error.localizedDescription) }];

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.

NSDate *tomorrow = [[NSCalendar currentCalendar] dateByAddingUnit:NSCalendarUnitDay value:1 toDate:[NSDate date] options:NSCalendarMatchNextTime]; [channel muteUntil:tomorrow success:^{ //this channel is now muted until tomorrow! } failure:^(NSError *error) { //NSLog(@"%@", error.localizedDescription) }];

Unmute Channel

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

[channel unMuteWithSuccess:^{ //this channel is now unmuted! } failure:^(NSError *error) { //NSLog(@"%@", error.localizedDescription) }];

Channel Mute Status

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

if (channel.isMuted) { //this channel is muted } else { //this channel is not muted } NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; formatter.dateStyle = NSDateFormatterLongStyle; formatter.timeStyle = NSDateFormatterMediumStyle; NSString *dateString = [formatter stringFromDate:channel.mutedUntil]; NSLog(@"muted until %@", dateString);

Next Steps

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