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
139 stars 126 forks source link

Example Code Not Working #91

Closed Kishan-Somaiya closed 3 years ago

Kishan-Somaiya commented 3 years ago

I copied the example code and added the necessary permissions in manifest and still didn't receive message in onMessage and in onBackgroundMessage. Any help would be appreciated. Plugin isn't asking for permissions too.

 Future<void> initPlatformState() async {
    // Platform messages may fail, so we use a try/catch PlatformException.
    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.

    final bool result = await telephony.requestPhoneAndSmsPermissions;

    if (result != null && result) {
      telephony.listenIncomingSms(
          onNewMessage: onMessage, onBackgroundMessage: onBackgroundMessage);
    }

    if (!mounted) return;
  }
prajwal27 commented 3 years ago

I've tried the example just few days back and worked for me. @Kishan-Somaiya could u go through the steps once more.

shounakmulay commented 3 years ago

Hey @Kishan-Somaiya

Could you try running the example code from the repo itself? Does that work for you.

Also make sure you have followed the steps listed in the documentation: https://shounakmulay.gitbook.io/telephony/listen-incoming-sms