iosobjective-cjailbreakcydia-substrate

Hooking mute switch (Jailbroken)


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


Solution

  • 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);