Telephony
Telephony copied to clipboard
I get these errors after releasing the app. flutter run --release
Errors
E/flutter ( 5864): [ERROR:flutter/shell/common/shell.cc(93)] Dart Error: Dart_LookupLibrary: library 'package:telephony/telephony.dart' not found.
E/flutter ( 5864): [ERROR:flutter/runtime/dart_isolate.cc(668)] Could not resolve main entrypoint function.
E/flutter ( 5864): [ERROR:flutter/runtime/dart_isolate.cc(167)] Could not run the run main Dart entrypoint.
E/flutter ( 5864): [ERROR:flutter/runtime/runtime_controller.cc(385)] Could not create root isolate.
E/flutter ( 5864): [ERROR:flutter/shell/common/shell.cc(604)] Could not launch engine with configuration.
My Code
import 'package:telephony/telephony.dart';
import 'package:workmanager/workmanager.dart';
@pragma('vm:entry-point')
Future backgroundMessageHandler(SmsMessage smsMessage) async {
//Handle background message
log("==== Background Messages ==== $smsMessage");
// CustomerCardService.sendEmail(smsMessage.body ?? '');
Workmanager().registerOneOffTask('Send Email', 'send-email', inputData: {
'message': smsMessage.body,
});
return Future<void>.value();
}
void main() {
final telephony = Telephony.instance;
telephony.listenIncomingSms(
onNewMessage: (SmsMessage smsMessage) {
CustomerCardService.sendEmail(smsMessage.body ?? '');
},
onBackgroundMessage: backgroundMessageHandler,
listenInBackground: true,
);
...
}
Did you find any solution? I am facing same issue.
I am trying solution mentioned in https://github.com/shounakmulay/Telephony/issues/165
telephony:
git:
url: https://github.com/definev/Telephony.git
ref: develop
change is adding @pragma('vm:entry-point')
to telephony.dart
method
Not sure if and when it will merged to original package.