facebook

Is there a notification for iPhone’s volume up button

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #337269 Reply

    Is there a notification that I can listen to that will tell me when an iPhone’s volume up or down button is pressed ?

    #337275

    Brandon
    Member

    If you are doing a native app, yes, you can listen for the volumedownbutton or volumeupbutton events to be fired:
    http://docs.phonegap.com/en/2.5.0/cordova_events_events.md.html#volumedownbutton

    #337291

    Thanks for the tip. I tried it. But no luck. I added the code. Do i miss something. the event ‘deviceready’ is fired, but the event ‘volumedownbutton’ does not.

    
    phoneui.documentReadyHandler = function() {
    alert('load');
    }
        
      var pictureSource;   // picture source
      var destinationType; // sets the format of returned value 
    
        // Wait for Cordova to connect with the device
        //
        document.addEventListener("deviceready",onDeviceReady,false);
        
        // Cordova is ready to be used!
        //
         function onDeviceReady() {
            pictureSource=navigator.camera.PictureSourceType;
            destinationType=navigator.camera.DestinationType;
           document.addEventListener("volumedownbutton", onVolumeDownKeyDown, false);
          alert('onDeviceReady');
        }
        
       function onVolumeDownKeyDown() {
         alert('VolumeDownKeyDown');
        }
    
    #337302

    Brandon
    Member

    Try checking the Debugger to make sure there are no errors anywhere else in the script.
    Also, if you are building for Android make sure you set any permissions it may need, iOS doesnt have any to set.

    #337317

    Thank you for your reply,

    I was too fast and didn’t read the instruction that well, PhoneCap doesn’t support this event for iOS.

    I’m trying to make an application, to operate my lights, blinds by my iPhone and iPad. I wanted to use the volume buttons to dim the lights .

    Is there a another way?

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: Is there a notification for iPhone’s volume up button

You must be logged in to post in the forum log in