iPhone - How do I know if the vibrate is on or off for iOS?

前端 未结 1 1728
说谎
说谎 2020-12-14 11:00

Do you know how I may know if the iPhone is on vibrate mode ? I don\'t find anything about this on the Web... Too tired to see ?

I want to display an icon in the app

相关标签:
1条回答
  • 2020-12-14 11:40

    You should be able to achieve this using:

    #import "AudioToolbox/AudioToolbox.h"
    
    - (void) ifSilentModeThenShowIcon
    {
       CFStringRef state;
       UInt32 propertySize = sizeof(CFStringRef);
       AudioSessionInitialize(NULL, NULL, NULL, NULL);
       AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize, &state);
    
       if(CFStringGetLength(state) == 0)
       { 
         // phone's ringer is off so put
         // some icon showing code here
       }
    }
    

    Source

    0 讨论(0)
提交回复
热议问题