Skip to content

fix: Square payment SDK integration#900

Merged
kirillzyusko merged 4 commits into
mainfrom
fix/recursive-responds-to-check
Apr 15, 2025
Merged

fix: Square payment SDK integration#900
kirillzyusko merged 4 commits into
mainfrom
fix/recursive-responds-to-check

Conversation

@kirillzyusko

@kirillzyusko kirillzyusko commented Apr 3, 2025

Copy link
Copy Markdown
Owner

📜 Description

Fixed an integration with Square SDK.

💡 Motivation and Context

The current problem is that SQIPTextFieldInputModifier always redirects call to an injected (KCCompositeDelegate) delegate - and it causes infinite loop that eventually leads to a crash 🤷‍♂️

I've tried to find source code of SQIPTextFieldInputModifier but it's closed, and I can not read it.

So far I had two approaches to fix it:

1️⃣ Add state variable and prevent infinite calls

While it solves the problem, it produces other problems - it looks like original delegate methods never gets called and in this case we break Square SDK, so it's not really an option.

2️⃣ Don't set delegate for SQIPTextFieldInputModifier

While it breaks the principle that any focused input will intercept events it makes certain sense:

  • seems like Square did such "protection" intentionally;
  • Square handler keyboard appearance on their own and it's not possible to use react-native-keyboard-controller component there.

So after thinking a while I decided that we shouldn't inject our delegate for Square SDK inputs. The solution may be not perfect, but for now it totally works. If it causes more issues, then I'll be glad to re-consider the solution with new info in mind.

Closes #896

📢 Changelog

iOS

  • don't substitute delegate for Square inputs;

🤔 How Has This Been Tested?

tested manually on iPhone 15 Pro (iOS 17.5) in repro example.

📸 Screenshots (if appropriate):

Simulator.Screen.Recording.-.iPhone.15.Pro.-.2025-04-15.at.10.09.54.mp4

📝 Checklist

  • CI successfully passed
  • I added new mocks and corresponding unit-tests if library API was changed

@kirillzyusko kirillzyusko added 🍎 iOS iOS specific 🎯 crash Library triggers a crash of the app focused input 📝 Anything about focused input functionality labels Apr 3, 2025
@kirillzyusko kirillzyusko self-assigned this Apr 3, 2025
@github-actions

github-actions Bot commented Apr 3, 2025

Copy link
Copy Markdown
Contributor

📊 Package size report

Current size Target Size Difference
176578 bytes 176273 bytes 305 bytes 📈

@kirillzyusko kirillzyusko changed the title fix: recursive respondsTo check fix: Square payment SDK integration Apr 15, 2025
@kirillzyusko kirillzyusko marked this pull request as ready for review April 15, 2025 08:18
@kirillzyusko kirillzyusko merged commit 033e043 into main Apr 15, 2025
@kirillzyusko kirillzyusko deleted the fix/recursive-responds-to-check branch April 15, 2025 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🎯 crash Library triggers a crash of the app focused input 📝 Anything about focused input functionality 🍎 iOS iOS specific

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Recursive stack overflow with Square in app payments sdk

1 participant