iOS Question How to use the BGTaskScheduler

Alexander Stolte

Expert
Licensed User
Longtime User
I would like to create an alarm clock app and have found apps in the app store that do exactly what I want to achieve.

e.g. ring in 8 hours, the apps regulate the volume in the background of the music that is then played -> so the app has to run in the background. I came across the following point in the documentation:

How can i use it in B4I?
 

Alexander Stolte

Expert
Licensed User
Longtime User
It doesn't let you run a task at a specific time.
But it must be possible somehow... I mean, there are also sleep tracking apps that run in the background all the time.

You should use a local notification as an alarm.
Unfortunately, this is not a solution. For example, I always have my phone on silent, so I would never hear the alarm and I also always have to make sure that I have the sound at a volume that I can hear. While the alarm clock apps regulate the volume while the music is playing.

Then I'll probably have to search a bit more
 
Upvote 0

Alessandro71

Well-Known Member
Licensed User
Longtime User
have a look at this thread
 
Upvote 0

Alessandro71

Well-Known Member
Licensed User
Longtime User
Did you get it to work?
my use case was not about scheduling task rather than having the app not suspended upon going in background.
apparently it allows the app to run even while not in foreground.
i don't know for how long though, since for my app need only some minutes
 
Upvote 0

Alessandro71

Well-Known Member
Licensed User
Longtime User
this is the code I use for plist

B4X:
#PlistExtra: <key>BGTaskSchedulerPermittedIdentifiers</key>
#PlistExtra: <array>
#PlistExtra:   <string>package.name.here</string>
#PlistExtra: </array>
#PlistExtra: <key>UIBackgroundModes</key>
#PlistExtra: <array>
#PlistExtra:   <string>bluetooth-central</string>
#PlistExtra:   <string>processing</string>
#PlistExtra: </array>

no other events/subs defined
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
But somehow the whole thing only works in the IOS simulator. Nothing happens on my Iphone when the app is in the background. I have already switched to VideoPlayer. But even the timer that controls the whole thing is only triggered when I bring the app back into the foreground. It works reliably in the simulator...
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
Solution:
 
Upvote 1
Solution
Top