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
137 stars 124 forks source link

I get these errors after releasing the app. flutter run --release #169

Open binemmanuel opened 1 year ago

binemmanuel commented 1 year ago

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,
    );

   ...
}
rahulmaindargi commented 1 year ago

Did you find any solution? I am facing same issue.

rahulmaindargi commented 1 year ago

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.