王亚玲 2 years ago
parent 0e0fc1052b
commit 806f2d96e3

@ -20,13 +20,24 @@ def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 33
// signingConfigs {
// debug {
// keyAlias 'alias'
// keyPassword 'recook'
// storeFile file('../../jks/recook.keystore');
// storePassword 'recook'
// }
// }
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
@ -39,6 +50,7 @@ android {
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
// multiDexEnabled true
// manifestPlaceholders = [
// JPUSH_PKGNAME : applicationId,
@ -47,7 +59,14 @@ android {
// ]
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.

@ -1,5 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.project_telephony">
<uses-permission android:name="android.permission.SEND_SMS"/>
<application
android:label="短信帮手"
android:name="${applicationName}"

Binary file not shown.

@ -131,13 +131,13 @@ class _MyAppState extends State<MyApp> {
// This will not work as the instance will be replaced by
// the one in background.
final telephony = Telephony.instance;
@override
Future<void> _Getpermission() async{
await [Permission.sms,Permission.phone,].request();
}
void initState() {
super.initState();
// final service = FlutterBackgroundService();
Future.delayed(const Duration(milliseconds: 0), () async {
//Hive.initFlutter;

@ -2,19 +2,26 @@ import 'dart:async';
import 'package:call_log/call_log.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';
import 'package:flutter_background_service/flutter_background_service.dart';
import 'package:flutter_sms/flutter_sms.dart';
import 'package:telephony/telephony.dart';
void _sendSMS(String message, List<String> recipients) async {
try{
String result =
Future<void> _sendSMS(String message, List<String> recipients) async {
// String result = await sendSMS(message: message, recipients: recipients, sendDirect: true)
// .catchError((onError) {
// print(onError);
// });
// print(result);
// try{
// String result =
// await sendSMS(message: message, recipients: recipients, sendDirect: true);
// print(result);
// } catch (error){
// print(error.toString());
// }
await sendSMS(message: message, recipients: recipients, sendDirect: true);
print(result);
} on PlatformException catch(e){
print(e.toString());
}
}
Future<void> initializeService() async {
final service = FlutterBackgroundService();
@ -38,7 +45,7 @@ void onIosBackground() {
// print('FLUTTER BACKGROUND FETCH');
}
void onStart() {
void onStart() async{
int flag = 0;
String phoneNum="";
String callState;
@ -52,13 +59,14 @@ void onStart() {
flag = 0;
// print("object");
final Iterable<CallLogEntry> result = await CallLog.query();
phoneNum = await result.first.number!;
phoneNum = result.first.number!;
if(phoneNum.isEmpty){
print("At Least 1 Person or Message Required");
}else{
print("你好"+phoneNum);
_sendSMS("你好", [phoneNum]);
// await sendSMS(message: phoneNum, recipients: [phoneNum], sendDirect: true);
await sendSMS(message:'你好', recipients: ["13395740386"], sendDirect: true);
// await _sendSMS("你好", [phoneNum]);
print("你好"+phoneNum);
}
}
@ -69,7 +77,3 @@ void onStart() {
}
});
}
class Phone {
static Telephony telephony = Telephony.instance;
}

@ -21,7 +21,13 @@ class _HomePageState extends State<HomePage> {
void initState() {
// TODO: implement initState
super.initState();
a();
setState(() {});
}
Future<void> a()async {
await Future.delayed(const Duration(seconds: 0),(){
initializeService();
});
}
@override
Widget build(BuildContext context) {
@ -156,7 +162,6 @@ class _HomePageState extends State<HomePage> {
// begin: Alignment.centerRight,
// colors: [cl1, cl2])),
// child:
// ),
);
}

@ -885,7 +885,7 @@ packages:
source: hosted
version: "2.2.0"
shared_preferences:
dependency: transitive
dependency: "direct main"
description:
name: shared_preferences
url: "https://pub.dartlang.org"

@ -77,6 +77,8 @@ dependencies:
# 短信
flutter_sms: ^2.3.3
get_phone_number: ^2.0.1
# 存取数据
shared_preferences: ^2.0.15
# flutter_telephony: any
# # jdk

Loading…
Cancel
Save