9/24/1-backLocation
This commit is contained in:
@@ -112,6 +112,22 @@ class LoginDriverController extends GetxController {
|
||||
'token': box.read(BoxName.tokenDriver),
|
||||
'captain_id': box.read(BoxName.driverID).toString()
|
||||
});
|
||||
CRUD().post(
|
||||
link:
|
||||
"${AppLink.seferAlexandriaServer}/ride/firebase/addDriver.php",
|
||||
payload: {
|
||||
'token': box.read(BoxName.tokenDriver),
|
||||
'captain_id':
|
||||
box.read(BoxName.driverID).toString()
|
||||
});
|
||||
CRUD().post(
|
||||
link:
|
||||
"${AppLink.seferGizaServer}/ride/firebase/addDriver.php",
|
||||
payload: {
|
||||
'token': box.read(BoxName.tokenDriver),
|
||||
'captain_id':
|
||||
box.read(BoxName.driverID).toString()
|
||||
});
|
||||
Get.back();
|
||||
}));
|
||||
}
|
||||
@@ -139,5 +155,17 @@ class LoginDriverController extends GetxController {
|
||||
'token': box.read(BoxName.tokenDriver).toString(),
|
||||
'captain_id': box.read(BoxName.driverID).toString()
|
||||
});
|
||||
CRUD().post(
|
||||
link: "${AppLink.seferAlexandriaServer}/ride/firebase/addDriver.php",
|
||||
payload: {
|
||||
'token': box.read(BoxName.tokenDriver),
|
||||
'captain_id': box.read(BoxName.driverID).toString()
|
||||
});
|
||||
CRUD().post(
|
||||
link: "${AppLink.seferGizaServer}/ride/firebase/addDriver.php",
|
||||
payload: {
|
||||
'token': box.read(BoxName.tokenDriver),
|
||||
'captain_id': box.read(BoxName.driverID).toString()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,13 +94,96 @@ class RegisterCaptainController extends GetxController {
|
||||
return validPrefixes.hasMatch(phoneNumber);
|
||||
}
|
||||
|
||||
// sendOtpMessage() async {
|
||||
// SmsEgyptController smsEgyptController = Get.put(SmsEgyptController());
|
||||
// isLoading = true;
|
||||
// update();
|
||||
// int randomNumber = Random().nextInt(100000) + 1;
|
||||
// isLoading = true;
|
||||
// update();
|
||||
// if (formKey3.currentState!.validate()) {
|
||||
// if (box.read(BoxName.countryCode) == 'Egypt') {
|
||||
// if (isValidEgyptianPhoneNumber(phoneController.text)) {
|
||||
// var responseCheker = await CRUD()
|
||||
// .post(link: AppLink.checkPhoneNumberISVerfiedDriver, payload: {
|
||||
// 'phone_number': '+2${phoneController.text}',
|
||||
// });
|
||||
// if (responseCheker != 'failure') {
|
||||
// var d = jsonDecode(responseCheker);
|
||||
// if (d['message'][0]['is_verified'].toString() == '1') {
|
||||
// Get.snackbar('Phone number is verified before'.tr, '',
|
||||
// backgroundColor: AppColor.greenColor);
|
||||
// box.write(BoxName.phoneVerified, '1');
|
||||
// box.write(BoxName.phone, '+2${phoneController.text}');
|
||||
// await Get.put(LoginDriverController()).loginUsingCredentials(
|
||||
// box.read(BoxName.driverID).toString(),
|
||||
// box.read(BoxName.emailDriver).toString(),
|
||||
// );
|
||||
// } else {
|
||||
// await CRUD().post(link: AppLink.sendVerifyOtpMessage, payload: {
|
||||
// 'phone_number': '+2${phoneController.text}',
|
||||
// 'token_code': randomNumber.toString(),
|
||||
// "driverId": box.read(BoxName.driverID),
|
||||
// "email": box.read(BoxName.emailDriver),
|
||||
// });
|
||||
|
||||
// await smsEgyptController.sendSmsEgypt(
|
||||
// phoneController.text.toString(), randomNumber.toString());
|
||||
|
||||
// isSent = true;
|
||||
|
||||
// isLoading = false;
|
||||
// update();
|
||||
// }
|
||||
// } else {
|
||||
// await CRUD().post(link: AppLink.sendVerifyOtpMessage, payload: {
|
||||
// 'phone_number': '+2${phoneController.text}',
|
||||
// 'token_code': randomNumber.toString(),
|
||||
// "driverId": box.read(BoxName.driverID),
|
||||
// "email": box.read(BoxName.emailDriver),
|
||||
// });
|
||||
|
||||
// await smsEgyptController.sendSmsEgypt(
|
||||
// phoneController.text.toString(), randomNumber.toString());
|
||||
|
||||
// isSent = true;
|
||||
|
||||
// isLoading = false;
|
||||
// update();
|
||||
// }
|
||||
// } else {
|
||||
// Get.snackbar('Phone Number wrong'.tr, '',
|
||||
// backgroundColor: AppColor.redColor);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// isLoading = false;
|
||||
// update();
|
||||
// }
|
||||
sendOtpMessage() async {
|
||||
SmsEgyptController smsEgyptController = Get.put(SmsEgyptController());
|
||||
isLoading = true;
|
||||
update();
|
||||
|
||||
int randomNumber = Random().nextInt(100000) + 1;
|
||||
isLoading = true;
|
||||
update();
|
||||
|
||||
// Get the current time and the last OTP time (if it exists)
|
||||
DateTime currentTime = DateTime.now();
|
||||
DateTime? lastOtpTime = box.read(BoxName.lastOtpTime);
|
||||
|
||||
// Check if the last OTP was sent within 5 minutes (300 seconds)
|
||||
if (lastOtpTime != null &&
|
||||
currentTime.difference(lastOtpTime).inSeconds < 300) {
|
||||
Get.snackbar(
|
||||
'Please wait'.tr, 'You can send another OTP after 5 minutes.'.tr,
|
||||
backgroundColor: AppColor.redColor);
|
||||
isLoading = false;
|
||||
update();
|
||||
return;
|
||||
}
|
||||
|
||||
if (formKey3.currentState!.validate()) {
|
||||
if (box.read(BoxName.countryCode) == 'Egypt') {
|
||||
if (isValidEgyptianPhoneNumber(phoneController.text)) {
|
||||
@@ -108,6 +191,7 @@ class RegisterCaptainController extends GetxController {
|
||||
.post(link: AppLink.checkPhoneNumberISVerfiedDriver, payload: {
|
||||
'phone_number': '+2${phoneController.text}',
|
||||
});
|
||||
|
||||
if (responseCheker != 'failure') {
|
||||
var d = jsonDecode(responseCheker);
|
||||
if (d['message'][0]['is_verified'].toString() == '1') {
|
||||
@@ -120,36 +204,10 @@ class RegisterCaptainController extends GetxController {
|
||||
box.read(BoxName.emailDriver).toString(),
|
||||
);
|
||||
} else {
|
||||
await CRUD().post(link: AppLink.sendVerifyOtpMessage, payload: {
|
||||
'phone_number': '+2${phoneController.text}',
|
||||
'token_code': randomNumber.toString(),
|
||||
"driverId": box.read(BoxName.driverID),
|
||||
"email": box.read(BoxName.emailDriver),
|
||||
});
|
||||
|
||||
await smsEgyptController.sendSmsEgypt(
|
||||
phoneController.text.toString(), randomNumber.toString());
|
||||
|
||||
isSent = true;
|
||||
|
||||
isLoading = false;
|
||||
update();
|
||||
await _sendOtp(randomNumber, smsEgyptController);
|
||||
}
|
||||
} else {
|
||||
await CRUD().post(link: AppLink.sendVerifyOtpMessage, payload: {
|
||||
'phone_number': '+2${phoneController.text}',
|
||||
'token_code': randomNumber.toString(),
|
||||
"driverId": box.read(BoxName.driverID),
|
||||
"email": box.read(BoxName.emailDriver),
|
||||
});
|
||||
|
||||
await smsEgyptController.sendSmsEgypt(
|
||||
phoneController.text.toString(), randomNumber.toString());
|
||||
|
||||
isSent = true;
|
||||
|
||||
isLoading = false;
|
||||
update();
|
||||
await _sendOtp(randomNumber, smsEgyptController);
|
||||
}
|
||||
} else {
|
||||
Get.snackbar('Phone Number wrong'.tr, '',
|
||||
@@ -157,6 +215,26 @@ class RegisterCaptainController extends GetxController {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
isLoading = false;
|
||||
update();
|
||||
}
|
||||
|
||||
_sendOtp(int randomNumber, SmsEgyptController smsEgyptController) async {
|
||||
await CRUD().post(link: AppLink.sendVerifyOtpMessage, payload: {
|
||||
'phone_number': '+2${phoneController.text}',
|
||||
'token_code': randomNumber.toString(),
|
||||
"driverId": box.read(BoxName.driverID),
|
||||
"email": box.read(BoxName.emailDriver),
|
||||
});
|
||||
|
||||
await smsEgyptController.sendSmsEgypt(
|
||||
phoneController.text.toString(), randomNumber.toString());
|
||||
|
||||
// Save the current time as the last OTP time
|
||||
box.write(BoxName.lastOtpTime, DateTime.now());
|
||||
|
||||
isSent = true;
|
||||
isLoading = false;
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -551,80 +551,8 @@ class FirebaseMessagesController extends GetxController {
|
||||
// }
|
||||
//android/app/src/main/res/raw/iphone_ringtone.wav
|
||||
void sendNotificationToPassengerToken(
|
||||
String title, body, token, List<String> map, String tone) async {
|
||||
try {
|
||||
String serviceAccountKeyJson = '''{
|
||||
"type": "service_account",
|
||||
"project_id": "ride-b1bd8",
|
||||
"private_key_id": "75e817c0b902db2ef35edf2c2bd159dec1f13249",
|
||||
"private_key": "-----BEGIN PRIVATE KEY-----\\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQD0zH9TQGDQHUv3\\na3/JAD1UKPwAp3wNKT0a6fxiIzjI3JxQWI30QvZCcfl6CdMhIcydX1ncSaYTcEeC\\n/AdPVCPkqyJx1YIGGg6P/mRzCWeaN8fsp6z250m5vcObDCZc3dbJEkepbep+6FPY\\n21m3KO+AHh1glgsTGZOTm5xiU8NGXpdk2QEh8wpiIIlR/HuKwVw9g8urNe3Sno+U\\nDm3z37iFqvZdmpqO8aWTJu6beb3hsREK9XK2I9JqC2JUwiGQRo3idOvPP6hkqrWx\\nKSX96vglQFYfakvJdDp2ZATOlpBYPMtS/IWhJ985u58TSS+Kl8qpnpaZBSxgJirf\\nhWzhnKLfAgMBAAECggEAJP785SePGhS7ZN6ltspm+l+hSjYFrPWFCxq+rlQ1YkHZ\\nC9l+RqKSFhOkiPmQI2s4wbXl3kFxLHHlFNoi/q2wKQBmGb8TQfnRJpjjNHGA61Ev\\n0Ue7/6qPvVb9B2MsLw/FxKiTFPuMG3bgKR9pbSFuJLYoaW7zqITOhVnYphGTqwAY\\nBVVcvISSLvELDmH9VZcv/9DVqVlqbbESHWh1Z4W6XGPoEqeDH/upNTyQQ/46Msgm\\nTGE6VqLHpWuSf6SqHp+r0Y0lI3vIPM1vz5FAJDJbOE/enHa0fSup0OHSMxl0HVMn\\nnO1yrGF3vsIPOej5HKr5d71bEIckzk73/yjNC1/mDQKBgQD7RtUvc9omsSsFMJ6e\\nBASAn6Dktx/QY/XNJjFzHQj69cywLDe5t5AL2gUi3phQ2oqB5XJdwnd5bTIEPEPZ\\nDOuOai2802p6FJk6kjmZAMVGx5JtXBH+vs6jrmQQSMiKbjwN1TT6xIWakvLOonUi\\nX6ZvjYYjU/E0YJU3jSiXWEr76wKBgQD5Zn4SouJ6BCDZMbausJVMBkk3qxsYooip\\np89WakC6e7AZinpkRcqjGGV9GOvc8crJs6fyXAA9ORepGP47Mc0ZrDssOkstznsM\\npr8R0S6MKwEZaT9ixOHdOcLZ47ps+JzA2Wr4KN2OvFHksUkB/46ATD1j9WZVgB8M\\namsYp/Y73QKBgHOo+PvsoZ9psVmkNX6abtAdqdtdB0HOoRea2uwXk0ig12TIFaZg\\nfedWpUKVnxqoXVTJHklV99RmlL0qWDiSH+LfsMnXro0e6iDxqZ1po2Se/CFmXcoa\\nXdctsFVmixhdATuExewfhTfPKABA+xWlXWC/jdy5CK+JPWXijaqMM4edAoGAE5Bj\\nsWiPpYyvWvpYX0nA3G7dzX0hqgQN/mkIjbnWDArp3IcNZNJIvBSM2Yxb7EAXbU0n\\njo6DAkp5Pa2VO+WDNlFZbvW/sf8xjeOCt44WPa6d7nVgIIpbQXRngZoopKW3/jTP\\n/FmQT8McFXmGxZ5belsAsdetSGW9icbLUerTGQ0CgYEAmf/G8Ag3XxmqTXvvHuv2\\n14OP7WnrVqkEMnydrftEwn4peXd/Lz+/GYX5Zc4ZoNgbN8IvZ5z0+OmRsallsbiW\\nBw0/tc68CjzxXOvReWxDluUopqWVGj5tlGqE5xUDku9SWJSxbkiQ3rqutzBdPXpr\\noqHwPyDrmK/Zgqn+uiIm4Ck=\\n-----END PRIVATE KEY-----\\n",
|
||||
"client_email": "firebase-adminsdk-o2wqi@ride-b1bd8.iam.gserviceaccount.com",
|
||||
"client_id": "111210077025005706623",
|
||||
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
||||
"token_uri": "https://oauth2.googleapis.com/token",
|
||||
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
||||
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-o2wqi%40ride-b1bd8.iam.gserviceaccount.com",
|
||||
"universe_domain": "googleapis.com"
|
||||
}
|
||||
'''; // As defined above
|
||||
|
||||
// Initialize AccessTokenManager
|
||||
final accessTokenManager = AccessTokenManager(serviceAccountKeyJson);
|
||||
|
||||
// Obtain an OAuth 2.0 access token
|
||||
final accessToken = await accessTokenManager.getAccessToken();
|
||||
|
||||
// Send the notification
|
||||
final response = await http.post(
|
||||
Uri.parse(
|
||||
'https://fcm.googleapis.com/v1/projects/ride-b1bd8/messages:send'),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer $accessToken',
|
||||
},
|
||||
body: jsonEncode({
|
||||
'message': {
|
||||
'token': token,
|
||||
'notification': {
|
||||
'title': title,
|
||||
'body': body,
|
||||
},
|
||||
'data': {
|
||||
'passengerList': map,
|
||||
},
|
||||
'android': {
|
||||
'priority': 'high', // Set priority to high
|
||||
'notification': {
|
||||
'sound': tone,
|
||||
},
|
||||
},
|
||||
'apns': {
|
||||
'headers': {
|
||||
'apns-priority': '10', // Set APNs priority to 10
|
||||
},
|
||||
'payload': {
|
||||
'aps': {
|
||||
'sound': tone,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
// Notification sent successfully
|
||||
} else {
|
||||
// Handle error response
|
||||
'Failed to send notification. Status code: ${response.statusCode}';
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle other exceptions
|
||||
}
|
||||
}
|
||||
|
||||
void sendNotificationToPassengerTokenCALL(
|
||||
String title, body, token, List<String> map, String tone) async {
|
||||
String title, body, token, List<String> map, String tone,
|
||||
{int retryCount = 2}) async {
|
||||
try {
|
||||
String serviceAccountKeyJson = '''{
|
||||
"type": "service_account",
|
||||
@@ -692,15 +620,31 @@ class FirebaseMessagesController extends GetxController {
|
||||
} else {
|
||||
print(
|
||||
'Failed to send notification. Status code: ${response.statusCode}');
|
||||
|
||||
print('Response body: ${response.body}');
|
||||
if (retryCount > 0) {
|
||||
print('Retrying... Attempts remaining: $retryCount');
|
||||
await Future.delayed(
|
||||
const Duration(seconds: 2)); // Optional delay before retrying
|
||||
return sendNotificationToPassengerToken(title, body, token, map, tone,
|
||||
retryCount: retryCount - 1);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error sending notification: $e');
|
||||
if (retryCount > 0) {
|
||||
print('Retrying... Attempts remaining: $retryCount');
|
||||
await Future.delayed(
|
||||
const Duration(seconds: 2)); // Optional delay before retrying
|
||||
return sendNotificationToPassengerToken(title, body, token, map, tone,
|
||||
retryCount: retryCount - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sendNotificationToAnyWithoutData(
|
||||
String title, String body, String token, String tone) async {
|
||||
void sendNotificationToPassengerTokenCALL(
|
||||
String title, body, token, List<String> map, String tone,
|
||||
{int retryCount = 2}) async {
|
||||
try {
|
||||
String serviceAccountKeyJson = '''{
|
||||
"type": "service_account",
|
||||
@@ -739,7 +683,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
'body': body,
|
||||
},
|
||||
'data': {
|
||||
'DriverList': jsonEncode([]),
|
||||
'passengerList': jsonEncode(map),
|
||||
},
|
||||
'android': {
|
||||
'priority': 'high', // Set priority to high
|
||||
@@ -768,15 +712,125 @@ class FirebaseMessagesController extends GetxController {
|
||||
} else {
|
||||
print(
|
||||
'Failed to send notification. Status code: ${response.statusCode}');
|
||||
|
||||
print('Response body: ${response.body}');
|
||||
if (retryCount > 0) {
|
||||
print('Retrying... Attempts remaining: $retryCount');
|
||||
await Future.delayed(
|
||||
const Duration(seconds: 2)); // Optional delay before retrying
|
||||
return sendNotificationToPassengerTokenCALL(
|
||||
title, body, token, map, tone,
|
||||
retryCount: retryCount - 1);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error sending notification: $e');
|
||||
if (retryCount > 0) {
|
||||
print('Retrying... Attempts remaining: $retryCount');
|
||||
await Future.delayed(
|
||||
const Duration(seconds: 2)); // Optional delay before retrying
|
||||
return sendNotificationToPassengerTokenCALL(
|
||||
title, body, token, map, tone,
|
||||
retryCount: retryCount - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sendNotificationToDriverMAP(String title, String body, String token,
|
||||
List<String> data, String tone) async {
|
||||
void sendNotificationToAnyWithoutData(
|
||||
String title, String body, String token, String tone,
|
||||
{int retryCount = 2}) async {
|
||||
try {
|
||||
String serviceAccountKeyJson = '''{
|
||||
"type": "service_account",
|
||||
"project_id": "ride-b1bd8",
|
||||
"private_key_id": "75e817c0b902db2ef35edf2c2bd159dec1f13249",
|
||||
"private_key": "-----BEGIN PRIVATE KEY-----\\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQD0zH9TQGDQHUv3\\na3/JAD1UKPwAp3wNKT0a6fxiIzjI3JxQWI30QvZCcfl6CdMhIcydX1ncSaYTcEeC\\n/AdPVCPkqyJx1YIGGg6P/mRzCWeaN8fsp6z250m5vcObDCZc3dbJEkepbep+6FPY\\n21m3KO+AHh1glgsTGZOTm5xiU8NGXpdk2QEh8wpiIIlR/HuKwVw9g8urNe3Sno+U\\nDm3z37iFqvZdmpqO8aWTJu6beb3hsREK9XK2I9JqC2JUwiGQRo3idOvPP6hkqrWx\\nKSX96vglQFYfakvJdDp2ZATOlpBYPMtS/IWhJ985u58TSS+Kl8qpnpaZBSxgJirf\\nhWzhnKLfAgMBAAECggEAJP785SePGhS7ZN6ltspm+l+hSjYFrPWFCxq+rlQ1YkHZ\\nC9l+RqKSFhOkiPmQI2s4wbXl3kFxLHHlFNoi/q2wKQBmGb8TQfnRJpjjNHGA61Ev\\n0Ue7/6qPvVb9B2MsLw/FxKiTFPuMG3bgKR9pbSFuJLYoaW7zqITOhVnYphGTqwAY\\nBVVcvISSLvELDmH9VZcv/9DVqVlqbbESHWh1Z4W6XGPoEqeDH/upNTyQQ/46Msgm\\nTGE6VqLHpWuSf6SqHp+r0Y0lI3vIPM1vz5FAJDJbOE/enHa0fSup0OHSMxl0HVMn\\nnO1yrGF3vsIPOej5HKr5d71bEIckzk73/yjNC1/mDQKBgQD7RtUvc9omsSsFMJ6e\\nBASAn6Dktx/QY/XNJjFzHQj69cywLDe5t5AL2gUi3phQ2oqB5XJdwnd5bTIEPEPZ\\nDOuOai2802p6FJk6kjmZAMVGx5JtXBH+vs6jrmQQSMiKbjwN1TT6xIWakvLOonUi\\nX6ZvjYYjU/E0YJU3jSiXWEr76wKBgQD5Zn4SouJ6BCDZMbausJVMBkk3qxsYooip\\np89WakC6e7AZinpkRcqjGGV9GOvc8crJs6fyXAA9ORepGP47Mc0ZrDssOkstznsM\\npr8R0S6MKwEZaT9ixOHdOcLZ47ps+JzA2Wr4KN2OvFHksUkB/46ATD1j9WZVgB8M\\namsYp/Y73QKBgHOo+PvsoZ9psVmkNX6abtAdqdtdB0HOoRea2uwXk0ig12TIFaZg\\nfedWpUKVnxqoXVTJHklV99RmlL0qWDiSH+LfsMnXro0e6iDxqZ1po2Se/CFmXcoa\\nXdctsFVmixhdATuExewfhTfPKABA+xWlXWC/jdy5CK+JPWXijaqMM4edAoGAE5Bj\\nsWiPpYyvWvpYX0nA3G7dzX0hqgQN/mkIjbnWDArp3IcNZNJIvBSM2Yxb7EAXbU0n\\njo6DAkp5Pa2VO+WDNlFZbvW/sf8xjeOCt44WPa6d7nVgIIpbQXRngZoopKW3/jTP\\n/FmQT8McFXmGxZ5belsAsdetSGW9icbLUerTGQ0CgYEAmf/G8Ag3XxmqTXvvHuv2\\n14OP7WnrVqkEMnydrftEwn4peXd/Lz+/GYX5Zc4ZoNgbN8IvZ5z0+OmRsallsbiW\\nBw0/tc68CjzxXOvReWxDluUopqWVGj5tlGqE5xUDku9SWJSxbkiQ3rqutzBdPXpr\\noqHwPyDrmK/Zgqn+uiIm4Ck=\\n-----END PRIVATE KEY-----\\n",
|
||||
"client_email": "firebase-adminsdk-o2wqi@ride-b1bd8.iam.gserviceaccount.com",
|
||||
"client_id": "111210077025005706623",
|
||||
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
||||
"token_uri": "https://oauth2.googleapis.com/token",
|
||||
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
||||
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-o2wqi%40ride-b1bd8.iam.gserviceaccount.com",
|
||||
"universe_domain": "googleapis.com"
|
||||
}
|
||||
'''; // As defined above
|
||||
|
||||
// Initialize AccessTokenManager
|
||||
final accessTokenManager = AccessTokenManager(serviceAccountKeyJson);
|
||||
|
||||
// Obtain an OAuth 2.0 access token
|
||||
final accessToken = await accessTokenManager.getAccessToken();
|
||||
|
||||
// Send the notification
|
||||
final response = await http.post(
|
||||
Uri.parse(
|
||||
'https://fcm.googleapis.com/v1/projects/ride-b1bd8/messages:send'),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer $accessToken',
|
||||
},
|
||||
body: jsonEncode({
|
||||
'message': {
|
||||
'token': token,
|
||||
'notification': {
|
||||
'title': title,
|
||||
'body': body,
|
||||
},
|
||||
// 'data': {
|
||||
// 'DriverList': jsonEncode([]),
|
||||
// },
|
||||
'android': {
|
||||
'priority': 'high', // Set priority to high
|
||||
'notification': {
|
||||
'sound': tone,
|
||||
},
|
||||
},
|
||||
'apns': {
|
||||
'headers': {
|
||||
'apns-priority': '10', // Set APNs priority to 10
|
||||
},
|
||||
'payload': {
|
||||
'aps': {
|
||||
'sound': tone,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
print(
|
||||
'Notification sent successfully. Status code: ${response.statusCode}');
|
||||
print('Response body: ${response.body}');
|
||||
} else {
|
||||
print(
|
||||
'Failed to send notification. Status code: ${response.statusCode}');
|
||||
|
||||
print('Response body: ${response.body}');
|
||||
if (retryCount > 0) {
|
||||
print('Retrying... Attempts remaining: $retryCount');
|
||||
await Future.delayed(
|
||||
const Duration(seconds: 2)); // Optional delay before retrying
|
||||
return sendNotificationToAnyWithoutData(title, body, token, tone,
|
||||
retryCount: retryCount - 1);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error sending notification: $e');
|
||||
if (retryCount > 0) {
|
||||
print('Retrying... Attempts remaining: $retryCount');
|
||||
await Future.delayed(
|
||||
const Duration(seconds: 2)); // Optional delay before retrying
|
||||
return sendNotificationToAnyWithoutData(title, body, token, tone,
|
||||
retryCount: retryCount - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sendNotificationToDriverMAP(
|
||||
String title, String body, String token, List<String> data, String tone,
|
||||
{int retryCount = 2}) async {
|
||||
try {
|
||||
String serviceAccountKeyJson = '''{
|
||||
"type": "service_account",
|
||||
@@ -844,10 +898,27 @@ class FirebaseMessagesController extends GetxController {
|
||||
} else {
|
||||
print(
|
||||
'Failed to send notification. Status code: ${response.statusCode}');
|
||||
|
||||
print('Response body: ${response.body}');
|
||||
if (retryCount > 0) {
|
||||
print('Retrying... Attempts remaining: $retryCount');
|
||||
await Future.delayed(
|
||||
const Duration(seconds: 2)); // Optional delay before retrying
|
||||
return sendNotificationToPassengerTokenCALL(
|
||||
title, body, token, data, tone,
|
||||
retryCount: retryCount - 1);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error sending notification: $e');
|
||||
if (retryCount > 0) {
|
||||
print('Retrying... Attempts remaining: $retryCount');
|
||||
await Future.delayed(
|
||||
const Duration(seconds: 2)); // Optional delay before retrying
|
||||
return sendNotificationToPassengerTokenCALL(
|
||||
title, body, token, data, tone,
|
||||
retryCount: retryCount - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -935,19 +1006,19 @@ class OverlayContent extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
|
||||
style: const TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
|
||||
),
|
||||
SizedBox(height: 8.0),
|
||||
const SizedBox(height: 8.0),
|
||||
Text(
|
||||
body,
|
||||
style: TextStyle(fontSize: 16),
|
||||
style: const TextStyle(fontSize: 16),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:SEFER/constant/colors.dart';
|
||||
import 'package:SEFER/views/home/Captin/orderCaptin/order_request_page.dart';
|
||||
@@ -31,11 +32,10 @@ class NotificationController extends GetxController {
|
||||
|
||||
// Create a notification channel
|
||||
const AndroidNotificationChannel channel = AndroidNotificationChannel(
|
||||
'dynamic_channel', // Channel ID
|
||||
'Dynamic Notifications', // Channel name
|
||||
description:
|
||||
'This channel is used for various types of notifications.', // Channel description
|
||||
importance: Importance.max,
|
||||
'high_importance_channel',
|
||||
'High Importance Notifications',
|
||||
description: 'This channel is used for important notifications.',
|
||||
importance: Importance.high,
|
||||
);
|
||||
|
||||
// Register the channel with the system
|
||||
@@ -55,31 +55,36 @@ class NotificationController extends GetxController {
|
||||
htmlFormatContentTitle: true,
|
||||
);
|
||||
|
||||
AndroidNotificationDetails android =
|
||||
AndroidNotificationDetails('dynamic_channel', 'Dynamic Notifications',
|
||||
importance: Importance.max,
|
||||
priority: Priority.high,
|
||||
styleInformation: bigTextStyleInformation,
|
||||
playSound: true,
|
||||
sound: RawResourceAndroidNotificationSound(tone),
|
||||
audioAttributesUsage: AudioAttributesUsage.alarm,
|
||||
visibility: NotificationVisibility.public,
|
||||
autoCancel: false,
|
||||
color: AppColor.primaryColor,
|
||||
showProgress: true,
|
||||
showWhen: true,
|
||||
timeoutAfter: title == 'Order' ? 14500 : 6000,
|
||||
subText: message,
|
||||
actions: [
|
||||
AndroidNotificationAction(
|
||||
allowGeneratedReplies: true,
|
||||
'id',
|
||||
title.tr,
|
||||
titleColor: AppColor.bronze,
|
||||
showsUserInterface: true,
|
||||
)
|
||||
],
|
||||
category: AndroidNotificationCategory.call);
|
||||
AndroidNotificationDetails android = AndroidNotificationDetails(
|
||||
'high_importance_channel', 'High Importance Notifications',
|
||||
importance: Importance.high,
|
||||
priority: Priority.high,
|
||||
styleInformation: bigTextStyleInformation,
|
||||
playSound: true,
|
||||
sound: RawResourceAndroidNotificationSound(tone),
|
||||
// audioAttributesUsage: AudioAttributesUsage.alarm,
|
||||
visibility: NotificationVisibility.public,
|
||||
autoCancel: false,
|
||||
color: AppColor.primaryColor,
|
||||
showProgress: true,
|
||||
showWhen: true,
|
||||
ongoing: true,
|
||||
enableVibration: true,
|
||||
vibrationPattern: Int64List.fromList([0, 1000, 500, 1000]),
|
||||
timeoutAfter: 14500,
|
||||
setAsGroupSummary: true,
|
||||
subText: message, fullScreenIntent: true,
|
||||
actions: [
|
||||
AndroidNotificationAction(
|
||||
allowGeneratedReplies: true,
|
||||
'id',
|
||||
title.tr,
|
||||
titleColor: AppColor.bronze,
|
||||
showsUserInterface: true,
|
||||
)
|
||||
],
|
||||
category: AndroidNotificationCategory.progress,
|
||||
);
|
||||
|
||||
NotificationDetails details = NotificationDetails(android: android);
|
||||
|
||||
@@ -175,30 +180,30 @@ class NotificationController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
// class NotificationController extends GetxController {
|
||||
// final FlutterLocalNotificationsPlugin _flutterLocalNotificationsPlugin =
|
||||
// FlutterLocalNotificationsPlugin();
|
||||
class NotificationController1 extends GetxController {
|
||||
final FlutterLocalNotificationsPlugin _flutterLocalNotificationsPlugin =
|
||||
FlutterLocalNotificationsPlugin();
|
||||
|
||||
// // Initializes the local notifications plugin
|
||||
// Future<void> initNotifications() async {
|
||||
// const AndroidInitializationSettings android =
|
||||
// AndroidInitializationSettings('@mipmap/launcher_icon');
|
||||
// const InitializationSettings initializationSettings =
|
||||
// InitializationSettings(android: android);
|
||||
// await _flutterLocalNotificationsPlugin.initialize(initializationSettings);
|
||||
// }
|
||||
// Initializes the local notifications plugin
|
||||
Future<void> initNotifications() async {
|
||||
const AndroidInitializationSettings android =
|
||||
AndroidInitializationSettings('@mipmap/launcher_icon');
|
||||
const InitializationSettings initializationSettings =
|
||||
InitializationSettings(android: android);
|
||||
await _flutterLocalNotificationsPlugin.initialize(initializationSettings);
|
||||
}
|
||||
|
||||
// // Displays a notification with the given title and message
|
||||
// void showNotification(
|
||||
// String title, String message, String tone, String payLoad) async {
|
||||
// AndroidNotificationDetails android = AndroidNotificationDetails(
|
||||
// 'your channel id', 'your channel name',
|
||||
// importance: Importance.max,
|
||||
// priority: Priority.high,
|
||||
// showWhen: false,
|
||||
// sound: RawResourceAndroidNotificationSound(tone));
|
||||
// Displays a notification with the given title and message
|
||||
void showNotification(
|
||||
String title, String message, String tone, String payLoad) async {
|
||||
AndroidNotificationDetails android = AndroidNotificationDetails(
|
||||
'your channel id', 'your channel name',
|
||||
importance: Importance.max,
|
||||
priority: Priority.high,
|
||||
showWhen: false,
|
||||
sound: RawResourceAndroidNotificationSound(tone));
|
||||
|
||||
// NotificationDetails details = NotificationDetails(android: android);
|
||||
// await _flutterLocalNotificationsPlugin.show(0, title, message, details);
|
||||
// }
|
||||
// }
|
||||
NotificationDetails details = NotificationDetails(android: android);
|
||||
await _flutterLocalNotificationsPlugin.show(0, title, message, details);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,12 +355,12 @@ class AI extends GetxController {
|
||||
|
||||
if (status1['status'] == 'success') {
|
||||
isDriverSaved = true;
|
||||
// CRUD().post(
|
||||
// link: '${AppLink.seferGizaServer}/auth/captin/register.php',
|
||||
// payload: payload);
|
||||
// CRUD().post(
|
||||
// link: '${AppLink.seferAlexandriaServer}/auth/captin/register.php',
|
||||
// payload: payload);
|
||||
CRUD().post(
|
||||
link: '${AppLink.seferGizaServer}/auth/captin/register.php',
|
||||
payload: payload);
|
||||
CRUD().post(
|
||||
link: '${AppLink.seferAlexandriaServer}/auth/captin/register.php',
|
||||
payload: payload);
|
||||
Get.snackbar('Success', 'Driver data saved successfully',
|
||||
backgroundColor: AppColor.greenColor);
|
||||
} else {
|
||||
@@ -416,55 +416,55 @@ class AI extends GetxController {
|
||||
isCarSaved = true;
|
||||
Get.snackbar('Success', 'message',
|
||||
backgroundColor: AppColor.greenColor);
|
||||
// CRUD().post(
|
||||
// link:
|
||||
// '${AppLink.seferAlexandriaServer}/ride/RegisrationCar/add.php',
|
||||
// payload: {
|
||||
// 'driverID': box.read(BoxName.driverID),
|
||||
// 'vin': responseIdCardDriverEgyptBack['chassis'].toString(),
|
||||
// 'car_plate':
|
||||
// responseIdCardDriverEgyptFront['car_plate'].toString(),
|
||||
// 'make': responseIdCardDriverEgyptBack['make'].toString(),
|
||||
// 'model': responseIdCardDriverEgyptBack['model'],
|
||||
// 'year': responseIdCardDriverEgyptBack['year'].toString(),
|
||||
// 'expiration_date':
|
||||
// responseIdCardDriverEgyptFront['LicenseExpirationDate']
|
||||
// .toString(),
|
||||
// 'color': responseIdCardDriverEgyptBack['color'],
|
||||
// 'owner': responseIdCardDriverEgyptFront['owner'],
|
||||
// 'color_hex':
|
||||
// responseIdCardDriverEgyptBack['color_hex'].toString(),
|
||||
// 'address': responseIdCardDriverEgyptFront['address'].toString(),
|
||||
// 'displacement':
|
||||
// responseIdCardDriverEgyptBack['engine'].toString(),
|
||||
// 'fuel': responseIdCardDriverEgyptBack['fuel'].toString(),
|
||||
// 'registration_date':
|
||||
// '${responseIdCardDriverEgyptBack['inspection_date']}',
|
||||
// });
|
||||
// CRUD().post(
|
||||
// link: '${AppLink.seferGizaServer}/ride/RegisrationCar/add.php',
|
||||
// payload: {
|
||||
// 'driverID': box.read(BoxName.driverID),
|
||||
// 'vin': responseIdCardDriverEgyptBack['chassis'].toString(),
|
||||
// 'car_plate':
|
||||
// responseIdCardDriverEgyptFront['car_plate'].toString(),
|
||||
// 'make': responseIdCardDriverEgyptBack['make'].toString(),
|
||||
// 'model': responseIdCardDriverEgyptBack['model'],
|
||||
// 'year': responseIdCardDriverEgyptBack['year'].toString(),
|
||||
// 'expiration_date':
|
||||
// responseIdCardDriverEgyptFront['LicenseExpirationDate']
|
||||
// .toString(),
|
||||
// 'color': responseIdCardDriverEgyptBack['color'],
|
||||
// 'owner': responseIdCardDriverEgyptFront['owner'],
|
||||
// 'color_hex':
|
||||
// responseIdCardDriverEgyptBack['color_hex'].toString(),
|
||||
// 'address': responseIdCardDriverEgyptFront['address'].toString(),
|
||||
// 'displacement':
|
||||
// responseIdCardDriverEgyptBack['engine'].toString(),
|
||||
// 'fuel': responseIdCardDriverEgyptBack['fuel'].toString(),
|
||||
// 'registration_date':
|
||||
// '${responseIdCardDriverEgyptBack['inspection_date']}',
|
||||
// });
|
||||
CRUD().post(
|
||||
link:
|
||||
'${AppLink.seferAlexandriaServer}/ride/RegisrationCar/add.php',
|
||||
payload: {
|
||||
'driverID': box.read(BoxName.driverID),
|
||||
'vin': responseIdCardDriverEgyptBack['chassis'].toString(),
|
||||
'car_plate':
|
||||
responseIdCardDriverEgyptFront['car_plate'].toString(),
|
||||
'make': responseIdCardDriverEgyptBack['make'].toString(),
|
||||
'model': responseIdCardDriverEgyptBack['model'],
|
||||
'year': responseIdCardDriverEgyptBack['year'].toString(),
|
||||
'expiration_date':
|
||||
responseIdCardDriverEgyptFront['LicenseExpirationDate']
|
||||
.toString(),
|
||||
'color': responseIdCardDriverEgyptBack['color'],
|
||||
'owner': responseIdCardDriverEgyptFront['owner'],
|
||||
'color_hex':
|
||||
responseIdCardDriverEgyptBack['color_hex'].toString(),
|
||||
'address': responseIdCardDriverEgyptFront['address'].toString(),
|
||||
'displacement':
|
||||
responseIdCardDriverEgyptBack['engine'].toString(),
|
||||
'fuel': responseIdCardDriverEgyptBack['fuel'].toString(),
|
||||
'registration_date':
|
||||
'${responseIdCardDriverEgyptBack['inspection_date']}',
|
||||
});
|
||||
CRUD().post(
|
||||
link: '${AppLink.seferGizaServer}/ride/RegisrationCar/add.php',
|
||||
payload: {
|
||||
'driverID': box.read(BoxName.driverID),
|
||||
'vin': responseIdCardDriverEgyptBack['chassis'].toString(),
|
||||
'car_plate':
|
||||
responseIdCardDriverEgyptFront['car_plate'].toString(),
|
||||
'make': responseIdCardDriverEgyptBack['make'].toString(),
|
||||
'model': responseIdCardDriverEgyptBack['model'],
|
||||
'year': responseIdCardDriverEgyptBack['year'].toString(),
|
||||
'expiration_date':
|
||||
responseIdCardDriverEgyptFront['LicenseExpirationDate']
|
||||
.toString(),
|
||||
'color': responseIdCardDriverEgyptBack['color'],
|
||||
'owner': responseIdCardDriverEgyptFront['owner'],
|
||||
'color_hex':
|
||||
responseIdCardDriverEgyptBack['color_hex'].toString(),
|
||||
'address': responseIdCardDriverEgyptFront['address'].toString(),
|
||||
'displacement':
|
||||
responseIdCardDriverEgyptBack['engine'].toString(),
|
||||
'fuel': responseIdCardDriverEgyptBack['fuel'].toString(),
|
||||
'registration_date':
|
||||
'${responseIdCardDriverEgyptBack['inspection_date']}',
|
||||
});
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
@@ -8,19 +8,13 @@ class LocationBackgroundController extends GetxController {
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
requestLocationPermission();
|
||||
configureBackgroundLocation();
|
||||
}
|
||||
|
||||
Future<void> requestLocationPermission() async {
|
||||
var status = await Permission.locationAlways.status;
|
||||
if (!status.isGranted) {
|
||||
status = await Permission.locationAlways.request();
|
||||
}
|
||||
|
||||
if (status.isGranted) {
|
||||
configureBackgroundLocation();
|
||||
} else {
|
||||
// Handle permission denial
|
||||
print("Location permission denied");
|
||||
await Permission.locationAlways.request();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,36 +25,29 @@ class LocationBackgroundController extends GetxController {
|
||||
icon: '@mipmap/launcher_icon',
|
||||
);
|
||||
|
||||
// Set the location update interval to 5 seconds
|
||||
BackgroundLocation.setAndroidConfiguration(5000);
|
||||
BackgroundLocation.setAndroidConfiguration(3000);
|
||||
BackgroundLocation.startLocationService();
|
||||
|
||||
BackgroundLocation.getLocationUpdates((location) {
|
||||
// Handle location updates here
|
||||
print("Latitude: ${location.latitude}, Longitude: ${location.longitude}");
|
||||
});
|
||||
|
||||
startBackLocation();
|
||||
}
|
||||
|
||||
void startBackLocation() async {
|
||||
Timer.periodic(const Duration(seconds: 5), (timer) async {
|
||||
await getBackgroundLocation();
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> getBackgroundLocation() async {
|
||||
startBackLocation() async {
|
||||
Timer.periodic(const Duration(seconds: 3), (timer) {
|
||||
getBackgroundLocation();
|
||||
});
|
||||
}
|
||||
|
||||
getBackgroundLocation() async {
|
||||
var status = await Permission.locationAlways.status;
|
||||
if (status.isGranted) {
|
||||
// The location service is already started in configureBackgroundLocation
|
||||
// No need to call startLocationService again
|
||||
BackgroundLocation.getLocationUpdates((location) {
|
||||
// Handle location updates here
|
||||
print(
|
||||
"Latitude: ${location.latitude}, Longitude: ${location.longitude}");
|
||||
});
|
||||
await BackgroundLocation.startLocationService(
|
||||
distanceFilter: 20, forceAndroidLocationManager: true);
|
||||
BackgroundLocation.setAndroidConfiguration(
|
||||
Duration.microsecondsPerSecond); // Set interval to 5 seconds
|
||||
|
||||
BackgroundLocation.getLocationUpdates((location1) {});
|
||||
} else {
|
||||
// Request permission if not granted
|
||||
await Permission.locationAlways.request();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ class LocationController extends GetxController {
|
||||
} else if (latitude >= 29.904975 &&
|
||||
latitude <= 30.143372 &&
|
||||
longitude >= 30.787030 &&
|
||||
longitude <= 31.238843) {
|
||||
longitude <= 31.215009) {
|
||||
return 'Giza';
|
||||
} else if (latitude >= 30.396286 &&
|
||||
latitude <= 31.654458 &&
|
||||
@@ -61,7 +61,7 @@ class LocationController extends GetxController {
|
||||
longitude <= 32.626259) {
|
||||
return 'Alexandria';
|
||||
} else {
|
||||
return 'Outside';
|
||||
return 'Cairo';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,15 +102,7 @@ class LocationController extends GetxController {
|
||||
endpoint = AppLink.addCarsLocationAlexandriaEndpoint;
|
||||
Log.print('Endpoint: $endpoint');
|
||||
break;
|
||||
case 'Outside':
|
||||
// Handle cases outside of Cairo, Giza, and Alexandria
|
||||
print('Location outside Cairo, Giza, or Alexandria');
|
||||
|
||||
box.write(BoxName.serverChosen, AppLink.seferCairoServer);
|
||||
endpoint = AppLink
|
||||
.addCarsLocationCairoEndpoint; // Fallback to Cairo endpoint
|
||||
Log.print('Fallback Endpoint: $endpoint');
|
||||
break;
|
||||
default:
|
||||
// Handle any other unexpected cases
|
||||
print('Unknown location area');
|
||||
|
||||
@@ -1,16 +1,60 @@
|
||||
import 'package:location/location.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
import '../../constant/box_name.dart';
|
||||
import '../../main.dart';
|
||||
import '../../print.dart';
|
||||
import '../../views/widgets/mydialoug.dart';
|
||||
import '../auth/captin/login_captin_controller.dart';
|
||||
|
||||
class LocationPermissions {
|
||||
late Location location;
|
||||
// late Location location;
|
||||
|
||||
Future locationPermissions() async {
|
||||
location = Location();
|
||||
var permissionStatus = await location.requestPermission();
|
||||
if (permissionStatus == PermissionStatus.denied) {
|
||||
// The user denied the location permission.
|
||||
Get.defaultDialog(title: 'GPS Required Allow !.'.tr, middleText: '');
|
||||
return null;
|
||||
}
|
||||
// Future locationPermissions() async {
|
||||
// location = Location();
|
||||
// var permissionStatus = await location.requestPermission();
|
||||
// if (permissionStatus == PermissionStatus.denied) {
|
||||
// // The user denied the location permission.
|
||||
// Get.defaultDialog(title: 'GPS Required Allow !.'.tr, middleText: '');
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
Future<void> getPermissionLocation() async {
|
||||
final PermissionStatus status = await Permission.locationAlways.status;
|
||||
if (!await Permission.locationAlways.serviceStatus.isEnabled) {
|
||||
Log.print('status.isGranted: ${status.isGranted}');
|
||||
// box.write(BoxName.locationPermission, 'true');
|
||||
await Permission.locationAlways.request();
|
||||
Get.put(LoginDriverController()).update();
|
||||
MyDialog().getDialog(
|
||||
'Enable Location Permission'.tr, // {en:ar}
|
||||
'Allowing location access will help us display orders near you. Please enable it now.'
|
||||
.tr, // {en:ar}
|
||||
() async {
|
||||
Get.back();
|
||||
box.write(BoxName.locationPermission, 'true');
|
||||
await Permission.locationAlways.request();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> getPermissionLocation1() async {
|
||||
PermissionStatus status = await Permission.locationWhenInUse.request();
|
||||
|
||||
if (status.isGranted) {
|
||||
// After granting when in use, request "always" location permission
|
||||
status = await Permission.locationAlways.request();
|
||||
|
||||
if (status.isGranted) {
|
||||
print("Background location permission granted");
|
||||
} else {
|
||||
print("Background location permission denied");
|
||||
}
|
||||
} else {
|
||||
print("Location permission denied");
|
||||
await openAppSettings();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,12 @@ import 'dart:io';
|
||||
import 'package:SEFER/views/widgets/mydialoug.dart';
|
||||
import 'package:flutter_overlay_window/flutter_overlay_window.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:location/location.dart';
|
||||
// import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
import '../../constant/box_name.dart';
|
||||
import '../../main.dart';
|
||||
import '../../print.dart';
|
||||
import '../auth/captin/login_captin_controller.dart';
|
||||
|
||||
Future<void> getPermissionOverlay() async {
|
||||
@@ -26,24 +28,55 @@ Future<void> getPermissionOverlay() async {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> getPermissionLocation() async {
|
||||
final PermissionStatus status = await Permission.location.status;
|
||||
if (!status.isGranted) {
|
||||
// Log.print('status.isGranted: ${status.isGranted}');
|
||||
box.write(BoxName.locationPermission, 'true');
|
||||
await Permission.location.request();
|
||||
Get.find<LoginDriverController>().update();
|
||||
// MyDialog().getDialog(
|
||||
// 'Enable Location Permission'.tr, // {en:ar}
|
||||
// 'Allowing location access will help us display orders near you. Please enable it now.'
|
||||
// .tr, // {en:ar}
|
||||
// () async {
|
||||
// Get.back();
|
||||
// box.write(BoxName.locationPermission, 'true');
|
||||
// await Permission.location.request();
|
||||
// },
|
||||
// );
|
||||
// Future<void> getPermissionLocation() async {
|
||||
// // final PermissionStatus status = await Permission.location.status;
|
||||
// // if (!status.isGranted) {
|
||||
// // Log.print('status.isGranted: ${status.isGranted}');
|
||||
// // // box.write(BoxName.locationPermission, 'true');
|
||||
// // await Permission.location.request();
|
||||
// // Get.find<LoginDriverController>().update();
|
||||
// // MyDialog().getDialog(
|
||||
// // 'Enable Location Permission'.tr, // {en:ar}
|
||||
// // 'Allowing location access will help us display orders near you. Please enable it now.'
|
||||
// // .tr, // {en:ar}
|
||||
// // () async {
|
||||
// // Get.back();
|
||||
// // box.write(BoxName.locationPermission, 'true');
|
||||
// // await Permission.location.request();
|
||||
// // },
|
||||
// // );
|
||||
// // }
|
||||
// }
|
||||
final location = Location();
|
||||
Future<void> getLocationPermission() async {
|
||||
bool serviceEnabled;
|
||||
PermissionStatus permissionGranted;
|
||||
|
||||
// Check if location services are enabled
|
||||
serviceEnabled = await location.serviceEnabled();
|
||||
if (!serviceEnabled) {
|
||||
serviceEnabled = await location.requestService();
|
||||
if (!serviceEnabled) {
|
||||
// Location services are still not enabled, handle the error
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the app has permission to access location
|
||||
permissionGranted = await location.hasPermission();
|
||||
if (permissionGranted == PermissionStatus.denied) {
|
||||
permissionGranted = await location.requestPermission();
|
||||
if (permissionGranted != PermissionStatus.granted) {
|
||||
// Location permission is still not granted, handle the error
|
||||
permissionGranted = await location.requestPermission();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (permissionGranted.toString() == 'PermissionStatus.granted') {
|
||||
box.write(BoxName.locationPermission, 'true');
|
||||
Get.find<LoginDriverController>().update();
|
||||
}
|
||||
// update();
|
||||
}
|
||||
|
||||
Future<void> getOverLay(String myListString) async {
|
||||
|
||||
@@ -240,6 +240,18 @@ class HomeCaptainController extends GetxController {
|
||||
'token': box.read(BoxName.tokenDriver),
|
||||
'captain_id': box.read(BoxName.driverID).toString()
|
||||
});
|
||||
CRUD().post(
|
||||
link: "${AppLink.seferAlexandriaServer}/ride/firebase/addDriver.php",
|
||||
payload: {
|
||||
'token': box.read(BoxName.tokenDriver),
|
||||
'captain_id': box.read(BoxName.driverID).toString()
|
||||
});
|
||||
CRUD().post(
|
||||
link: "${AppLink.seferGizaServer}/ride/firebase/addDriver.php",
|
||||
payload: {
|
||||
'token': box.read(BoxName.tokenDriver),
|
||||
'captain_id': box.read(BoxName.driverID).toString()
|
||||
});
|
||||
MapDriverController().driverCallPassenger();
|
||||
// box.write(BoxName.statusDriverLocation, 'off');
|
||||
}
|
||||
|
||||
@@ -184,6 +184,20 @@ class OrderRequestController extends GetxController {
|
||||
'status': 'Refused',
|
||||
'driver_id': box.read(BoxName.driverID),
|
||||
});
|
||||
CRUD().post(
|
||||
link: '${AppLink.seferAlexandriaServer}/rides/update.php',
|
||||
payload: {
|
||||
'id': orderID,
|
||||
// 'rideTimeStart': DateTime.now().toString(),
|
||||
'status': 'Refused',
|
||||
'driver_id': box.read(BoxName.driverID),
|
||||
});
|
||||
CRUD().post(link: '${AppLink.seferGizaServer}/rides/update.php', payload: {
|
||||
'id': orderID,
|
||||
// 'rideTimeStart': DateTime.now().toString(),
|
||||
'status': 'Refused',
|
||||
'driver_id': box.read(BoxName.driverID),
|
||||
});
|
||||
|
||||
// applied = true;
|
||||
// if (box.read(BoxName.gender).toString() != 'Female') {
|
||||
@@ -229,5 +243,41 @@ class OrderRequestController extends GetxController {
|
||||
'distance': distance,
|
||||
'duration': duration,
|
||||
});
|
||||
CRUD().post(
|
||||
link:
|
||||
'${AppLink.seferAlexandriaServer}/notificationCaptain/addWaitingRide.php',
|
||||
payload: {
|
||||
'id': orderID,
|
||||
'start_location': startLocation,
|
||||
'end_location': endLocation,
|
||||
'date': date,
|
||||
'time': time,
|
||||
'price': price,
|
||||
'passenger_id': passengerId,
|
||||
'status': status,
|
||||
'carType': carType,
|
||||
'passengerRate': passengerRate,
|
||||
'price_for_passenger': priceForPassenger,
|
||||
'distance': distance,
|
||||
'duration': duration,
|
||||
});
|
||||
CRUD().post(
|
||||
link:
|
||||
'${AppLink.seferGizaServer}/notificationCaptain/addWaitingRide.php',
|
||||
payload: {
|
||||
'id': orderID,
|
||||
'start_location': startLocation,
|
||||
'end_location': endLocation,
|
||||
'date': date,
|
||||
'time': time,
|
||||
'price': price,
|
||||
'passenger_id': passengerId,
|
||||
'status': status,
|
||||
'carType': carType,
|
||||
'passengerRate': passengerRate,
|
||||
'price_for_passenger': priceForPassenger,
|
||||
'distance': distance,
|
||||
'duration': duration,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,6 +154,7 @@ class MyTranslation extends Translations {
|
||||
"لقد اخترت التأمين الصحي بنجاح.",
|
||||
"Please enter a health insurance status.":
|
||||
"يرجى إدخال حالة التأمين الصحي",
|
||||
"Sefer Driver": "سفر السائق",
|
||||
"The 3000 points equal 3000 L.E for you \nSo go and gain your money":
|
||||
"3000 نقطة تساوي 3000 جنيه لك \nلذا اذهب واحصل على أموالك",
|
||||
"Info": "معلومات",
|
||||
|
||||
@@ -127,7 +127,24 @@ class RateController extends GetxController {
|
||||
middleText: '',
|
||||
confirm: MyElevatedButton(title: 'Ok', onPressed: () => Get.back()));
|
||||
} else {
|
||||
await CRUD().post(link: AppLink.addRateToPassenger, payload: {
|
||||
await CRUD()
|
||||
.post(link: "${AppLink.seferCairoServer}/rate/add.php", payload: {
|
||||
'passenger_id': passengerId,
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
'rideId': rideId,
|
||||
'rating': selectedRateItemId.toString(),
|
||||
'comment': comment.text,
|
||||
});
|
||||
CRUD().post(
|
||||
link: "${AppLink.seferAlexandriaServer}/rate/add.php",
|
||||
payload: {
|
||||
'passenger_id': passengerId,
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
'rideId': rideId,
|
||||
'rating': selectedRateItemId.toString(),
|
||||
'comment': comment.text,
|
||||
});
|
||||
CRUD().post(link: AppLink.seferGizaServer, payload: {
|
||||
'passenger_id': passengerId,
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
'rideId': rideId,
|
||||
|
||||
Reference in New Issue
Block a user