Access to volume down button press

We’ve included a selfie camera shot mode in our app. On iOS, people are used to take a snapshot with the volume down button in this case, so we’d like to support this as well. Unfortunately, I couldn’t find a way to access the hardware button state in Unity, as it doesn’t seem to have a key code.

I read online this was due to the fact that Apple used to reject apps that re-purposed hardware buttons. However, this seems to be outdated information from the time when Apple did not have this feature themselves. I could not find any section about this in their app guidelines, and there are apps like WhatsApp that support taking selfie shots via volume down.

Did anybody solve this, maybe with the help of some native plugin?

This is not doable in a straightforward way, and the way I know that works is frankly a quite ugly one.

So first of all, there are no APIs or events available to read that button press. The only way I know of (and shared among StackOverflow) is to actually create an audio session and monitor the volume change. (eugh) From there you may have to make an empty view that overrides the volume window, and possibly restore the volume programmatically.

1 Like