I am trying to implement label text read and assign to local notification sound. Whenever local notification trigger It should make sound like "Hey your +label.text+ file downloaded.
Please help me to make above scenarion.
let content = UNMutableNotificationContent()
content.title = "Title"
content.body = "Body"
content.sound = UNNotificationSound.default()
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 5, repeats: false)
let request = UNNotificationRequest(identifier: "TestIdentifier", content: content, trigger: trigger)
UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
I have text to speech but I don't how to merge both
import AVFoundation
let string = "Hello, World!"
let utterance = AVSpeechUtterance(string: string)
utterance.voice = AVSpeechSynthesisVoice(language: "en-US")
let synth = AVSpeechSynthesizer()
synth.speak(utterance)
It does not look like possible in iOS. Custom notification sound should be an instance of the UNNotificationSound
class, AVSpeechSynthesisVoice
can't help you with this.
content.sound = UNNotificationSound(named: soundName)
Please check below link. raywenderlich
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.