Skip to content
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

Fix sms code entry using certain custom keyboards #358

Merged
merged 1 commit into from
Jul 18, 2016

Conversation

0thernet
Copy link
Contributor

@0thernet 0thernet commented Jul 1, 2016

r? @jflinter

tl;dr, When the delete key is pressed, some custom keyboards will call textDocumentProxy.insertText("") if the field is empty, rather than textDocumentProxy.deleteBackward(). This seems entirely at the discretion of the developer, so we should support both possibilities.

I tested entering SMS codes with a few custom keyboards:

  • Using the system number pad or Swype, when the delete key is pressed, deleteBackward is called.
  • Using Gboard or SwiftKey, deleteBackward is not called – instead, shouldChangeCharactersInRange: is called with an empty string.

A more heavy-handed solution would be to use UIKeyboardTypePhonePad, but that doesn't seem ideal.

Your custom keyboard is also ineligible to type into so-called phone pad objects, such as the phone number fields in Contacts. These input objects are exclusively for strings built from a small set of alphanumeric characters specified by telecommunications carriers and are identified by having one or another of the following two keyboard type traits: UIKeyboardTypePhonePad, UIKeyboardTypeNamePhonePad

https://developer.apple.com/library/prerelease/content/documentation/General/Conceptual/ExtensibilityPG/CustomKeyboard.html

@jflinter
Copy link

Hey @benzguo sorry it took me so long to get to this.

Honestly, I think we should just use UIKeyboardTypePhonePad here (and on STPPaymentCardTextField, etc). I'm getting worried about the amount of magic keyboard logic we're maintaining. The only difference is the "+*#" button in the lower-left, and we already ignore those characters if the user taps them (which they won't). Thoughts?

@0thernet 0thernet force-pushed the bg-fix-custom-kbs branch from 4051c26 to 903970a Compare July 14, 2016 15:04
@0thernet
Copy link
Contributor Author

That sounds reasonable to me – I've updated this PR to replace all occurrences of UIKeyboardTypeNumberPad with UIKeyboardTypePhonePad.

@0thernet 0thernet force-pushed the bg-fix-custom-kbs branch from 903970a to 05a256c Compare July 14, 2016 17:25
@jflinter
Copy link

thanks, lgtm in that case!

@jflinter jflinter assigned 0thernet and unassigned jflinter Jul 18, 2016
@0thernet 0thernet merged commit 87cf009 into master Jul 18, 2016
danj-stripe added a commit that referenced this pull request Dec 19, 2017
For STPFormTextField, this was a lot harder than expected, due to *always* returning NO
from `textField:shouldChangeCharactersInRange:replacementString:`. There's a workaround
for the way UIKit behaves, which is only applicable for the Phone Number field right now.

Also using `UIKeyboardTypeASCIICapableNumberPad` in `STPPaymentCardTextField` if available

Per [WWDC 2016](http://asciiwwdc.com/2016/sessions/201), this was specifically added to
support things like credit card entry:

> We’ve also localized the keyboard number pads this year. [...]
> Now in some cases, you might want to specify ASCII capable number pad instead when you’re sure that the input that you have needs to be restricted to ASCII digits.
> Some examples of this are credit card numbers and IP addresses.

I think this is redundant for the Credit Card Number field (just setting the
`textContentType` is sufficient to use this keyboard), but it'll help w/the expiration
and CVC.

These text fields fall back to using .PhonePad, apparently to avoid localized & third
party keyboards (#358), and as far as I can tell `.ASCIICapableNumberPad` continues to
avoid them.
@danj-stripe danj-stripe deleted the bg-fix-custom-kbs branch August 3, 2018 20:32
yuki-stripe pushed a commit that referenced this pull request Oct 8, 2021
* Define PaymentSheet events and use PaymentAnalytic

* Remove string building for event name

* Don't hardcode bindings version
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