UILocalNotification alarm sound does not trigger when app is in Active state iOS Swift


When the app is in foreground app will not trigger the sound of the notification.It will directly come to the app updates.So you can use the AVPlayer to trigger the sound manually when app receives the notification.

Code:


    func application(_ application: UIApplication, didReceive notification: UILocalNotification) {

        if application.applicationState == .active {
//here play the sound using AVPlayer
}
}

Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Saved Image in document directory and save path in coredata not able to fetch the image file iOS swift