You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
how do i stop listening after i've received the sms i'm interested in, or how do i make it so that if after 30 seconds we've received nothing we can stop listening and return a waiting message. here's the function I've made.
try {
// Créez une fonction pour vérifier si un message vous intéresse
bool isInterestingMessage(SmsMessage message) {
if (message.address == "OrangeMoney" ||
message.address == "MobileMoney") {
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,
);
how do i stop listening after i've received the sms i'm interested in, or how do i make it so that if after 30 seconds we've received nothing 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 == "OrangeMoney" ||
message.address == "MobileMoney") {
int currentTime = DateTime.now().millisecondsSinceEpoch;
int timeDifference = currentTime - message.date!;
int minutes = timeDifference ~/ 60000;
} catch (e) {
print("wow wow wow wow wow .... va regarder:" + e.toString());
}
String sms = await completer.future;
return sms;
}
`
The text was updated successfully, but these errors were encountered: