NEW: My new book Pro SwiftUI is out now – level up your SwiftUI skills today! >>

How can I use speech synthesis as an alarm?

Forums > Swift

I made a speaking alarm clock using iOS Shortcuts. It reads out a hard coded string using the 'speak text' function, and I used the Shortcuts automation feature to have it run every morning at a specified time. In the automation settings, I was able to turn off 'ask before running', so that I don't have to do anything for it to work, even if the device is asleep. It reads out the string every morning all by itself.

I am having a hard time figuring out how to achieve the same functionality in Swift/SwiftUI using AVSpeechSynthesizer and background tasks like appRefresh. Every solution seems to somehow require the user to interact with the device - by tapping a notification, for example. Obviously an alarm clock that doesn't make any sound until you tap the screen is pretty useless. If anyone could shed some light on a possible solution here, or what Shortcuts is doing under the hood to make the automation happen, it would be extremely appreciated!

Thanks for any insight and for taking the time to read.


Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until October 1st.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.