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

some volume events missed (xcode 13) #62

@ashley-mort

Description

@ashley-mort

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)
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions