I am currently working on a task with background and foreground stuffs. Is it possible for me to detect my app when my app WILL GO to background? I've searched and read many information from internet but I didn't get what I want. When I search on internet It's all about "when the app moves to background", "when the app already in background", and something that it's already happen in background.
So far, I already tried with UIApplicationWillResignActiveNotification
but, willResignActive does not mean it is going into the background -- it means it is going inactive. (an incoming call on top of your app , when I click Siri, and when notification come).
I already tried with DidEnterBackground
but ya, It only triggered when it's already in background mode.
Why I want to know this answer? Because, I want to enable Picture in Picture mode when the app is in the background mode (not in the foreground mode). So, I disable the Picture-in-Picture in the foreground mode then I enable that when in background mode. I know, normally Apple auto enable the PiP in the background and when user click the PiP mode.
The reason why I want make this because, it's so annoying if user always must enable the PiP mode. So, I think It would be 'clean' if I enable this feature when my app in background mode.
So, how do I know if my app Will Go to background? I am open with any suggestion.