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

Regex is not filtering on HMS (HarmonyOS) #243

Open
hsynksahin opened this issue Sep 30, 2024 · 0 comments
Open

Regex is not filtering on HMS (HarmonyOS) #243

hsynksahin opened this issue Sep 30, 2024 · 0 comments

Comments

@hsynksahin
Copy link

On my already deployed app, I've got an error feedback which is that my app can not read the message. I've checked every log and observed the situation on user's phone.

The problem is intead of the actual code in the message the OS sends back the B002 part of the message as the code. Furthermore my regex checks not accepting this code and user can not use this function. (This function is mandatory in this app so user can not use the app itself !)

My conclusion is the OS is not recognizing the REGEX given to the SmsAutoFill. And returning the last word in the message. Here is a part of my code:

Future<bool> _sendVerificationMessage() async {
  await _smsListener.listenForCode(smsCodeRegexPattern: r'\d{6}');

  // Sends message
_verificationCode = await _smsListener.getAppSignature.then((signature) async => await messageService.sendPhoneVerification(
              localization: Localization.of(context),
              phoneNumber: _state!.model.phoneNumber.replaceAll(' ', '').replaceAll('+', ''),
              signature: signature,
            ));
  
  _codeListener?.cancel();
  _codeListener = null;
  _codeListener = _smsListener.code.listen(_listenCode);
}

void _listenCode(String code) {
  if (!mounted) return;
  
  Log.trace('[PhoneScreen] Listened for code:\n`$code`');
  
  var filteredCode = RegExp(r'\d{6}').stringMatch(code);
  if (filteredCode == null) {
    Log.error(
      '[PhoneScreen] Listened code incompatible',
      stackTrace: StackTrace.current,
      upload: true,
    );
    return;
  }

  _checkCode(filteredCode); // Pastes code and proceeds...
}

There is no problems on any other Android device. I got this error only on one user's device which has OS as Huawei HMS. Downloaded app via GBox trough Google Play (This might be the one causing problem too).

Anyone else got this problem? Or as temporary solution, Is there a way to get the whole the message then parse the code myself ?

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

No branches or pull requests

1 participant