Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keeps crashing in background #193

Open
gsharewz opened this issue Jul 19, 2023 · 4 comments
Open

Keeps crashing in background #193

gsharewz opened this issue Jul 19, 2023 · 4 comments

Comments

@gsharewz
Copy link

Telephony is keep crashing in background for any device.
Code

Telephony.instance.listenIncomingSms(
           onNewMessage: (SmsMessage message) {
             // debugPrint('Received message => ${message.body}');
             updateDataOnSms(message);
           },
           onBackgroundMessage: (SmsMessage message) =>
               backgrounMessageHandler(message));

Exception
E/AndroidRuntime( 9362): Caused by: java.lang.NullPointerException: Attempt to read from field 'java.lang.String io.flutter.view.FlutterCallbackInformation.callbackLibraryPath' on a null object reference

@gsharewz
Copy link
Author

I tried downgrading the flutter version but that didn't help me.

@faizann
Copy link
Contributor

faizann commented Aug 11, 2023

Hi

I upgraded flutter recently and the app mostly can't receive SMS. Did you figure out the solution for your issue?

@thanhdang198
Copy link

Hi

I upgraded flutter recently and the app mostly can't receive SMS. Did you figure out the solution for your issue?

Seem the author is not continue maintained, so you can check my fork at https://pub.dev/packages/another_telephony to resolve this

@fumant2000
Copy link

Salut
J'ai récemment mis à jour Flutter et l'application ne peut généralement pas recevoir de SMS. Avez-vous trouvé la solution à votre problème ?

Il semble que l'auteur ne soit pas maintenu, vous pouvez donc vérifier mon fork sur https://pub.dev/packages/another_telephony pour résoudre ce problème

how to stop listening after having received the sms I'm interested in, or how to make it so that if after 30 seconds nothing is received we can stop listening and return a waiting message. here's the function I've made.

`import 'package:telephony/telephony.dart';

import 'dart:async';

Future smsSensor() async {
Completer completer = Completer();
Telephony telephony = Telephony.instance;

try {
// Créez une fonction pour vérifier si un message vous intéresse
bool isInterestingMessage(SmsMessage message) {
if (message.address == "TITO" ||
message.address == "TATA") {
int currentTime = DateTime.now().millisecondsSinceEpoch;
int timeDifference = currentTime - message.date!;
int minutes = timeDifference ~/ 60000;

    // Vérifiez si le message a été reçu il y a moins d'une minute
    if (minutes < 2) {
      // Ajoutez ici votre logique pour filtrer les messages en fonction de leur contenu
      // Par exemple, vérifiez s'il contient des mots-clés spécifiques
      if (message.body?.contains("Transfert de") == true ||
          message.body?.contains("Vous avez recu") == true ||
          message.body
                  ?.contains("avez effectue avec succes le retrait de") ==
              true ||
          message.body?.contains("You have received") == true ||
          message.body?.contains(
                  "Vous avez effectue avec succes le retrait de") ==
              true ||
          message.body?.contains("Retrait d'argent reussi par") == true) {
        return true;
      }
    }
  }
  return false;
}
telephony.listenIncomingSms(
  onNewMessage: (SmsMessage message) {
    if (isInterestingMessage(message)) {
      completer.complete(message.body!);
    }
  },
  listenInBackground: false,
);

} catch (e) {
print("wow wow wow wow wow .... va regarder:" + e.toString());
}

String sms = await completer.future;
return sms;
}
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants