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