Best Practices With BGAppRefreshTask

I'm attempting to regularly interact with ApplicationMusicPlayer in MusicKit, even while in the background. I'd like to allow for changes in the network to allow me to change songs.

While this works fine while the application is in the foreground, due to idiosyncrasies with how ApplicationMusicPlayer does not in fact "count" for your application actively playing audio while in the background my network connection becomes lost.

I would like to check the network again while the app is in the background, and it seems like I could do so with BGAppRefreshTask. However, the frequency that I'd like to request would be on the order of sub-30s refresh timelines. This seems...excessive, given how BGAppRefreshTask seems to be documented.

Are there best practices in terms of what is an appropriate interval for BGAppRefreshTask being executed? Is there an upper or lower bound on intervals that is known? Should I consider using something different to achieve what I'm after?

Thanks for any help.

Answered by DTS Engineer in 753186022

However, the frequency that I'd like to request would be on the order of sub-30s refresh timelines. This seems...excessive

Indeed. That will not work.

There is no way to get resumed (or relaunched) in the background at that rate. See iOS Background Execution Limits.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer

However, the frequency that I'd like to request would be on the order of sub-30s refresh timelines. This seems...excessive

Indeed. That will not work.

There is no way to get resumed (or relaunched) in the background at that rate. See iOS Background Execution Limits.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thanks for confirmation.

Best Practices With BGAppRefreshTask
 
 
Q