title: How to create haptic feedback for a Button in SwiftUI?
body: <p>I'm trying to implement haptic feedback at the beginning of a tap for a Button in SwiftUI. Therefore I'm trying to use simultaneousGesture, but I'm sill struggling. I can't manage to figure out when the tap begins.</p>
  
  <p>Also there is no Haptic feedback implemented for Swift UI, so I guess I would blend it in from UIKit?</p>
  
  <p>I tried to implement the updating method of the TapGesture but it does not seem to do anything. This is what I've got so far. Thanks for any hints.</p>
  
  <pre class="lang-swift prettyprint-override"><code>struct HapticButton : View {
  
      @GestureState var isDetectingTap = false
  
      var body: some View {
  
          let tap = TapGesture()
              .updating($isDetectingTap) { (body, stateType, transaction) in
                  // nothing happens below
                  print(body)
                  print(stateType)
                  print(transaction)
              }.onEnded { _ in
                  // this one works but it is to late
                  // I need to figure out the beginning of the tap
                  print("Button was tapped, will invoke haptic feedback, maybe with UIKit")
          }
  
          return Button(action: {
              print("Action executed")
          }) {
              HStack {
                  Image("icon")
                  Text("Login")
              }
          }.simultaneousGesture(tap)
      }
  }
  
  </code></pre>