我想让我的 iPhone 在静音模式下保持振动,即使它在设置中打开也是如此。我想从一个应用程序以编程方式完成它。这是给我的,所以我可以使用私有 API。是否有在设置中管理声音的 api?你知道有什么解决办法吗?
谢谢,
弗洛
我想让我的 iPhone 在静音模式下保持振动,即使它在设置中打开也是如此。我想从一个应用程序以编程方式完成它。这是给我的,所以我可以使用私有 API。是否有在设置中管理声音的 api?你知道有什么解决办法吗?
谢谢,
弗洛
我认为以下代码可以解决问题。不过,您需要从某个地方触发它(不知道您是希望它通过按钮触发还是从应用程序中触发)。
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");
我自己还没有尝试过,但在Smartvibrate调整中找到了您正在寻找的东西。这将更改设置参数,因此您应该在应用程序完成后将其更改回 on。
希望有帮助!
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");