Flutter_Pinput icon indicating copy to clipboard operation
Flutter_Pinput copied to clipboard

autofill not working on ios

Open Mohamedfaroouk opened this issue 2 years ago • 10 comments

I tried to use the autofill and it works perfectly with andriod but its not working with the ios

Pinput( androidSmsAutofillMethod: AndroidSmsAutofillMethod.smsUserConsentApi, length: 6, focusNode: _pinOTPCodeFocus, controller: _pinOTPController, defaultPinTheme: PinTheme( textStyle: TextStyle( color: Colors.white, fontSize: 16, ), width: 40.0, height: 50.0, decoration: pinOTPCodeDecoration), pinAnimationType: PinAnimationType.rotation, onCompleted: _onCompleted)

Mohamedfaroouk avatar Apr 21 '22 13:04 Mohamedfaroouk

User should tap on the code which should be shown on top of the keyboard try autofocus: true this will open the keyboard automatically, and when user receives a SMS the code should pop up

Screen Shot 2022-04-21 at 8 55 42 PM

Tkko avatar Apr 21 '22 16:04 Tkko

i tired this but the code dosnt apear on the keyboard

Mohamedfaroouk avatar Apr 30 '22 11:04 Mohamedfaroouk

Hello @Tkko,

unfortunately I have the same issue on IOS. If I put for example the autofillHints: [AutofillHints.email], that's working fine, but the sms code didn't appear. I am using the firebase sms authentication. After the code was sent a chapcha screen appear and disappear. I don't know if it can influence the functionality.

Best regards, Norbert

szusznorbert avatar Jun 12 '22 13:06 szusznorbert

Hi @szusznorbert,

  • Share example of sms
  • Are you passing any autofillHints? I just tried sending the sms "verification code: 1233" to my phone number while on https://flutter_pinput.codemagic.app/ and it works, check if it works for you as well.

In working I mean this:

Tkko avatar Jun 12 '22 14:06 Tkko

Hi @Tkko ,

first of all thank you for your fast reply. I didn't use any autofillHints. I have just tried just to be sure that the feature is working. I got the problem source. I tried your app, and I could get the code from my keyboard. Seems that the problem was that the firebase sent me the verification sms in Hungarian not in English. If I switched the language to English than it's working fine. Is there any possibility to handle the sms language? I suppose that the phone language should be also set to Hungarian in order to work the code cutting.

Thank you! Norbert

szusznorbert avatar Jun 12 '22 15:06 szusznorbert

@szusznorbert Interesting, I haven't had that issue before, and I'm not sure what's the workaround here, please let me know if you find the solution.

Tkko avatar Jun 12 '22 15:06 Tkko

Hi @Tkko

I am facing a similar issue on iOS. I tried the codemagic link on my device and the autofill was not always working.

  1. I tried sending verification code: 1234 and it was working fine.
  2. But when I sent the sms as The one time password to verify your number on xxx app is 9644 it was not able to pick it up.

I have also attached a screen recording with this comment.

Thank you

https://user-images.githubusercontent.com/34997841/176832849-4855595b-f110-43a7-90eb-2f5522c0e0b4.mp4

pranjalpc99 avatar Jul 01 '22 05:07 pranjalpc99

Hi @pranjalpc99 I believe this issue is out of my packages scope, could your try if the same happens for pure TextField? If yes, then you should also create an issue on Flutter repository.

Why I think so is that, I'm not doing anything for SMS autofill on WEB, it works out of the box.

I think the SMS code must follow some standards, which is not specified anywhere I looked for 😢, I saw some people have problems with other languages (Spanish). If you find anything helpful please share with us.

Tkko avatar Jul 01 '22 06:07 Tkko

Hi @Tkko Yes, there is some kind of SMS format that iOS uses which is not documented anywhere sadly 😢.

From my observation the format should be like the following:

  1. Code is 123456
  2. OTP is 123456
  3. code: 123456 etc.

pranjalpc99 avatar Jul 01 '22 07:07 pranjalpc99

Hi @Tkko Yes, there is some kind of SMS format that iOS uses which is not documented anywhere sadly 😢.

From my observation the format should be like the following:

1. Code is 123456

2. OTP is 123456

3. code: 123456
   etc.

True. Is there a work around for this?

definitelyme avatar Jul 15 '22 10:07 definitelyme

Hi @Tkko Yes, there is some kind of SMS format that iOS uses which is not documented anywhere sadly 😢. From my observation the format should be like the following:

1. Code is 123456

2. OTP is 123456

3. code: 123456
   etc.

True. Is there a work around for this?

Nothing that I know

Tkko avatar Oct 03 '22 16:10 Tkko

Closing this issue, feel free to reopen it if you need to.

Tkko avatar Oct 03 '22 16:10 Tkko

I need to open it @Tkko because I have problem with iOS release or debug version.

Here are my codes, that does not understand the coming OTP code: (Also the code coming as 0000 is your verification code)

Pinput(
          keyboardType: TextInputType.phone,
          androidSmsAutofillMethod: AndroidSmsAutofillMethod.smsUserConsentApi,
          autofocus: true,
          length: 4,
          controller: pinPutFieldController,
          onChanged: (value) {
            context.read<AuthBloc>().add(ChangeOTPCodeEvent(value));
          },
          defaultPinTheme: PinTheme(
            width: 56,
            height: 56,
            textStyle: const TextStyle(
              fontSize: 24,
              color: blackColor,
              fontWeight: FontWeight.w400,
            ),
            decoration: BoxDecoration(
              color: whiteColor,
              border: Border.all(color: kafileGreen),
              borderRadius: BorderRadius.circular(8),
            ),
          ),
        ),

FlutterWiz avatar May 09 '23 15:05 FlutterWiz

Hi @alperefesahin, to double check your issue, the code ins't showing on top of the keyboard, right?

Tkko avatar May 09 '23 16:05 Tkko

Yes @Tkko, right

FlutterWiz avatar May 09 '23 17:05 FlutterWiz

Temporarily replace Pinput with TextField and check if autofill works fine

Tkko avatar May 09 '23 17:05 Tkko

@Tkko it does not work also for TextField or TextFormField

FlutterWiz avatar May 10 '23 23:05 FlutterWiz

@alperefesahin Try to change SMS code to your verification code is 000000

Tkko avatar May 11 '23 06:05 Tkko

Tried, but still does not work for pinput and textfield @Tkko

FlutterWiz avatar May 11 '23 17:05 FlutterWiz

also tried it on android, and it works well, but on the other hand, iOS has a problem with getting the sms automatically. The incoming text like, Your verification code 0000, you can use it etc. @Tkko

FlutterWiz avatar May 11 '23 17:05 FlutterWiz

@alperefesahin SMS text guideline is not clear but what mentioned should work fine. Is the SMS text in English? If not it might be the issue.

Tkko avatar May 11 '23 17:05 Tkko

@Tkko the text is the Turkish language based, and unfortunately can't be changed. As I said, it works on Android as well, but for the iOS side, you said that the problem is related to "Language of the incoming text", right?

FlutterWiz avatar May 11 '23 17:05 FlutterWiz

Yeah that's correct. Apple also supports domain based verification so that should work https://developer.apple.com/news/?id=z0i801mg

Tkko avatar May 11 '23 17:05 Tkko