Skip to content

Conversation

@chroxify
Copy link
Contributor

@chroxify chroxify commented Jan 29, 2026

Changes in this pull request

  • Adds native haptic feedback support for paywall buttons. Haptic types can be configured in the paywall editor and include light, medium, heavy, success, warning, error, and selection.

Checklist

  • All unit tests pass.
  • All UI tests pass.
  • Demo project builds and runs on iOS.
  • Demo project builds and runs on Mac Catalyst.
  • Demo project builds and runs on visionOS.
  • I added/updated tests or detailed why my change isn't tested.
  • I added an entry to the CHANGELOG.md for any breaking changes, enhancements, or bug fixes.
  • I have run swiftlint in the main directory and fixed any issues.
  • I have updated the SDK documentation as well as the online docs.
  • I have reviewed the contributing guide

Greptile Overview

Greptile Summary

Added native haptic feedback support for paywall buttons, enabling configurable haptic types from the paywall editor.

Key Changes:

  • Introduced new hapticFeedback message type in PaywallMessage enum with proper JSON decoding
  • Implemented triggerHapticFeedback() method supporting 7 haptic types: light, medium, heavy, success, warning, error, and selection
  • Added comprehensive test coverage for message decoding and handler behavior
  • Updated CHANGELOG.md with version 4.12.10 entry

Implementation Details:

  • Haptic feedback is excluded on visionOS (using #if !os(visionOS) compiler directives)
  • Uses appropriate iOS feedback generators: UIImpactFeedbackGenerator for impact styles, UINotificationFeedbackGenerator for notifications, and UISelectionFeedbackGenerator for selections
  • Follows existing codebase patterns for message handling and webview communication

Note: Previous review thread mentioned calling .prepare() on generators for optimal performance. This remains unaddressed but is a minor performance optimization rather than a functional issue.

Confidence Score: 4/5

  • Safe to merge with minor performance optimization opportunity
  • The implementation is solid with comprehensive test coverage and follows existing patterns. The only issue is the missing .prepare() calls on feedback generators, which is a minor performance optimization rather than a functional problem. All haptic types are properly handled and visionOS is correctly excluded.
  • PaywallMessageHandler.swift could benefit from calling .prepare() on haptic generators before triggering

Important Files Changed

Filename Overview
Sources/SuperwallKit/Paywall/View Controller/Web View/Message Handling/PaywallMessage.swift Added hapticFeedback message case with proper decoding support
Sources/SuperwallKit/Paywall/View Controller/Web View/Message Handling/PaywallMessageHandler.swift Implemented triggerHapticFeedback() method supporting 7 haptic types, but missing .prepare() calls for optimal performance

Sequence Diagram

sequenceDiagram
    participant Web as Paywall WebView
    participant Handler as PaywallMessageHandler
    participant Generator as UIFeedbackGenerator
    participant System as iOS Haptic Engine

    Web->>Handler: haptic_feedback message<br/>(haptic_type: "medium")
    Handler->>Handler: handle(.hapticFeedback(hapticType))
    Handler->>Handler: triggerHapticFeedback("medium")
    
    alt visionOS
        Handler->>Handler: Skip (no haptics on visionOS)
    else iOS/iPadOS
        alt Impact Feedback (light/medium/heavy)
            Handler->>Generator: Create UIImpactFeedbackGenerator
            Generator->>System: impactOccurred()
        else Notification Feedback (success/warning/error)
            Handler->>Generator: Create UINotificationFeedbackGenerator
            Generator->>System: notificationOccurred()
        else Selection Feedback
            Handler->>Generator: Create UISelectionFeedbackGenerator
            Generator->>System: selectionChanged()
        else Unknown Type
            Handler->>Handler: No-op (default case)
        end
        System-->>Generator: Trigger haptic
    end

Loading

@chroxify chroxify marked this pull request as draft January 29, 2026 16:35
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@chroxify chroxify marked this pull request as ready for review January 29, 2026 17:13
@chroxify chroxify requested a review from yusuftor January 29, 2026 17:13
@yusuftor yusuftor merged commit 88593d4 into develop Jan 30, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants