0

I have a question for Telephony plugin,

I am developing a sms app with Flutter framework, and the developing sms app must have a function that can let my flutter sms app set as default sms app,In order to complete this,I invoked a method channel from Android native layer and worked normally,

It included several relative configure options in “AndroidManifest.xml”,the four configurations are all required,otherwise couldn’t work, according to the link https://stackoverflow.com/questions/30127564/how-do-i-set-my-app-as-the-default-sms-app to finish it, the above steps are correct, then followed Telephone plugin’s instructions to receive incoming sms message, once I sent any test sms message, would appear an error message that showed as below:

"java.lang.RuntimeException: Unable to instantiate receiver com.example.fluttertest7.SmsReceiver: java.lang.ClassNotFoundException: Didn't find class "com.example.fluttertest7.SmsReceiver" on path....." According to Telephony's manual, the mapped configuration of “AndroidManifest.xml” is

<receiver android:name="com.shounakmulay.telephony.sms.IncomingSmsReceiver" android:permission="android.permission.BROADCAST_SMS" android:exported="true"> <intent-filter> <action android:name="android.provider.Telephony.SMS_RECEIVED"/> </intent-filter> </receiver>

It looks like a conflict problem?They can not exist together?Once I removed the four configuration of “default sms app”,will receive incoming message,I am pretty confused for that, please help! Thanks a lot.

wjlester
  • 71
  • 3
  • Try this https://stackoverflow.com/questions/74644070/errorflutter-runtime-dart-vm-initializer-cc41unhandled-exceptionplatformexce/74712489#74712489 – Vepa Sabyrow Dec 12 '22 at 06:41
  • The answer I posted,it's incorrect for my problem,my problem is "receive", not "send" – wjlester Dec 12 '22 at 09:26
  • When your app is the default SMS app, it receives a special broadcast of `SMS_DELIVER`, and your manifest apparently says that the `".SmsReceiver"` class is supposed to handle it, but that class doesn't exist, which is why it's throwing. If your app is only meant to receive messages while it's set as the default app, then you could simply get rid of the `` for `".SmsReceiver"` altogether, and change the action on the one for `"com.shounakmulay.telephony.sms.IncomingSmsReceiver"` from `SMS_RECEIVED` to `SMS_DELIVER`, since it doesn't check for a specific action in its `onReceive()`. – Mike M. Dec 12 '22 at 15:53
  • @Mike M. Thanks for your help,I added "SMS_DELIVER" to telephony section, now I can receive incoming message in my app,but the incoming message didn't appear in SMS push notification,a little weired,how should I do to fix it?Thank you very much. – wjlester Dec 13 '22 at 03:35
  • The default app is responsible for those notifications. It's also responsible for a whole bunch of other stuff, like saving those incoming SMS messages, saving its own outgoing messages, updating relevant conversations, handling incoming and outgoing MMS (and RCS too, these days), etc. If your app doesn't do those things while it's set as the default, they just won't get done, and you can't hand off those responsibilities, either. Some things, only the default can do, and for the rest, no other app is going to be set up to notice and handle whatever default doesn't. – Mike M. Dec 13 '22 at 04:02
  • @Mike M Thank you,I will continue to complete some of necessary functions to test. – wjlester Dec 15 '22 at 01:38
  • @Mike M Hi,I performed all functions of sms app and set it as default,it still didn't pop up the sms notification,do I need to call the Indent of sms notification from Android native layer when the sms message is coming,or something I missed?Or can I use Flutter plugins to fulfill such as "awesome notification",I'm not sure it's useful or not,based on you said last time,they shouldn't have fulfilled,it's so difficult for me,can you please give me some suggestions if you can,thanks again. – wjlester Dec 20 '22 at 07:47
  • You have to create and post them yourself; they don't happen automatically. And they're just regular local `Notification`s, so whichever way you prefer to do those in Flutter is fine. I've never used Flutter, but it sounds like Awesome Notifications would work. – Mike M. Dec 20 '22 at 08:06

0 Answers0