Update: 2026-06-12 01:23:54

This commit is contained in:
Hamza-Ayed
2026-06-12 01:23:54 +03:00
parent 7049c7468c
commit ef6b52d2e3
47 changed files with 1480 additions and 1472 deletions

View File

@@ -1,6 +1,6 @@
import '../env/env.dart';
class AppLink {
import '../main.dart';
import 'box_name.dart';class AppLink {
static String seferPaymentServer =
'https://walletintaleq.intaleq.xyz/v1/main';
static final String tripzPaymentServer0 = seferPaymentServer;
@@ -11,15 +11,64 @@ class AppLink {
// static final String endPoint = box.read(BoxName.serverChosen);
// static final String server = Env.seferCairoServer;
static final String server = 'https://api.intaleq.xyz/siro_v3';
static final String endPoint = 'https://api.intaleq.xyz/siro_v3';
static final String syria = 'https://syria.intaleq.xyz/siro';
static String paymentServer = 'https://walletintaleq.intaleq.xyz/v1/main';
static String locationServer = 'https://location.intaleq.xyz/siro/ride/location';
static String locationServerSide = 'https://location.intaleq.xyz/siro/ride/location';
static String mapSaasRoute = 'https://map-saas.intaleqapp.com/api/maps/route';
static String mapSaasPlaces = 'https://map-saas.intaleqapp.com/api/geocoding/places';
static const String routeApiBaseUrl = "https://routesjo.intaleq.xyz/route/v1/driving";
static String get currentCountry => box.read('countryCode') ?? 'Jordan';
static String get server {
switch (currentCountry) {
case 'Syria': return 'https://api-syria.siromove.com/siro_v3';
case 'Egypt': return 'https://api-egypt.siromove.com/siro_v3';
case 'Jordan': return 'https://api-jordan.siromove.com/siro_v3';
default: return 'https://api.siromove.com/siro_v3';
}
}
static String get endPoint => server;
static String get syria => 'https://api-syria.siromove.com/siro';
static String get paymentServer {
switch (currentCountry) {
case 'Syria': return 'https://wallet-syria.siromove.com/v1/main';
case 'Egypt': return 'https://wallet-egypt.siromove.com/v1/main';
case 'Jordan': return 'https://wallet-jordan.siromove.com/v1/main';
default: return 'https://wallet.siromove.com/v1/main';
}
}
static String get locationServer {
switch (currentCountry) {
case 'Syria': return 'https://location-syria.siromove.com/siro/ride/location';
case 'Egypt': return 'https://location-egypt.siromove.com/siro/ride/location';
case 'Jordan': return 'https://location-jordan.siromove.com/siro/ride/location';
default: return 'https://location.siromove.com/siro/ride/location';
}
}
static String get locationServerSide => locationServer;
static String get mapSaasRoute {
switch (currentCountry) {
case 'Syria': return 'https://map-syria.siromove.com/api/maps/route';
case 'Egypt': return 'https://map-egypt.siromove.com/api/maps/route';
case 'Jordan': return 'https://map-jordan.siromove.com/api/maps/route';
default: return 'https://map-saas.intaleqapp.com/api/maps/route';
}
}
static String get mapSaasPlaces {
switch (currentCountry) {
case 'Syria': return 'https://map-syria.siromove.com/api/geocoding/places';
case 'Egypt': return 'https://map-egypt.siromove.com/api/geocoding/places';
case 'Jordan': return 'https://map-jordan.siromove.com/api/geocoding/places';
default: return 'https://map-saas.intaleqapp.com/api/geocoding/places';
}
}
static String get routeApiBaseUrl {
switch (currentCountry) {
case 'Syria': return 'https://routes-syria.siromove.com/route/v1/driving';
case 'Egypt': return 'https://routes-egypt.siromove.com/route/v1/driving';
case 'Jordan': return 'https://routes-jordan.siromove.com/route/v1/driving';
default: return 'https://routes.siromove.com/route/v1/driving';
}
}
static String loginJwtDriver =
"https://api.intaleq.xyz/siro/loginAdmin.php";
//=============================

View File

@@ -20,6 +20,7 @@ import '../../views/widgets/elevated_btn.dart';
import '../functions/encrypt_decrypt.dart';
import '../notification_controller.dart';
import 'local_notification.dart';
import 'notification_service.dart';
import 'token_access.dart';
class FirebaseMessagesController extends GetxController {
@@ -364,66 +365,6 @@ class FirebaseMessagesController extends GetxController {
// ));
// }
void sendNotificationAll(String title, body) async {
// Get the token you want to subtract.
String token = box.read(BoxName.tokenFCM);
tokens = box.read(BoxName.tokens);
// Subtract the token from the list of tokens.
tokens.remove(token);
// Save the list of tokens back to the box.
// box.write(BoxName.tokens, tokens);
tokens = box.read(BoxName.tokens);
for (var i = 0; i < tokens.length; i++) {
String serviceAccountKeyJson = '''{
"type": "service_account",
"project_id": "ride-b1bd8",
"private_key_id": "75e817c0b902db2ef35edf2c2bd159dec1f13249",
"private_key": "-----BEGIN PRIV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M\\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({
'notification': <String, dynamic>{
'title': title,
'body': body,
'sound': 'ding.wav'
},
'priority': 'high',
'data': <String, dynamic>{
'click_action': 'FLUTTER_NOTIFICATION_CLICK',
'id': '1',
'status': 'done'
},
'to': tokens[i],
}))
.whenComplete(() {})
.catchError((e) {});
}
}
// for (var i = 0; i < tokens.length; i++) {
// http
// .post(Uri.parse('https://fcm.googleapis.com/fcm/send'),
@@ -452,66 +393,18 @@ class FirebaseMessagesController extends GetxController {
// }
//android/app/src/main/res/raw/iphone_ringtone.wav
late String serviceAccountKeyJson;
void sendNotificationAll(String title, body) async {
// Deprecated: Admin panel notifications are sent via NotificationService.
}
void sendNotificationToAnyWithoutData(
String title, String body, String token, String tone) async {
try {
var encryptedKey = Env.privateKeyFCM;
// Log.print('encryptedKey: ${encryptedKey}');
serviceAccountKeyJson =
EncryptionHelper.instance.decryptData(encryptedKey);
// As defined above
// Initialize AccessTokenManager
final accessTokenManager = AccessTokenManager(serviceAccountKeyJson);
// Obtain an OAuth 2.0 access token
final accessToken = await accessTokenManager.getAccessToken();
// Log.print('accessToken: ${accessToken}');
// Send the notification
final response = await http.post(
Uri.parse(
'https://fcm.googleapis.com/v1/projects/siro-d48a7/messages:send'),
headers: <String, String>{
'Content-Type': 'application/json',
'Authorization': 'Bearer $accessToken',
},
body: jsonEncode({
'message': {
'token': token,
'notification': {
'title': title,
'body': body,
},
'android': {
'notification': {
'sound': tone,
},
},
'apns': {
'payload': {
'aps': {
'sound': tone,
},
},
},
},
}),
);
if (response.statusCode == 200) {
SnackBar(content: Text('${response.statusCode}'));
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}');
}
} catch (e) {
print('Error sending notification: $e');
}
await NotificationService.sendNotification(
target: token,
title: title,
body: body,
category: 'fromAdmin',
tone: tone,
);
}
}

View File

@@ -1,12 +1,10 @@
import 'dart:convert';
import 'package:http/http.dart' as http;
import '../../print.dart';
import '../../constant/links.dart';
class NotificationService {
// تأكد من أن هذا هو الرابط الصحيح لملف الإرسال
static const String _serverUrl =
'https://syria.intaleq.xyz/siro/fcm/send_fcm.php';
static String get _serverUrl => '${AppLink.server.replaceAll('_v3', '')}/ride/firebase/send_fcm.php';
static Future<void> sendNotification({
required String target,

View File

@@ -1,53 +1,51 @@
import 'dart:convert';
import 'package:googleapis_auth/auth_io.dart';
// import 'dart:convert';
import '../../print.dart';
// import '../../print.dart';
class AccessTokenManager {
static final AccessTokenManager _instance = AccessTokenManager._internal();
late final String serviceAccountJsonKey;
AccessToken? _accessToken;
DateTime? _expiryDate;
// class AccessTokenManager {
// static final AccessTokenManager _instance = AccessTokenManager._internal();
// late final String serviceAccountJsonKey;
// DateTime? _expiryDate;
AccessTokenManager._internal();
// AccessTokenManager._internal();
factory AccessTokenManager(String jsonKey) {
if (_instance._isServiceAccountKeyInitialized()) {
// Prevent re-initialization
return _instance;
}
_instance.serviceAccountJsonKey = jsonKey;
return _instance;
}
// factory AccessTokenManager(String jsonKey) {
// if (_instance._isServiceAccountKeyInitialized()) {
// // Prevent re-initialization
// return _instance;
// }
// _instance.serviceAccountJsonKey = jsonKey;
// return _instance;
// }
bool _isServiceAccountKeyInitialized() {
try {
serviceAccountJsonKey; // Access to check if initialized
return true;
} catch (e) {
return false;
}
}
// bool _isServiceAccountKeyInitialized() {
// try {
// serviceAccountJsonKey; // Access to check if initialized
// return true;
// } catch (e) {
// return false;
// }
// }
Future<String> getAccessToken() async {
if (_accessToken != null && DateTime.now().isBefore(_expiryDate!)) {
return _accessToken!.data;
}
try {
final serviceAccountCredentials = ServiceAccountCredentials.fromJson(
json.decode(serviceAccountJsonKey));
final client = await clientViaServiceAccount(
serviceAccountCredentials,
['https://www.googleapis.com/auth/firebase.messaging'],
);
// Future<String> getAccessToken() async {
// if (_accessToken != null && DateTime.now().isBefore(_expiryDate!)) {
// return _accessToken!.data;
// }
// try {
// final serviceAccountCredentials = ServiceAccountCredentials.fromJson(
// json.decode(serviceAccountJsonKey));
// final client = await clientViaServiceAccount(
// serviceAccountCredentials,
// ['https://www.googleapis.com/auth/firebase.messaging'],
// );
_accessToken = client.credentials.accessToken;
_expiryDate = client.credentials.accessToken.expiry;
client.close();
Log.print('_accessToken!.data: ${_accessToken!.data}');
return _accessToken!.data;
} catch (e) {
throw Exception('Failed to obtain access token');
}
}
}
// _accessToken = client.credentials.accessToken;
// _expiryDate = client.credentials.accessToken.expiry;
// client.close();
// Log.print('_accessToken!.data: ${_accessToken!.data}');
// return _accessToken!.data;
// } catch (e) {
// throw Exception('Failed to obtain access token');
// }
// }
// }

View File

@@ -29,12 +29,12 @@ class WalletController extends GetxController {
'driverID': driverID.toString(),
});
if (res != 'failure') {
FirebaseMessagesController().sendNotificationToAnyWithoutData(
"لديك هدية من سفَر".tr,
'لقد حصلت على هدية من سفر بقيمة $amount ',
token, // Access token correctly
'ding.wav',
);
// FirebaseMessagesController().sendNotificationToAnyWithoutData(
// "لديك هدية من سفَر".tr,
// 'لقد حصلت على هدية من سفر بقيمة $amount ',
// token, // Access token correctly
// 'ding.wav',
// );
Get.snackbar('success', 'addPaymentToDriver',
backgroundColor: AppColor.greenColor);
} else {

View File

@@ -249,7 +249,8 @@ class CaptainDetailsPage extends StatelessWidget {
borderRadius: BorderRadius.circular(12)),
),
onPressed: () {
Get.to(() => DriverScorecardPage(driverId: data['id'].toString()));
Get.to(
() => DriverScorecardPage(driverId: data['id'].toString()));
},
),
),
@@ -380,11 +381,11 @@ class CaptainDetailsPage extends StatelessWidget {
// Check if key is valid (might be recreated)
if (controller.formCaptainPrizeKey.currentState?.validate() ??
true) {
FirebaseMessagesController().sendNotificationToAnyWithoutData(
controller.titleNotify.text,
controller.bodyNotify.text,
data['passengerToken'] ?? '', // Safety check
'order.wav');
// FirebaseMessagesController().sendNotificationToAnyWithoutData(
// controller.titleNotify.text,
// controller.bodyNotify.text,
// data['passengerToken'] ?? '', // Safety check
// 'order.wav');
Get.back();
Get.snackbar("Success", "Notification Sent",
backgroundColor: Colors.green.withOpacity(0.2));

View File

@@ -393,11 +393,11 @@ class PassengerDetailsPage extends StatelessWidget {
onPressed: () {
// Validate form safely
if (controller.formPrizeKey.currentState?.validate() ?? false) {
FirebaseMessagesController().sendNotificationToAnyWithoutData(
controller.titleNotify.text,
controller.bodyNotify.text,
data['passengerToken'],
'order.wav');
// FirebaseMessagesController().sendNotificationToAnyWithoutData(
// controller.titleNotify.text,
// controller.bodyNotify.text,
// data['passengerToken'],
// 'order.wav');
Get.back();
Get.snackbar('Success', 'Notification sent successfully!',
backgroundColor: Colors.green.withOpacity(0.2));

View File

@@ -12,7 +12,6 @@ import firebase_crashlytics
import firebase_messaging
import flutter_image_compress_macos
import flutter_secure_storage_macos
import google_sign_in_ios
import local_auth_darwin
import sqflite_darwin
import url_launcher_macos
@@ -25,7 +24,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FLTFirebaseMessagingPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseMessagingPlugin"))
FlutterImageCompressMacosPlugin.register(with: registry.registrar(forPlugin: "FlutterImageCompressMacosPlugin"))
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
FLTGoogleSignInPlugin.register(with: registry.registrar(forPlugin: "FLTGoogleSignInPlugin"))
LocalAuthPlugin.register(with: registry.registrar(forPlugin: "LocalAuthPlugin"))
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))

View File

@@ -592,62 +592,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "6.3.3"
google_identity_services_web:
dependency: transitive
description:
name: google_identity_services_web
sha256: "5d187c46dc59e02646e10fe82665fc3884a9b71bc1c90c2b8b749316d33ee454"
url: "https://pub.dev"
source: hosted
version: "0.3.3+1"
google_sign_in:
dependency: "direct main"
description:
name: google_sign_in
sha256: d0a2c3bcb06e607bb11e4daca48bd4b6120f0bbc4015ccebbe757d24ea60ed2a
url: "https://pub.dev"
source: hosted
version: "6.3.0"
google_sign_in_android:
dependency: transitive
description:
name: google_sign_in_android
sha256: d5e23c56a4b84b6427552f1cf3f98f716db3b1d1a647f16b96dbb5b93afa2805
url: "https://pub.dev"
source: hosted
version: "6.2.1"
google_sign_in_ios:
dependency: transitive
description:
name: google_sign_in_ios
sha256: "102005f498ce18442e7158f6791033bbc15ad2dcc0afa4cf4752e2722a516c96"
url: "https://pub.dev"
source: hosted
version: "5.9.0"
google_sign_in_platform_interface:
dependency: transitive
description:
name: google_sign_in_platform_interface
sha256: "5f6f79cf139c197261adb6ac024577518ae48fdff8e53205c5373b5f6430a8aa"
url: "https://pub.dev"
source: hosted
version: "2.5.0"
google_sign_in_web:
dependency: transitive
description:
name: google_sign_in_web
sha256: "460547beb4962b7623ac0fb8122d6b8268c951cf0b646dd150d60498430e4ded"
url: "https://pub.dev"
source: hosted
version: "0.12.4+4"
googleapis_auth:
dependency: "direct main"
description:
name: googleapis_auth
sha256: befd71383a955535060acde8792e7efc11d2fccd03dd1d3ec434e85b68775938
url: "https://pub.dev"
source: hosted
version: "1.6.0"
graphs:
dependency: transitive
description:

View File

@@ -48,7 +48,6 @@ dependencies:
# google_maps_flutter: ^2.6.1
flutter_map: ^7.0.0 # مكتبة OpenStreetMap للفلاتر
latlong2: ^0.9.1
google_sign_in: ^6.2.1
http: ^1.0.0
# image: ^4.1.7
image_cropper: ^8.0.2
@@ -60,7 +59,6 @@ dependencies:
sqflite: ^2.3.3+1
url_launcher: ^6.2.6
# webview_flutter: ^4.7.0
googleapis_auth: ^1.6.0
firebase_crashlytics: ^4.2.0
flutter_image_compress: ^2.3.0
jwt_decoder: ^2.0.1