Thank you so much for your reply! I tested implementing the beginBackgroundTask in my app, and it works as you say, it gives the app around 30 extra seconds to run after the app enters background. That helps, but the task of adding those songs to the playlist using MusicKit unfortunately takes more time than that. I guess I just have to look into switching to the Apple Music API which from what I have understood can handle batch loads of songs to a playlist, to make my app handle this quicker.
Topic:
App & System Services
SubTopic:
Processes & Concurrency