1

I want to override the mute switch to create a new action whenever the switch is switched. So what is the method that is fired when the switch is changed?

Thanks

Nate
  • 31,017
  • 13
  • 83
  • 207

1 Answers1

1

Hook this method in the SpringBoard

SBMediaController - (void)setRingerMuted:(char)

If you just want to observer the switch event then you can observe system-wide notification com.apple.springboard.ringerstate with darwin notification center like this

static void RingerStateChanged(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo)
{
}

CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(),
                                NULL,
                                RingerStateChanged,
                                CFSTR("com.apple.springboard.ringerstate"),
                                NULL,
                                CFNotificationSuspensionBehaviorDeliverImmediately);
creker
  • 9,400
  • 1
  • 30
  • 47
  • I've searched a lot on how to listen to darwin notifications but almost didn't find anything. So could you please give me an example on that? :) – user3628430 Oct 06 '14 at 09:16
  • It's documented by Apple https://developer.apple.com/library/mac/documentation/CoreFoundation/Reference/CFNotificationCenterRef/Reference/reference.html – creker Oct 06 '14 at 10:17
  • I've already read that, but it's confusing. I want a real example for _ringerstate_ notification. also if I want to override the **setRingerMuted:** method, it accepts a char argument, so how to figure out if its on or off? I think it's bool not char. Thanks for helping me :) – user3628430 Oct 06 '14 at 10:22
  • BOOL is typedef for char, so yes, in this case it's a boolean argument. – creker Oct 06 '14 at 10:40
  • so please, can you give me an example of the darwin notification observing? – user3628430 Oct 06 '14 at 10:52