jpsim / JPSVolumeButtonHandler

JPSVolumeButtonHandler provides an easy block interface to hardware volume buttons on iOS devices. Perfect for camera apps!
MIT License
333 stars 90 forks source link

some volume events missed (xcode 13) #62

Open ashley-mort opened 1 year ago

ashley-mort commented 1 year ago

This works pretty well for me on ios 15.6 but sometimes an up or down event doesn't fire. I'm trying to make a stopwatch app and sometimes I have to press volume up or volume down twice to get the event to fire.

Any tips on if this can be fixed/improved or maybe I'm doing something wrong?

import SwiftUI
import JPSVolumeButtonHandler

struct ContentView: View {
    @State private var volumeHandler: JPSVolumeButtonHandler?
    var body: some View {
        ZStack {
            Text("Hello World")
        }
        .onAppear {
            volumeHandler = JPSVolumeButtonHandler(up: {
                print("up")
            }, downBlock: {
                print("down")
            })
            volumeHandler?.start(true)
        }
        .onDisappear {
            volumeHandler?.start(false)
        }
    }
}
glennposadas commented 11 months ago

Have you solved this?