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

When the sms is sent successfully, the onNewMessage callback (listenIncomingSms's callback) is executed #155

Closed hamsadev closed 2 years ago

hamsadev commented 2 years ago

I'm confused! Shouldn't listenIncomingSms callbacks be executed only to receive sms? When I call _sendSMS, the onNewMessage callback is also executed

Future<void> initPlatformState() async {
  final bool? result = await telephony.requestPhoneAndSmsPermissions;

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

  if (!mounted) return;
}
  Future<void> _sendSMS(String recipients, String password) async {
  final String? command = _commandMap[_selectedCommand];
  await telephony.sendSms(
    to: recipients,
    message: '$password*$command',
  );
}
hamsadev commented 2 years ago

I'm confused! Shouldn't listenIncomingSms callbacks be executed only to receive sms? When I call _sendSMS, the onNewMessage callback is also executed

Future<void> initPlatformState() async {
  final bool? result = await telephony.requestPhoneAndSmsPermissions;

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

  if (!mounted) return;
}
  Future<void> _sendSMS(String recipients, String password) async {
  final String? command = _commandMap[_selectedCommand];
  await telephony.sendSms(
    to: recipients,
    message: '$password*$command',
  );
}
hamsadev commented 2 years ago

I apologize, it was my mistake