Control when to prompt "allow access to microphone"?


My ionic app needs access to microphone, but up until the Media plugin is invoked (i.e. click the recording button in UI), the prompt to ask users to allow access to microphone will appear.

This is a bad user experience. How to improve?
I was thinking of moving the prompt appearing to earlier, like when the page that contains recording functionality is opened. Is it viable?