Andy Nuryana
Andy Nuryana

Reputation: 3

How to make the system speak a title or body text of a notification with Swift

I've been looking for how to make the system speaks alertTitle or alertBody of a notification when the notification appears in the background with Swift but until now I don't find any solution.

let notification = UILocalNotification()
notification.alertTitle = "Wake up"
notification.alertBody = "What's your agenda today?"
notification.fireDate = time
notification.repeatInterval = NSCalendar.Unit.day
notification.soundName = UILocalNotificationDefaultSoundName
UIApplication.shared.scheduleLocalNotification(notification)

So how would I accomplish this?

Thanks!

Upvotes: 0

Views: 90

Answers (1)

naglerrr
naglerrr

Reputation: 2854

There is no way to achieve this programatically. You can not put anything into your UILocalNotification object to achieve this.

iOS supports VoiceOver, and you can set it up so it reads all your incoming notifications. To do this, go to the Settings --> Accessiblity --> Turn on VoiceOver --> Verbosity --> Turn on Always Speak Notifications.

This is a system wide setting that the user will have to enable however. It is valid for all applications, and not just yours.

Upvotes: 1

Related Questions