Push Notification sound stops when the notification badge disappears - ios

I need to play notification sound for a long time (20-25 sec) when the app is in background. I have imported my custom sound file (25 sec in duration) in the project. Custom sound is playing but the problem is it only plays as long as the notification badge remains on the screen, i.e. 3-4 sec. As soon as the badge disappears, the notification sound also stops. What should I do ?

In this link Managing Your App’s Notification Support, go to section title Preparing Custom Alert Sounds
It mentions, Custom sounds must be under 30 seconds when played. If a custom sound is over that limit, the default system sound is played instead.
Possible duplicate of Limits on iPhone push notification sounds?

Related

Play sound at a specific time in background iOS

I have a muslim app that triggers local notifications with sounds for prayer times throughout the day. The sounds are limited to 30 seconds. I am searching for a workaround to play sound longer than that.
I found out I can use AVAudioSession to play audio even if the app is in background by turning on Background Modes (Audio, Airplay, and Picture in Picture) in Capabilities target tab and using background task to play the audio. However I want to play sound at a specific time by scheduling it.
Among the workarounds I found are also setting continuous local notifications. However I came across an alarm app (Alarmy) that can play sound when local notification is received. How is that doable? Thank you in advance!

How to play longer music as Notification alert?

I want to set a music which is longer than 30sec as notification soound. But after searching about this I came to know that it is not possible to add these type of music as notification sound. notification sound must be in 30sec longer otherwise it will not play music. Now how can I add more than 30sec longer music as notification sound?
I had a similar issue for my alarm app as well. What I did was a workaround when your app is in background. You play a music file in your code in background and increase the volume of the device to maximum. You can play as much longer music file as you want. Stop playing the music when someone clicks on the notification.
The only problem with this is that your app should not be killed or terminated.

How to play music when receive local notification on background

I'm making an alarm function for my app and local notification is one of method I have searched. But when receive local notification it enable only 30s for it sound while I want my alarm play sound on 15 minute.
I can make 1 alarm sound on 15 minute with 30 notifications but my app need create a lot of alarm while iOS app allow only 64 or 128 local notifications. So I would like to run music on background when receive the notification, but how to do this?
Can anybody help me with this?
Many thanks.
If you want your app to play a 15 minute sound then you are going to need to set it up with the background mode flags in info.plist that declare it as a background sound playing app. You'll then need to ask for background time and quit background mode once your sound is complete.

Is it possible for timer running in iOS background?

I made a timer. After I hit home button in iOs simulator, it was still running in the background. I didn't save the state, I only added local notification. Why is that?
Also, I set to play a 4 seconds sound in notification and it came out that the sound only played 3 seconds. Is there a limitation of how long the sound can play for notification?
Maybe you selected one of them:

How to detect if UILocalnotification sound is playing or not

In my application I am using 'UILocalNotification` with a 30 sec audio file. I fire the notification when device is in lock mode. I tried to drag the notification on lock screen, then application will open at that Notification sound is playing, I need to recognize notification sound is playing or not when app is in foreground.
No good way, but you can use NSTimer. Start timer after show notification and make work when timer notify you. It will work, but use it only if any other resolution don't work.

Resources