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

Listening to incoming messages #174

Open
Trend74X opened this issue Jan 16, 2023 · 1 comment
Open

Listening to incoming messages #174

Trend74X opened this issue Jan 16, 2023 · 1 comment

Comments

@Trend74X
Copy link

I am using telephony: 0.2.0, flutter version: 3.3.8

I am trying to listen to message received, it works when the messages is sent by the service providers, but it doenst work when the sms is sent from another mobiles.

is anyone else experiencing this problem? is there a solution

I have also added to android manifest files.

`
onBackgroundMessage(SmsMessage message) {
debugPrint("onBackgroundMessage called");
mainController.newSMSReceived(message);
}

@OverRide
void initState() {
super.initState();
listenToNewSms();
}

listenToNewSms() async {
final bool? result = await telephony.requestPhoneAndSmsPermissions;

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

if (!mounted) return;

}

onMessage(message) async {
mainController.newSMSReceived(message);
}
`

@aman-singh7
Copy link

Yes, I am also facing this issue.

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

2 participants