IOS手机震动和铃声设置

做app的时候经常会遇到收到告警消息后,手机要震动下或播放个声音.以下记录了相关代码

1.手机震动(在iphone有作用,在ipad上没有作用)

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

2.播放铃声

SystemSoundID soundId;

NSString *path = [[NSBundle mainBundle]pathForResource:@“ring”1 ofType:@"aiff"];

AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:path], &soundId);

AudioServicesPlaySystemSound(soundId);

你可能感兴趣的:(IOS手机震动和铃声设置)