IOS静音还是震动
2016-02-02 09:50
363 查看
[(SBMediaController *)[objc_getClass("SBMediaController") sharedInstance] isRingerMuted]
越狱环境
#define kSpringBoardPlist @"/var/mobile/Library/Preferences/com.apple.springboard.plist"
+ (BOOL)vibrateServicesEnabled
{
NSDictionary *dict;
if (kCFCoreFoundationVersionNumber >= 1000)
{
dict = [[NSUserDefaults standardUserDefaults] persistentDomainForName:@"com.apple.springboard"];
}
else
{
dict = [NSDictionary dictionaryWithContentsOfFile:kSpringBoardPlist];
}
BOOL enabled;
if (![Function ringerMutedServicesEnabled]) {
//非静音状态
enabled = [[dict valueForKey:@"ring-vibrate"] boolValue];
}
else
{
//静音状态
enabled = [[dict valueForKey:@"silent-vibrate"] boolValue];
}
return enabled;
}
CFNotificationCenterAddObserver(center, NULL, SystemPostedNotification, CFSTR("com.apple.springboard.ringerstate"), NULL, CFNotificationSuspensionBehaviorCoalesce);
CFNotificationCenterAddObserver(center, NULL, SystemPostedNotification, CFSTR("com.apple.springboard.ring-vibrate.changed"), NULL, CFNotificationSuspensionBehaviorCoalesce);
CFNotificationCenterAddObserver(center, NULL, SystemPostedNotification, CFSTR("com.apple.springboard.ring-silent.changed"), NULL, CFNotificationSuspensionBehaviorCoalesce);
//回调
static void SystemPostedNotification(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo)
{
}
//audioToolBox
- (BOOL)slicend{
#if TARGET_IPHONE_SIMULATOR
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;
}
越狱环境
#define kSpringBoardPlist @"/var/mobile/Library/Preferences/com.apple.springboard.plist"
+ (BOOL)vibrateServicesEnabled
{
NSDictionary *dict;
if (kCFCoreFoundationVersionNumber >= 1000)
{
dict = [[NSUserDefaults standardUserDefaults] persistentDomainForName:@"com.apple.springboard"];
}
else
{
dict = [NSDictionary dictionaryWithContentsOfFile:kSpringBoardPlist];
}
BOOL enabled;
if (![Function ringerMutedServicesEnabled]) {
//非静音状态
enabled = [[dict valueForKey:@"ring-vibrate"] boolValue];
}
else
{
//静音状态
enabled = [[dict valueForKey:@"silent-vibrate"] boolValue];
}
return enabled;
}
CFNotificationCenterAddObserver(center, NULL, SystemPostedNotification, CFSTR("com.apple.springboard.ringerstate"), NULL, CFNotificationSuspensionBehaviorCoalesce);
CFNotificationCenterAddObserver(center, NULL, SystemPostedNotification, CFSTR("com.apple.springboard.ring-vibrate.changed"), NULL, CFNotificationSuspensionBehaviorCoalesce);
CFNotificationCenterAddObserver(center, NULL, SystemPostedNotification, CFSTR("com.apple.springboard.ring-silent.changed"), NULL, CFNotificationSuspensionBehaviorCoalesce);
//回调
static void SystemPostedNotification(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo)
{
}
//audioToolBox
- (BOOL)slicend{
#if TARGET_IPHONE_SIMULATOR
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;
}
相关文章推荐
- iOS 自定义TabBarController
- Github上600多个iOS开源项目
- IOS设置View的背景图片
- 框架
- iOS应用开发中实现页面跳转的简单方法笔记
- iOS开发第三方介绍之一Masonry
- iOS 如何连接打印机
- Ios 调用打印机2
- iOS 调用打印机
- edgesForExtendedLayout ios7新特性
- iOS-线程&&进程的深入理解
- iOS知识小集 第一期
- iOS中常用的四种数据持久化方法简介
- 蓝懿IOS学习音频播放
- iOS开发的小技巧(断点打印)
- iOS 基础知识
- JS判断客户端是否是iOS或者Android
- ios开发技巧之【1】
- ios9系统图片显示不出来
- iOS开发:NSNotification的使用