Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

some volume events missed (xcode 13) #62

Open
ashley-mort opened this issue Aug 13, 2022 · 1 comment
Open

some volume events missed (xcode 13) #62

ashley-mort opened this issue Aug 13, 2022 · 1 comment

Comments

@ashley-mort
Copy link

ashley-mort commented Aug 13, 2022

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
Copy link

Have you solved this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants