This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
Mute/Silence an iOS device programmatically?
I need to turn off the device volume programmatically. Does anyone know a way?
So far I have discovered, that maybe i can use AudioSessionSetProperty() function, and use the property "kAudioSessionProperty_CurrentHardwareOutputVolume",
but this property is only read only. SO i am not sure if this will work:
float value = 0.0f;
AudioSessionSetProperty(kAudioSessionProperty_CurrentHardwareOutputVolume, sizeof(float), &value);
There are already apps in the App-Store that does this, e.g. AutoSilent:
http://itunes.apple.com/nl/app/autosilent/id474777148?mt=8
You can't do this with iOS. The only way to mute an iOS device is by using the hardware switch. You can detect it and mute your app accordingly, but can't mute the entire device from your app.
See this question: How to disable iOS System Sounds
And this question: Mute/Silence an iOS device programmatically?
They say there that it is possible though you have to use a private framework called the Celestial framework. You would use AVSystemController to silence the phone like so:
[[AVSystemController sharedAVSystemController] setVolumeTo:0 forCategory:#"Ringtone"];
The use of private frameworks in your app will cause it to be rejected by apple, so I don't recommend using it. Some believe that using private frameworks in your app could potentially be allowed by Apple initially (if they miss it), but it will soon be removed from the App Store when they realize that you are utilizing a private framework.
Hope this helps!
Related
I know this question is already asked quite some time. And I read all the topics at stackoverflow.
But there isn't a satisfying answer to my problem.
I'd like to mute my iPhone running iOS 5 programmatically. Many would say it isn't possible with public frameworks. I'm aware of that. The App I'm planning to code is for personal use only. I do not intend to sell it over the AppStore (yet?).
My research brought me to the conclusion, that there my be several ways to achieve muting an iPhone programmatically.
Use private frameworks
Hook functions or methods which are playing sounds
Replace default sounds (like ringtone, MailSent, iMessage, usw...)
Some thoughts to the above mentioned methods:
I class-dumped all headers of the private frameworks (in my Xcode-Installation) and didn't find functions which indicate (by their function name) to the wanted behavior
I think it's possible, but I do not know the functions to be hooked. Therefore, it would be quite some effort for to make this work (and I think I do not want to do this)
Giving it a second thought, this might not be a good solution. Maybe you can change the sounds. But then the phone isn't mute at all (games, YouTube,...)
I had given AVSystemController a chance using the methods changeActiveCategoryVolumeBy and setVolumeTo but those won't mute my phone but set the minimal volume of the ringer to 0.06 (or something).
There has to be a way to completely mute the iPhone, RingToggle (jailbroken app) is doing it quite good.
Does anyone has a idea how to do it?
I don't think you'll be able to mute the phone from a sandboxed app, even using private frameworks.
What RingToggle probably does is hook into the springboard and use springboard's methods to mute the phone; they are probably using a MobileSubstrate extension.
I've been looking for a way to compare timestamps between applications on the same phone in real time, and NSDistributedNotificationCenter sounded like an ideal solution since i may not know the names of the apps listening for it, but it sounds like its not available in iOS.
Is there an equivalent way of notifying multiple apps of a time-sensitive event without knowing their name?
Coding for iOS 5+ and assuming the apps in question will register for the notification.
Look at CPDistributedMessagingCenter in /System/Library/PrivateFrameworks/AppSupport.framework. However, it's a private framework (may change with OS releases, and not allowed in AppStore).
Documentation here: http://iphonedevwiki.net/index.php/CPDistributedMessagingCenter
Example codes of mine here:
https://github.com/H2CO3/PwnTube
https://github.com/H2CO3/Cereal
I'm pretty sure you can use Mach ports. They are a bit low level but work well.
i found a way to use CFNotificationCenterGetDistributedCenter() on iOS. It is exists on device, but not exports in iOS SDK
void *libHandle = dlopen("/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation", RTLD_LAZY);
CFNotificationCenterRef (*CFNotificationCenterGetDistributedCenter)() = (CFNotificationCenterRef (*)())dlsym(libHandle, "CFNotificationCenterGetDistributedCenter");
if(CFNotificationCenterGetDistributedCenter) {
CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(), NULL, &NotificationUpdateApp, CFSTR("TestApp"), NULL, CFNotificationSuspensionBehaviorCoalesce);
}
dlclose(libHandle);
Not really. The closest you can do to what you’re asking, on a non-jailbroken device, is have your server talk to each other app’s server and have that server send a push notification to the app in question. Without NSDistributedNotificationCenter (which is, as you surmise, not available on iOS), you don’t really have any other option.
This question is a little bit old, but I'll post my answer just for information purposes.
NSDistributedNotificationCenter is not available for iOS yet, and unless your are developing an app that you don'd pretend to release on AppStore, you can't use AppSupport.framework because it's private.
iOS8 released App Extensions, that give us the ability to communicate with other apps. I don't know what you are trying to do exactly but I believe that if you are just trying to compare some timestamps from some other apps, it should resolve your problem.
Link to AppExtensions documentation:
https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/
Hope it helps somebody.
NSDistributedNotificationCenter exists on iOS, but the headers aren't made available to developers.
Create a header file in your project with the following to make the class available:
#interface NSDistributedNotificationCenter : NSNotificationCenter
+ (NSDistributedNotificationCenter *)defaultCenter;
// Returns the default distributed notification center - cover for [NSDistributedNotificationCenter notificationCenterForType:NSLocalNotificationCenterType]
- (void)postNotificationName:(NSNotificationName)name object:(nullable NSString *)object userInfo:(nullable NSDictionary *)userInfo deliverImmediately:(BOOL)deliverImmediately;
#end
This is very useful when trying to get information from an App to its UITest runner, but you should obviously NOT attempt to put this in the AppStore.
I've created a project XCTestBackChannel to show this off.
This question already has an answer here:
Closed 11 years ago.
Possible Duplicate:
Play alert sound (same as default message ringtone)
Hello all,
Quick question -
Is it possible to use one of the default sounds included on the iPhone - Marimba etc. in an iPhone application?
Thanks,
Teja
The actual directories will only be accessible after JailBreak.
Ringtones (including Marimba):
/Library/Ringtones/
System sounds:
/System/Library/Audio/UISounds/
Or use 'AudioServicesPlaySystemSound()' like mentioned by Black Frog.
Note: This method is undocumented and will cause AppStore rejection.
Download link for system sounds (comment by clusterfu_k):
Can I get default audio files of Iphone (marimba, alarm, ascending,...)?
Note: Possible copyright infringement.
This question already has an answer here:
Is possible to simulate touch event using an external keyboard on ios jailbroken?
(1 answer)
Closed 2 years ago.
Im writing an app running in background on a jailbreak iphone. I need to send touch event to iPhone OS to simulate finger touches. Is this possible?
See Matt Gallagher's article "Synthesizing a touch event on the iPhone". You may also check out the Three20 framework, which I believe used synthesized touch events to test UI elements (leading to a rash of recent application rejections due to the use of private APIs).
Yes it is possible, using GSEvents. Try the KennyTM's private framework and GSEvent.h. It is under the GraphicServices framework.
https://github.com/kennytm/iphone-private-frameworks
I've seen techniques to make sure that an app respects the mute switch, but is it possible to set the iPhone to mute (no sounds from any apps) using the SDK?
No.
Applications developed using the official SDK cannot change (and in most cases cannot even access) system-wide settings.
It is possible, but only using private API's. I only went as far as muting the ringer, but you should be able to control the master level as well.
See How to disable iOS System Sounds
It is technically possible to change the system volume through the private AVSystemController class in Celestial.framework, but will prevent your app from getting Apple's approval
As only one app can be running at a time, the only possible use I can think of for this would be to mute other people's apps, and it should be fairly clear why Apple prevents that.
What would I do if an app muted the iPhone and I didn't know it happened? It can't physically move the mute switch on the side of the phone, so that wouldn't match, and I'd have to figure out a) that the phone was muted and b) how to unmute it without the switch.
I can change volume using AVSystemController, it sets to minimum which is 0.06x. Is there class/API to mute it completely? toggleActiveCategoryMuted does not work