From 1b50de9a7c3d07a5a34596b723ef7748980b4ad2 Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Tue, 17 Sep 2024 00:31:50 +0300 Subject: [PATCH] 9/16/2 --- android/app/src/main/AndroidManifest.xml | 1 + ios/Runner/Info.plist | 184 +++++++++--------- lib/constant/box_name.dart | 1 + lib/controller/auth/login_controller.dart | 8 +- lib/controller/auth/register_controller.dart | 5 +- lib/controller/firebase/firbase_messge.dart | 66 +++++-- .../home/map_passenger_controller.dart | 2 +- lib/controller/local/translations.dart | 1 + .../payment/payment_controller.dart | 78 ++++---- .../payment/paymob/paymob_wallet.dart | 4 +- lib/main.dart | 4 +- lib/views/widgets/my_textField.dart | 2 +- 12 files changed, 199 insertions(+), 157 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index fedcf91..6759204 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -25,6 +25,7 @@ android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" + android:enableOnBackInvokedCallback="true" android:windowSoftInputMode="adjustResize"> - - CFBundleURLTypes - - - CFBundleTypeRole - Editor - CFBundleURLSchemes - - com.googleusercontent.apps.594687661098-8e26699cris2k3nj5msj1osi59it9kpf - - - - LSApplicationQueriesSchemes - - googlechromes - comgooglemaps - - CADisableMinimumFrameDurationOnPhone - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleDisplayName - Sefer - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleGetInfoString - - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - Sefer - CFBundlePackageType - APPL - CFBundleShortVersionString - 48 - CFBundleSignature - ???? - CFBundleVersion - 4.3.48 - FirebaseAppDelegateProxyEnabled - NO - GMSApiKey - YOUR_API_KEY - LSApplicationCategoryType - - LSRequiresIPhoneOS - - NSCameraUsageDescription - Sefer app requires access to your camera in order to scan QR codes and capture + + CFBundleURLTypes + + + CFBundleTypeRole + Editor + CFBundleURLSchemes + + com.googleusercontent.apps.594687661098-8e26699cris2k3nj5msj1osi59it9kpf + + + + LSApplicationQueriesSchemes + + googlechromes + comgooglemaps + + CADisableMinimumFrameDurationOnPhone + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Sefer + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleGetInfoString + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + Sefer + CFBundlePackageType + APPL + CFBundleShortVersionString + 48 + CFBundleSignature + ???? + CFBundleVersion + 4.3.48 + FirebaseAppDelegateProxyEnabled + NO + GMSApiKey + YOUR_API_KEY + LSApplicationCategoryType + + LSRequiresIPhoneOS + + NSCameraUsageDescription + Sefer app requires access to your camera in order to scan QR codes and capture images for uploading and access to connect to a call. - NSFaceIDUsageDescription - Use Face ID to securely authenticate payment accounts. - NSLocationAlwaysAndWhenInUseUsageDescription - This app needs access to your location to provide you with the best ride experience. + NSFaceIDUsageDescription + Use Face ID to securely authenticate payment accounts. + NSLocationAlwaysAndWhenInUseUsageDescription + This app needs access to your location to provide you with the best ride experience. Your location data will be used to find the nearest available cars and connect you with the closest captain for efficient and convenient rides. - NSLocationAlwaysUsageDescription - This app needs access to location. - NSLocationWhenInUseUsageDescription - This app needs access to your location to provide you with the best ride experience. + NSLocationAlwaysUsageDescription + This app needs access to location. + NSLocationWhenInUseUsageDescription + This app needs access to your location to provide you with the best ride experience. Your location data will be used to find the nearest available cars and connect you with the closest captain for efficient and convenient rides. - NSMicrophoneUsageDescription - This app requires access to your microphone to record audio, allowing you to add + NSMicrophoneUsageDescription + This app requires access to your microphone to record audio, allowing you to add voice recordings to your photos and videos and access to connect to a call. - NSPhotoLibraryUsageDescription - Explanation of why your app needs access to the photo library. - UIApplicationSupportsIndirectInputEvents - - UIBackgroundModes - - fetch - location - remote-notification - - UILaunchStoryboardName - LaunchScreen - UIMainStoryboardFile - Main - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UIViewControllerBasedStatusBarAppearance - - - + NSPhotoLibraryUsageDescription + Explanation of why your app needs access to the photo library. + UIApplicationSupportsIndirectInputEvents + + UIBackgroundModes + + fetch + location + remote-notification + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + + \ No newline at end of file diff --git a/lib/constant/box_name.dart b/lib/constant/box_name.dart index 450d1ba..c6dced8 100644 --- a/lib/constant/box_name.dart +++ b/lib/constant/box_name.dart @@ -25,6 +25,7 @@ class BoxName { static const String sosPhoneDriver = "sosPhoneDriver"; static const String passengerID = "pasengerID"; static const String phone = "phone"; + static const String phoneWallet = "phoneWallet"; static const String phoneDriver = "phoneDriver"; static const String dobDriver = "dobDriver"; static const String sexDriver = "sexDriver"; diff --git a/lib/controller/auth/login_controller.dart b/lib/controller/auth/login_controller.dart index eca3c09..b74a538 100644 --- a/lib/controller/auth/login_controller.dart +++ b/lib/controller/auth/login_controller.dart @@ -246,10 +246,10 @@ class LoginController extends GetxController { void onInit() async { // permissionLocation = await Permission.locationWhenInUse.isGranted; await getAppTester(AppInformation.appName); - if (isTest == 0 && box.read(BoxName.passengerID) != null) { - await loginUsingCredentials( - box.read(BoxName.passengerID), box.read(BoxName.email)); - } + // if (isTest == 0 && box.read(BoxName.passengerID) != null) { + // await loginUsingCredentials( + // box.read(BoxName.passengerID), box.read(BoxName.email)); + // } super.onInit(); } } diff --git a/lib/controller/auth/register_controller.dart b/lib/controller/auth/register_controller.dart index d728a5e..7ff0d90 100644 --- a/lib/controller/auth/register_controller.dart +++ b/lib/controller/auth/register_controller.dart @@ -232,9 +232,10 @@ class RegisterController extends GetxController { print('WhatsApp message sent to non-Egyptian phone number: $phoneNumber'); } isLoading = false; - update(); + isSent = true; - remainingTime = 300; // Reset to 5 minutes + remainingTime = 300; + update(); // Reset to 5 minutes startTimer(); } diff --git a/lib/controller/firebase/firbase_messge.dart b/lib/controller/firebase/firbase_messge.dart index cc46326..adaead2 100644 --- a/lib/controller/firebase/firbase_messge.dart +++ b/lib/controller/firebase/firbase_messge.dart @@ -495,34 +495,70 @@ class FirebaseMessagesController extends GetxController { void sendNotificationToPassengerToken( String title, body, token, List 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/IWhJ985u58T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IpbQXRngZoopKW3/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(); + // Log.print('accessToken: ${accessToken}'); + + // Send the notification final response = await http.post( - Uri.parse('https://fcm.googleapis.com/fcm/send'), + Uri.parse( + 'https://fcm.googleapis.com/v1/projects/ride-b1bd8/messages:send'), headers: { 'Content-Type': 'application/json', - 'Authorization': 'key=${AK.serverAPI}' + 'Authorization': 'Bearer $accessToken', }, body: jsonEncode({ - 'notification': { - 'title': title, - 'body': body, - 'sound': tone + 'message': { + 'token': token, + 'notification': { + 'title': title, + 'body': body, + }, + 'android': { + 'notification': { + 'sound': tone, + }, + }, + 'apns': { + 'payload': { + 'aps': { + 'sound': tone, + }, + }, + }, }, - 'data': { - 'passengerList': map, - }, - 'priority': 'high', - 'to': token, }), ); if (response.statusCode == 200) { - // Notification sent successfully + print( + 'Notification sent successfully. Status code: ${response.statusCode}'); + print('Response body: ${response.body}'); } else { - // Handle error response - 'Failed to send notification. Status code: ${response.statusCode}'; + print( + 'Failed to send notification. Status code: ${response.statusCode}'); + print('Response body: ${response.body}'); } } catch (e) { - // Handle other exceptions + print('Error sending notification: $e'); } } diff --git a/lib/controller/home/map_passenger_controller.dart b/lib/controller/home/map_passenger_controller.dart index deb6e0b..3eb764e 100644 --- a/lib/controller/home/map_passenger_controller.dart +++ b/lib/controller/home/map_passenger_controller.dart @@ -1769,7 +1769,7 @@ class MapPassengerController extends GetxController { 'northeastLon': bounds.northeast.longitude.toString(), }); break; - case 'Balash': + case 'Awfar Car': res = await CRUD() .get(link: AppLink.getCarsLocationByPassengerBalash, payload: { 'southwestLat': bounds.southwest.latitude.toString(), diff --git a/lib/controller/local/translations.dart b/lib/controller/local/translations.dart index 5d406ad..527f840 100644 --- a/lib/controller/local/translations.dart +++ b/lib/controller/local/translations.dart @@ -7,6 +7,7 @@ class MyTranslation extends Translations { "Update Available": "تحديث متوفر", 'Phone number must be exactly 11 digits long': "رقم الهاتف يجب أن يكون بطول 11 رقماً", + 'Insert Wallet phone number': 'أدخل رقم هاتف المحفظة', "Phone number isn't an Egyptian phone number": "رقم الهاتف ليس رقم هاتف مصري", "A new version of the app is available. Please update to the latest version.": diff --git a/lib/controller/payment/payment_controller.dart b/lib/controller/payment/payment_controller.dart index 4eb96d4..6d39df7 100644 --- a/lib/controller/payment/payment_controller.dart +++ b/lib/controller/payment/payment_controller.dart @@ -31,6 +31,7 @@ class PaymentController extends GetxController { bool isPromoSheetDialogue = false; final formKey = GlobalKey(); final promo = TextEditingController(); + final walletphoneController = TextEditingController(); double totalPassenger = Get.find().totalPassenger; int? selectedAmount = 0; List totalPassengerWalletDetails = []; @@ -762,44 +763,45 @@ class PaymentController extends GetxController { billingData: PaymobBillingData(), onPayment: (PaymobResponse response) {}, ); - - if (response!.responseCode == 'APPROVED') { - Get.defaultDialog( - barrierDismissible: false, - title: 'Payment Successful'.tr, - titleStyle: AppStyle.title, - // backgroundColor: AppColor.greenColor, - content: Text( - 'The payment was approved.'.tr, - style: AppStyle.title, - ), - confirm: MyElevatedButton( - kolor: AppColor.greenColor, - title: 'OK'.tr, - onPressed: () async { - Get.back(); - method(); - }, - ), - ); - } else { - Get.defaultDialog( - barrierDismissible: false, - // backgroundColor: AppColor.redColor, - title: 'Payment Failed'.tr, - content: Text( - 'The payment was not approved. Please try again.'.tr, - textAlign: TextAlign.center, - style: AppStyle.title, - ), - confirm: MyElevatedButton( - title: 'OK'.tr, - kolor: AppColor.redColor, - onPressed: () async { - Get.back(); - }, - ), - ); + if (response!.success == true && response.responseCode == '200') { + if (response!.responseCode == 'APPROVED') { + Get.defaultDialog( + barrierDismissible: false, + title: 'Payment Successful'.tr, + titleStyle: AppStyle.title, + // backgroundColor: AppColor.greenColor, + content: Text( + 'The payment was approved.'.tr, + style: AppStyle.title, + ), + confirm: MyElevatedButton( + kolor: AppColor.greenColor, + title: 'OK'.tr, + onPressed: () async { + Get.back(); + method(); + }, + ), + ); + } else { + Get.defaultDialog( + barrierDismissible: false, + // backgroundColor: AppColor.redColor, + title: 'Payment Failed'.tr, + content: Text( + 'The payment was not approved. Please try again.'.tr, + textAlign: TextAlign.center, + style: AppStyle.title, + ), + confirm: MyElevatedButton( + title: 'OK'.tr, + kolor: AppColor.redColor, + onPressed: () async { + Get.back(); + }, + ), + ); + } } } } catch (e) { diff --git a/lib/controller/payment/paymob/paymob_wallet.dart b/lib/controller/payment/paymob/paymob_wallet.dart index 3e8c3c7..e743bee 100644 --- a/lib/controller/payment/paymob/paymob_wallet.dart +++ b/lib/controller/payment/paymob/paymob_wallet.dart @@ -144,7 +144,7 @@ class PaymobPaymentWallet { }) async { final Map data = { "source": { - "identifier": box.read(BoxName.phone).toString(), + "identifier": box.read(BoxName.phoneWallet).toString(), "subtype": "WALLET", }, "payment_token": paymentToken, @@ -269,7 +269,7 @@ class PaymobBillingDataWallet { "email": box.read(BoxName.email) ?? box.read(BoxName.emailDriver), "first_name": box.read(BoxName.name) ?? box.read(BoxName.nameDriver), "last_name": box.read(BoxName.name) ?? box.read(BoxName.nameDriver), - "phone_number": box.read(BoxName.phone) ?? box.read(BoxName.phoneDriver), + "phone_number": box.read(BoxName.phoneWallet), "apartment": apartment ?? "NA", "floor": floor ?? "NA", "building": building ?? "NA", diff --git a/lib/main.dart b/lib/main.dart index 095fe52..028dc86 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -77,9 +77,9 @@ void main() async { userTokenExpiration: 200, iFrameID: 837992, ); + PaymobPaymentWallet.instance.initialize( - apiKey: AK - .payMobApikey, // from dashboard Select Settings -> Account Info -> API Key + apiKey: AK.payMobApikey, integrationID: int.parse(AK.integrationIdPayMobWallet), userTokenExpiration: 200, iFrameID: 837992, diff --git a/lib/views/widgets/my_textField.dart b/lib/views/widgets/my_textField.dart index 2e4f060..15fc4c0 100644 --- a/lib/views/widgets/my_textField.dart +++ b/lib/views/widgets/my_textField.dart @@ -27,7 +27,7 @@ class MyTextForm extends StatelessWidget { children: [ Text( label.tr, - style: TextStyle( + style: const TextStyle( color: CupertinoColors.label, fontSize: 16, fontWeight: FontWeight.w600,