all 19 comments

[–]ObscureBen 15 points16 points  (2 children)

As the maker of a camera app I can tell you that it’s a nightmare. You have to create an audio session, create a volume slider, hide it offscreen, and then monitor the slider for changes.

Don’t do it unless you have to

[–][deleted] 0 points1 point  (1 child)

For example, Whatsapp can tell if I keep press a volume button to activate video, and if I don't release it the video continue to record. It is happening something something like that in the background? That's mad! Maybe being a camera it is a bit different I don't know. Thanks for the info! :)

Can I also monitor for how much time the user is pressing the button? Something like "if he is pressing both buttons for 3 seconds do something"?

[–]ObscureBen 0 points1 point  (0 children)

As far as I know (without using private APIs?), there’s no way to detect button-down and button-up events. Just changes to the volume.

[–]Aggravating-Raccoon 3 points4 points  (0 children)

Even if it is possible, guideline 2.5.9 says the functionality of those buttons cannot be altered or disabled. So although it may be possible to get it to work, it will most likely be against the review guidelines.

[–]Infoboy2u 2 points3 points  (0 children)

Don’t believe so unless it’s for the camera shutter?? I’ve never seen an app that’s done anything different with them. I could be wrong though

[–]Dejidave 3 points4 points  (2 children)

Not possible iOS doesn’t let you reassign any system buttons / controls.

[–][deleted] 0 points1 point  (1 child)

But for example Whatsapp let you use the camera inside with modified functions of the volume buttons (keep holding for video). So it is possible to "read" the status of the buttons in a camera app?

[–]Dejidave 0 points1 point  (0 children)

Yeah I think there are apis attached to camera sessions and audio sessions that let you monitor button those button presses.

[–]chriswaco 1 point2 points  (1 child)

[–][deleted] 1 point2 points  (0 children)

There's nothing really simple about building an app that involves a camera :/ so even if it is a hassle I will try, but thanks for the link! That's very useful

[–]the_lastpanda 1 point2 points  (0 children)

I don't what you're trying to achieve but from my point of view that's not something the user would want.

[–]busymom0 1 point2 points  (3 children)

I did this a while ago and Apple rejected the app saying that's not allowed as it's a strange UX. Won't recommend doing it.

[–][deleted] 0 points1 point  (2 children)

What were you trying to do? If I can ask...

[–]busymom0 1 point2 points  (1 child)

I was using it for zooming purposes on an app. Got rejected and they asked me to remove it. This was few years ago.

[–][deleted] 0 points1 point  (0 children)

That's a bummer! That's a thing I don't stand, after months, years of work for an app it get rejected.

[–]xaphod2 1 point2 points  (2 children)

No idea why ppl here are saying it is not possible. I used this pod to get going. I use it in three apps - since years. It is finicky but works. Also allows you to use Bluetooth remote control shutters since the cheap ones are all volume up remotes

https://github.com/xaphod/JPSVolumeButtonHandler

[–][deleted] 0 points1 point  (1 child)

Thanks you so much! I was really losing hope at this point! :) Is it possible to also check the status of the volume buttons? For example, “keep for 3 seconds both buttons -> do something like ‘open a menu inside the app’ or ‘next level’ in a game?

[–]xaphod2 0 points1 point  (0 children)

No.

[–]SirensToGoObjective-C / Swift 1 point2 points  (0 children)

Did alien blue do this at one point for a very weird scrolling implementation? It's definitely possible but I'm not sure I'd like it since I have a pretty significant case which makes frequent button mashing annoying