我在iOS上尝试使用声音进行本地通知。
let content = UNMutableNotificationContent()
content.title = "Intro to Notifications"
content.subtitle = "Lets code,Talk is cheap"
content.body = "Sample code from WWDC"
content.sound = UNNotificationSound(named: "out.caf")
// content.sound = UNNotificationSound(named: "out.caf")
let trigger = UNTimeIntervalNotificationTrigger.init(timeInterval: 5.0, repeats: false)
let request = UNNotificationRequest(identifier:self.peripheralUUID, content: content, trigger: trigger)
UNUserNotificationCenter.current().delegate = self
UNUserNotificationCenter.current().add(request){(error) in
if (error != nil){
print(error?.localizedDescription)
}
}
声音不起作用,只有震动才起作用。哪里不对?
发布于 2018-06-14 16:04:59
首先,确保对目标memebership进行了文件检查,并尝试此扩展名。
content.sound = UNNotificationSound(named: "out.aif")
还要确保持续时间<30秒。
https://stackoverflow.com/questions/-100004918
复制相似问题