Telephony
Telephony copied to clipboard
PlatformException - failed_to_fetch_sms
Hi, I'm getting this error whenever I try to send an SMS. I tried with both Flutter 2.10.5 and 3.0.1
_telephony.sendSms(to: '00359882077170', message: 'Hello!');
E/flutter ( 975): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: PlatformException(failed_to_fetch_sms, Flutter Telephony: Error getting SmsManager, null, null)
E/flutter ( 975): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7)
E/flutter ( 975): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:167:18)
E/flutter ( 975): <asynchronous suspension>
E/flutter ( 975): #2 Telephony.sendSms (package:telephony/telephony.dart:321:5)
E/flutter ( 975): <asynchronous suspension>
E/flutter ( 975):
It's always there.
Same Error.
@chavdardonchev , I think in the telephony: ^0.2.0, there is some error. You may try the telephony: ^0.1.4. It's worked for me.
@swayamshreemohanty I tried it. It's impossible to build the app with 0.1.4. I should probably downgrade the Flutter version quite a lot, which is very undesirable in my case.
@chavdardonchev , just change the telephony version name in the pubspec to 0.1.4. . Umm, is there any issue to change the version from 0.2.0 to 0.1.4?
@swayamshreemohanty Yes, I can't even run the app if I switch to 0.1.4. I get nasty errors at build time. 01.4 was released 1 year ago, which is quite long time ago and will probably work with Flutter 2.5 or maybe 2.8?. I'm with Flutter 2.10 and just switched to 3.0.1, hoping 0.2.0 will work (it was released after Fluter 3 with fixes for it). But 0.2.0 doesn't work with Flutter 3 either, because of that "failed_to_fetch_sms" exception.
@chavdardonchev , in my case, I'm using Flutter 3.0.0 with telephony 0.1.4 . It's working fine. Hope your problem will solve soon.
@swayamshreemohanty You aren't getting any error while using Flutter 3.0.0 with telephony 0.1.4 ?
Yea it's working properly @dibyanshu-mohanty Here is my project link: https://github.com/swayamshreemohanty/flutter_send_sms
Would you mind sharing th telephony send sms function @swayamshreemohanty
Here are the 2 types of functions before the build method: https://github.com/swayamshreemohanty/flutter_send_sms/blob/master/lib/sms_send_screen.dart
@chavdardonchev Would you please tell me the minSdk and compileSdk versions?
@shounakmulay minSdk : 23 and default targetSdk versions
@shounakmulay Yes, it is: minSdkVersion 23 targetSdkVersion 32
await _telephony.sendSms( to: element.contact.phones![0].value!, message: message.body ?? "", isMultipart: true);
Getting same issue for android version 9 and device Redmi note 6 pro. but the same code is working fine for android version 12, device Samsung G A52. @shounakmulay any help??
telephony.sendSms( to: _reciever.text, message: 'Key: ' + encryption('Configuration|' + _reciever.text + '|' + hasher('Configuration|' + _reciever.text + phoneID)), statusListener: listener);
android version 12 with the latest update flutter 0.2.0 is perfectly fine but if i run my app with lower android version with flutter 0.2.0 there's an error with the failed_to_fetch_sms. When i downgrade to flutter 0.1.4 running on an android version lower than 12 is perpectly fine but on android 12 with flutter 0.1.4 will have the error this time.
minSdkVersion 23 targetSdkVersion 31
any update?
need fix of this issue, any update ?
@shounakmulay any update on this.
telephony.sendSms( to: _reciever.text, message: 'Key: ' + encryption('Configuration|' + _reciever.text + '|' + hasher('Configuration|' + _reciever.text + phoneID)), statusListener: listener);
android version 12 with the latest update flutter 0.2.0 is perfectly fine but if i run my app with lower android version with flutter 0.2.0 there's an error with the failed_to_fetch_sms. When i downgrade to flutter 0.1.4 running on an android version lower than 12 is perpectly fine but on android 12 with flutter 0.1.4 will have the error this time.
minSdkVersion 23 targetSdkVersion 31
#153 fix controller error, this solves my problem
hope this help 🙂 https://github.com/shounakmulay/Telephony/issues/149#issuecomment-1212695720