How can I programmatically disable incoming iPhone text messages?

I'm currently trying to use the private AVSystemController environment to mute system sounds based on user selection. Currently, I have disconnected phone calls by calling: [(AVSystemController object) setVolumeTo:0.0 forCategory:@"Ringtone"];

Is there a command for this for incoming text messages? I assume that this will be based on a change in the category specified in this call. However, I cannot find a list of categories for the link. Out of 10, I was able to find (Alert, Audio/Video, Ringtone, Voicemail, VoicemailGreeting, PhoneCall, TTYCall, RingtonePreview, Alarm, Record) , none of them control the sounds of text messages. Is there a category for this? If not, is there any other way to disconnect sound from incoming texts?

I understand that this is due to Apple's no-private-frameworks policy, but this application will not work in the application store so that there are no problems. I am developing it using the latest version of Xcode for the latest version of iOS, so any way to accomplish this can be done.

+7
source share
1 answer

@Jessica, you cannot do this, bcos this is limited. if you want to try it in your application, your application may be rejected in the application store.

So, using public APIs, this is not possible.

You found the link using private APIs that are not documented or are guaranteed to work as you expected. If you try to release an App Store application that calls a private API, it will be automatically rejected.

if you want to check if it is quiet or not, use below code,

  -(BOOL)silenced { #if TARGET_IPHONE_SIMULATOR // return NO in simulator. Code causes crashes for some reason. return NO; #endif CFStringRef state; UInt32 propertySize = sizeof(CFStringRef); AudioSessionInitialize(NULL, NULL, NULL, NULL); AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize, &state); if(CFStringGetLength(state) > 0) return NO; else return YES; } For completeness, building off this link from Dan Bon, I implement the following method to solve this problem in my apps. One thing to note is that the code checks for the iPhone simulator first - executing the below code will crash the simulator. Anyone know why? -(BOOL)silenced { #if TARGET_IPHONE_SIMULATOR // return NO in simulator. Code causes crashes for some reason. return NO; #endif CFStringRef state; UInt32 propertySize = sizeof(CFStringRef); AudioSessionInitialize(NULL, NULL, NULL, NULL); AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize, &state); if(CFStringGetLength(state) > 0) return NO; else return YES; } 

By declaring this right in the view controller, you simply check

 if ([self silenced]) { NSLog(@"silenced"); else { NSLog(@"not silenced"); } 
+1
source

All Articles