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

Not sure if it's a bug or not about background channel #78

Closed arkanmgerges closed 3 years ago

arkanmgerges commented 3 years ago

Hi sir, Thank you for providing this repo. I observed in the file telephony.dart the following on lines 81-84:

  static final Telephony _instance = Telephony._newInstance(
      const MethodChannel(_FOREGROUND_CHANNEL), const LocalPlatform());
  static final Telephony _backgroundInstance = Telephony._newInstance(
      const MethodChannel(_FOREGROUND_CHANNEL), const LocalPlatform());

Is this ok to have the same _FOREGROUND_CHANNEL for both the foreground and background?

I was trying to send sms from the background but it is not working. It is only working from foreground,

Thank you sir, Arkan

arkanmgerges commented 3 years ago

Also my intention is to send sms from a background (when my app is not active), my use case is to receive push notification from firebase, then in the background I want to send sms

meomap commented 3 years ago

I tried a similar setup to send SMS within firebase messaging background handler and got error

MissingPluginException (MissingPluginException(No implementation found for method sendSms on channel plugins.shounakmulay.com/foreground_sms_channel))

flutter 2.0.4 firebase_messaging 9.1.1 telephony 0.1.2

Other plugins like shared preference work fine in firebase background handler except for this one.

I think this PR broke the expected behavior https://github.com/shounakmulay/Telephony/commit/29ffc3381c2b576a9c502f331cf13fc6be4e7565#diff-d8470fb64214119fb5a3045932e214b0be49e6852ef472b778f1e1334873d789R35

I guess the reason for this PR is to allow the incoming sms handler to calls telephony's methods but it made the foreground channel unavailable for another plugin usage.

arkanmgerges commented 3 years ago

In my case, and because I needed to only send sms from (foreground and background), I've created a plugin on my local machine that does this (only on android), and I've tested it with FCM background function (from flutter), and it worked. Maybe someone will make some fixes for the Telephony plugin.

christianr11 commented 3 years ago

I've got the same error "No implementation found for method sendSms on channel plugins.shounakmulay.com/foreground_sms_channel". Im using Android Alarm Manager to trigger it in the background but unable for it to get working.

shounakmulay commented 3 years ago

Checkout version v0.1.3