shounakmulay / Telephony

Flutter plugin for telephony features like query device sms directory, listen for incoming messages, retrieve various network parameters, etc.
https://telephony.shounakmulay.dev
MIT License
140 stars 132 forks source link

Problems with Xiaomi/Redmi/MIUI #156

Open roip890 opened 2 years ago

roip890 commented 2 years ago

I don't know what it is happening.. but with my phone everything worked perfectly (Samsung Galaxy Note 20 Ultra). And when I tried it on Redmi 9 phone and Xiaomi MI 10 It didn't worked. I couldn't listen to messages at all. And the really weird part is that I even couldn't listen to messages on my phone (the Galaxy Note 20 Ultra) that comes from the Redmi and the Xiaomi phones..

RajLogistic commented 2 years ago

telephony.listenIncomingSms this method works fine in debug mode but not worked in release mode?

rxhul4 commented 1 month ago

(Solved) This below solution works with (another_telephony & telephony_fix as well.)

Few OS gives default Auto Start enabled to the app and few don't. MIUI does not give auto start enabled to the app as default config. Need to add auto start package (flutter_autostart: ^0.0.2) - Check if auto start is enabled or not, and if auto start is not enabled than open setting for the enduser using this package.

  final _flutterAutostartPlugin = FlutterAutostart();

  @override
  void initState() {
    checkIsAutoStartEnabled();
    super.initState();
  }

  Future<void> checkIsAutoStartEnabled() async {
    String isAutoStartEnabled;
    try {
      isAutoStartEnabled = await _flutterAutostartPlugin.checkIsAutoStartEnabled() == true ? "Yes" : "No";
      print("isAutoStartEnabled: $isAutoStartEnabled");
    } on PlatformException {
      isAutoStartEnabled = 'Failed to check isAutoStartEnabled.';
    }
    if (!mounted) return;
  }

  Future<void> openAutoStartPermissionSettings() async {
    String autoStartPermission;
    try {
      autoStartPermission =
          await _flutterAutostartPlugin.showAutoStartPermissionSettings() ?? 'Unknown autoStartPermission';
    } on PlatformException {
      autoStartPermission = 'Failed to show autoStartPermission.';
    }
    if (!mounted) return;
  }