Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

iOS SwiftUI: Custom Click Gestures Not Recording for Button Taps (While Swipes Work)

33 views
Skip to first unread message
Message has been deleted

Thaoiie

unread,
Feb 17, 2025, 6:30:47 AMFeb 17
to Google Mobile Ads SDK Developers
Hello,

I'm encountering an issue with custom click gesture recording in my SwiftUI application. While swipe gestures are working correctly, tap gestures are not being properly recorded despite following what appears to be the correct implementation.

Current implementation details:
  • iOS 18.0+
  • GoogleMobileAds SDK 11.13.0
  • Using SwiftUI Button(_:action:) component
  • Account is allow-listed
  • Custom click gestures are enabled (GADNativeAd.enableCustomClickGestures)
  • Recording is attempted at the earliest possible point in the tap action

Working scenario:
  • Swipe interactions using SwiftUI DragGesture().onEnded successfully record
  • These use the same GADNativeAd.recordCustomClickGesture() call

Non-working scenario:
  • Tap interactions using Button action handler
  • Receiving console message: "<Google> <Google:HTML> Custom clicks must be reported immediately after they are detected."
  • This occurs even though recordCustomClickGesture() is called directly in the button's action handler

The interesting part is that both implementations (swipe and tap) use the same recordCustomClickGesture() method, but only the swipe gesture is accepted as valid by the SDK.

Questions:
1. Is there a specific timing requirement or context needed for button taps that differs from swipe gestures?
2. Are there any SwiftUI-specific considerations for handling custom click gestures?
3. Is there a recommended way to implement custom click gestures with SwiftUI buttons?

Any guidance would be greatly appreciated, particularly regarding best practices for handling custom ad interactions in SwiftUI applications.

Thank you!

Mobile Ads SDK Forum Advisor

unread,
Feb 18, 2025, 5:49:30 PMFeb 18
to thaoi...@gmail.com, google-adm...@googlegroups.com

Hi,

Thank you for contacting the Mobile Ads SDK support team.

It looks like you haven't passed GADNativeAdCustomClickGestureOptions. I would suggest to pass GADNativeAdCustomClickGestureOptions while requesting ads as GADAdLoaderOptions in GADAdLoader request.

let rightSwipeOption = GADNativeAdCustomClickGestureOptions(swipeGestureDirection: .right, tapsAllowed: true)
let leftSwipeOption = GADNativeAdCustomClickGestureOptions(swipeGestureDirection: .left, tapsAllowed: true)
let upSwipeOption = GADNativeAdCustomClickGestureOptions(swipeGestureDirection: .up, tapsAllowed: true)
let downSwipeOption = GADNativeAdCustomClickGestureOptions(swipeGestureDirection: .down, tapsAllowed: true)

adLoader = GADAdLoader(adUnitID: "ca-app-pub-xxxxxxxx9942544/xxxxx24511", rootViewController: nil, adTypes: [.native], options:[rightSwipeOption, leftSwipeOption, upSwipeOption, downSwipeOption]) 

Kindly reach out to us again if you face any other issue related to Mobile Ads SDK.

Thanks,
 
Google Logo Mobile Ads SDK Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5
[2025-02-18 22:48:46Z GMT] This message is in relation to case "ref:!00D1U01174p.!5004Q02vH2CN:ref" (ADR-00288563)



Reply all
Reply to author
Forward
0 new messages