集成极光IM时候的需求 要像微信一样 在前端收到推送时,声音和震动分开的需求
使用系统的语音进行开启 震动也是一个语音 kSystemSoundID_Vibrate 可以自己录个无声语音 然后进行设置 然后根据需求发送不同的声音自定义
播放震动
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate)
静音效果
//音效文件路径
let path = Bundle.main.path(forResource: "noSound", ofType: "wav")
//组装并播放音效
var soundID:SystemSoundID = 0;
let filePath = NSURL.fileURL(withPath: path!, isDirectory: false)
AudioServicesCreateSystemSoundID(filePath as CFURL, &soundID)
AudioServicesPlaySystemSound(soundID)
只有系统声音
var soundID:SystemSoundID = 0;
let path = "/System/Library/Audio/UISounds/sms-received1.caf"
let filePath = NSURL.fileURL(withPath: path, isDirectory: false)
AudioServicesCreateSystemSoundID(filePath as CFURL, &soundID)
AudioServicesPlaySystemSound(soundID)
系统声音加震动
completionHandler? (Int(UNNotificationPresentationOptions.badge.rawValue | UNNotificationPresentationOptions.sound.rawValue