Tkko / Flutter_Pinput

Flutter package to create Pin code input text field with every pixel customization possibility 🎨 with beautiful animations, iOS autofill, Android autofill
https://pub.dev/packages/pinput
MIT License
776 stars 179 forks source link

Bug: SmartAuth getSmsCode is not supported on TargetPlatform.iOS #194

Open burekas7 opened 2 months ago

burekas7 commented 2 months ago

Hi,

I use your SmsRetrieverImpl implementation. There is a bug regarding the getSmsCode().

  @override
  Future<String?> getSmsCode() async {
    final res = await smartAuth.getSmsCode();
    if (res.succeed && res.codeFound) {
      return res.code!;
    }
    return null;
  }

It's ok when running Android.

But when running iOS, there is an error: flutter: SmartAuth getSmsCode is not supported on TargetPlatform.iOS

So I add this condition: Platform.isAndroid, but on iOS the screen is getting stuck, I can't press on anything. Maybe it shouldn't be return null? (I tried also return '', doesn't work)

  @override
  Future<String?> getSmsCode() async {
    if (Platform.isAndroid) {
      final res = await smartAuth.getSmsCode();
      if (res.succeed && res.codeFound) {
        return res.code!;
      }
    }
    return null;
  }

Pinput version: 5.0.0

Flutter: 3.24.2 iOS: 17.5.1

burekas7 commented 2 months ago

This is the solution:

Pinput(
      smsRetriever: Platform.isAndroid ? smsRetrieverImpl : null,
burekas7 commented 2 months ago

@Tkko Is this the correct way to solve it? I know that previously for iOS the code was shown above the keyboard.