My application have to start automatically dictation (with presentTextInputControllerWithSuggestions with an empty array of suggestions). For this, I schedule a dictation with a delay after X seconds on a certain screen.
But, I have a problem when the user quit the application before the starting of the dictation.
At the beginning, I just scheduled the dictation. If I left the application, the dictation started in background and when I came back on the application, I saw my screen but no dictation screen. If I tried to restart dictation, it didn't work (function is called and dictation start but also in background and the screen doesn't change).
So, I try not to start the dictation if application is leaving before. For this, I change a boolean in the applicationWillResignActive function in the ExtentienDelegate. But, my problem is that this function is not called immediately when the user quit the application. So, if user quit application 1 second or more, before the starting of dictation, the boolean is changed and the dictation doesn't start. When I come back, it works. But, if I quit just before the starting, the dictation continue to start in background and when I come back, I can't restart dictation.
So, could you tell me if there is a solution to change my boolean exactly when the application stop or to find another solution to this problem (stop dictation programmatically,...)