Is it possible for timer running in iOS background? - ios

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:

Related

Push Notification sound stops when the notification badge disappears

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?

How to build iOS Swift Alarm App with background Task

Im facing troubles with an app im working on.
I already have an android app that is running like that:
A background task i checking every 30 seconds an api to check if there is something going on my server.
When there is a result an alarm will come up and plays an mp3 and then shows an full screen activity with text and buttons.
The mp3 will be repeated for 5 minutes or when the user clicks on a button and replies to the alarm.
The mp3 is also played even if the pohone settings are on mute.
I also have an Setting inside the app where you can choose to mute the sound and only show the activity.
I need to have the same behaviour in my ios app but have no idea how to handle it in Swift.
The background task itself is also terminated after 30 seconds.

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.

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