How to call a function when the app is inactive (e.g. playing music in background)?
问题 I am making a music-streaming alarm clock. Music streams for the duration selected by the user, including in the background, and at the end of the duration a custom alarm sound is played in addition to a local notification. In short (1) set timer (2) local notification fires off (3) streamed music stops (4) alarm plays I am able to do (1) and (2) ok, but am unable to figure out how to trigger (3) or (4) when the app is in the background. Here is the code for (1) and (2) let center =