0

Hi im trying to make an alarm app, and made some notifications when the alarms finished. I have a custom alarm sound that last for some time, so the use will notice that the alarm is finished. But when the alarm goes and the notification gets sendt, the sound plays until its finished. Even when the user unlocks the phone.

Is it possible to make the sound stop playing when the user interacts with the phone ?

FredInn
  • 41
  • 4
  • Possible duplicate of [Is it possible to stop the sound of a UILocalNotification from playing when the notification is delivered?](https://stackoverflow.com/questions/4762816/is-it-possible-to-stop-the-sound-of-a-uilocalnotification-from-playing-when-the) – dvp.petrov Sep 10 '18 at 12:30

1 Answers1

0

In AppDelegate,

func application(_ application: UIApplication, didReceive notification: UILocalNotification) {
    // Handle notification here.
}

function executes when user tap the local notification. You can pause or stop sound in this function.

If you want to detect if phone is locked or unlocked, it isn't possible as far as I know.

Mahmut Acar
  • 713
  • 2
  • 7
  • 26