我希望能够在我的iPhone进入静音模式时,即使在设置中已经打开震动,也能保持不震动。我想要通过程序来控制这个功能。由于只是为了我自己使用,因此可以使用私有API。是否有API可以管理设置中的声音?你知道任何解决方案吗?
谢谢, Flo
谢谢, Flo
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");
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");