From 1f40e9fb55ca9ff44ab5c96e30e23ccfd827f20a Mon Sep 17 00:00:00 2001 From: "pouria.amini" Date: Thu, 18 Jul 2024 10:13:56 -0700 Subject: [PATCH] fix: add a guard to not add the customer gesture recognizer multiple times --- Sources/Amplitude/Plugins/iOS/UIKitUserInteractions.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sources/Amplitude/Plugins/iOS/UIKitUserInteractions.swift b/Sources/Amplitude/Plugins/iOS/UIKitUserInteractions.swift index 29ecacd..8af5eb9 100644 --- a/Sources/Amplitude/Plugins/iOS/UIKitUserInteractions.swift +++ b/Sources/Amplitude/Plugins/iOS/UIKitUserInteractions.swift @@ -61,6 +61,10 @@ class UIKitUserInteractions { @objc static func windowDidBecomeKey(_ notification: NSNotification) { guard setupAXBundle, let window = notification.object as? UIWindow else { return } + + if let windowGestureRecognizers = window.gestureRecognizers, windowGestureRecognizers.contains(where: { $0 is _AmplitudeSwiftUIGestureRecognizer }) { + return + } let swiftUIGestureRecognizer = _AmplitudeSwiftUIGestureRecognizer(target: UIKitUserInteractions.self, action: #selector(handleTap)) swiftUIGestureRecognizer.cancelsTouchesInView = false