7

I would like to keep my iPhone from vibrate when it's on Silent Mode even when it is ON in settings. I want to do it programmatically from an App. This is for me, so I can use a private API. Is there an api which manage Sounds in Settings? Do you know any solution?

Thank you,

Flo

Wain
  • 118,658
  • 15
  • 128
  • 151
Bcow7
  • 73
  • 1
  • 4

3 Answers3

1

I think the following code can do the trick. You need to trigger it from somewhere though (haven't understand if you want it to be fired with the button or from within an app).

NSString *sbPath = @"/var/mobile/Library/Preferences/com.apple.springboard.plist";
NSMutableDictionary *sbDict = [[NSMutableDictionary alloc] initWithContentsOfFile:sbPath];
[sbDict setValue:[NSNumber numberWithBool:NO] forKey:@"silent-vibrate"];
[sbDict writeToFile:filePath atomically: YES];
notify_post("com.apple.SpringBoard/Prefs");

Haven't tried it myself, but found something like what you are looking for in the Smartvibrate tweak. This will change the settings parameter, so you should change it back to on when your application finishes.

Hope that helps!

Panagiotis
  • 309
  • 2
  • 13
0

Update for ios 8 :

NSMutableDictionary *dict; BOOL newState = NO;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
dict = [[defaults persistentDomainForName:@"com.apple.springboard"] mutableCopy] ?:           [[NSMutableDictionary alloc] init];
NSNumber *value = [NSNumber numberWithBool:newState];
[dict setValue:value forKey:@"ring-vibrate"];
[dict setValue:value forKey:@"silent-vibrate"];
[defaults setPersistentDomain:dict forName:@"com.apple.springboard"];
notify_post("com.apple.springboard.ring-vibrate.changed");
notify_post("com.apple.springboard.silent-vibrate.changed");
P.J.Radadiya
  • 1,493
  • 1
  • 12
  • 21
  • 1
    I get an "Implicit declaration of function 'notify_post' is invalid in C99" when trying this in Xcode 6.2 (Swift project with Bridging Header to Objective-C) Edit: also in an Obj-C project. – vrwim Apr 08 '15 at 22:23
  • Is this still working for you? I can't seem to make this work – Jan Feb 22 '17 at 20:05
0

Update to @baptiste-truchot 's answer (and @vrwim 's concern):

This needs

#include <notify.h>

at top of the .h file associated.

Apple doc's about notify.h