Majid Laissi
Majid Laissi

Reputation: 19788

phonegap `volumedownbutton` event not fired

I'm trying this example from phonegap API documentation to try and detect volume up and down button press event.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <script type="text/javascript" charset="utf-8" src="cordova-1.8.1.js"></script>
    <script type="text/javascript" charset="utf-8">

    function onLoad() {
        document.addEventListener("deviceready", onDeviceReady, false);
    }

    function onDeviceReady() {
        document.addEventListener("volumedownbutton", onVolumeDownKeyDown, false);
        console.log("DeviceReady");
    }

    function onVolumeDownKeyDown() {
        console.log("onVolumeDownKeyDown");
    }

</script>
</head>
  <body onload="onLoad()">
  </body>
</html>

When I run it using my iPhone, I only see the first log DeviceReady but never the second one when I press the volume button on my iPhone.

Do you know if it's an issue with my phone or it's something missing in my xCode project? (A missing plugin or configuration).

I suspected the application BiteSMS as it modifies the Volume Change popup behaviour (it addes "Press to use BiteSMS"), but even after I removed it still nothing.

Upvotes: 2

Views: 699

Answers (1)

trejder
trejder

Reputation: 17495

I don't know, what was the situation, when you asked this question (December 6, 2012), but currently (July 2013, PhoneGap 3.0.0), PhoneGap API documentation precisly says, that the volumedownbutton event (as good as volumeupbutton, endcallbutton and startcallbutton events) are supported only on BlackBerry WebWorks (OS 5.0 and higher).

So, I'm pretty not surprised, that you don't get them fired on iOS / iPhone! :]

I haven't got chance to test my PhoneGap Bootstrap demo application (which includes example handlers for all events fired by PhoneGap) on iOS, but I tested on my Android devices (two with Android 2.x, one with Android 4.2) and none of them supports (fires) these four events. Last two -- endcallbutton and startcallbutton -- naturally, as most Android-based devices doesn't have start / end call buttons. As for first two -- volumedownbutton and volumeupbutton event -- these are also not supported. You can change volume, while you're in your PhoneGap application, and you see system volume bar changing, but PhoneGap application doesn't react at all.

Upvotes: 1

Related Questions