Skip to content

fix: Square payment SDK integration #900

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 15, 2025

Conversation

kirillzyusko
Copy link
Owner

@kirillzyusko kirillzyusko commented Apr 3, 2025

📜 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
Copy link
Contributor

github-actions bot commented Apr 3, 2025

📊 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
15 checks passed
@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