parent
3d04ed9418
commit
d66244e002
@ -1,54 +1,63 @@
|
|||||||
import 'dart:async';
|
//
|
||||||
|
//
|
||||||
import 'package:call_log/call_log.dart';
|
// import 'dart:async';
|
||||||
import 'package:flutter_sms/flutter_sms.dart';
|
//
|
||||||
import 'package:telephony/telephony.dart';
|
// import 'package:call_log/call_log.dart';
|
||||||
bool _speechEnabled=false;
|
// import 'package:flutter_sms/flutter_sms.dart';
|
||||||
Future<void> _sendSMS(String message, List<String> recipients) async {
|
// import 'package:get/get_utils/get_utils.dart';
|
||||||
// String result = await sendSMS(message: message, recipients: recipients, sendDirect: true)
|
// import 'package:telephony/telephony.dart';
|
||||||
// .catchError((onError) {
|
// import 'package:workmanager/workmanager.dart';
|
||||||
// print(onError);
|
//
|
||||||
// });
|
// import '../user/user_page.dart';
|
||||||
// print(result);
|
// Future<void> _sendSMS(String message, List<String> recipients) async {
|
||||||
try{
|
// // await sendSMS(message: message, recipients: recipients, sendDirect: true);
|
||||||
String result =
|
// try{
|
||||||
await sendSMS(message: message, recipients: recipients, sendDirect: true);
|
// String result =
|
||||||
print(result);
|
// await sendSMS(message: message, recipients: recipients, sendDirect: true);
|
||||||
} catch (error){
|
// print(result);
|
||||||
print(error.toString());
|
// } catch (error){
|
||||||
}
|
// print(error.toString());
|
||||||
void _initSpeech() async{
|
// }
|
||||||
_speechEnabled=await canSendSMS();
|
//
|
||||||
}
|
// }
|
||||||
Future sms() async{
|
// void callbackDispatcher() {
|
||||||
int flag = 0;
|
// Workmanager().executeTask((task, inputData) async{
|
||||||
String phoneNum="";
|
// // _sendSMS("感谢来电", ["13486828191"]);
|
||||||
String callState;
|
// // ${Telephony.backgroundInstance.sendSms(to: "13486828191", message: "message")}
|
||||||
// WidgetsFlutterBinding.ensureInitialized();
|
// print("123412312412312312431231231231231231313123:${ _sendSMS("感谢来电", ["13486828191"])}");
|
||||||
Timer.periodic(const Duration(seconds: 1), (timer) async {
|
// await sendSMS(message: "感谢来电", recipients: ["1348å6828191"], sendDirect: true);
|
||||||
CallState state = await Telephony.instance.callState;
|
// // sms();//simpleTask will be emitted here.
|
||||||
callState = state.name;
|
// return Future.value(true);
|
||||||
// print(callState!+" $flag");
|
// });
|
||||||
if (callState == "IDLE") {
|
// }
|
||||||
if (flag != 0) {
|
// void sms() async{
|
||||||
flag = 0;
|
// int flag = 0;
|
||||||
// print("object");
|
// String phoneNum="";
|
||||||
final Iterable<CallLogEntry> result = await CallLog.query();
|
// String callState;
|
||||||
phoneNum = result.first.number!;
|
// CallState state = await Telephony.instance.callState;
|
||||||
if(phoneNum.isEmpty){
|
// callState = state.name;
|
||||||
print("At Least 1 Person or Message Required");
|
// // print(callState!+" $flag");
|
||||||
}else{
|
// if (callState == "IDLE") {
|
||||||
print("你好"+phoneNum);
|
// if (flag != 0) {
|
||||||
// await sendSMS(message: phoneNum, recipients: [phoneNum], sendDirect: true);
|
// flag = 0;
|
||||||
// await sendSMS(message:'你好', recipients: ["13395740386"], sendDirect: true);
|
// // print("object");
|
||||||
await _sendSMS("你好", [phoneNum]);
|
// final Iterable<CallLogEntry> result = await CallLog.query();
|
||||||
print("你好"+phoneNum);
|
// phoneNum = result.first.number!;
|
||||||
}
|
// if(phoneNum.isEmpty){
|
||||||
}
|
// print("At Least 1 Person or Message Required");
|
||||||
} else if (callState == "RINGING") {
|
// }else{
|
||||||
flag++;
|
// print("你好$phoneNum");
|
||||||
} else if (callState == "OFFHOOK") {
|
// // telephony.sendSms(to: phoneNum, message: "1234");
|
||||||
flag++;
|
// _sendSMS('感谢来电',[phoneNum]);
|
||||||
}
|
// // print("你好123123$phoneNum");
|
||||||
});
|
// }
|
||||||
}}
|
// }
|
||||||
|
// } else if (callState == "RINGING") {
|
||||||
|
// flag++;
|
||||||
|
// print('flag $flag');
|
||||||
|
// } else if (callState == "OFFHOOK") {
|
||||||
|
// flag++;
|
||||||
|
// print('flag $flag');
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
Loading…
Reference in new issue