diff --git a/android/app/build.gradle b/android/app/build.gradle
index 7792554..198bc87 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -21,6 +21,12 @@ 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 plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
@@ -46,16 +52,22 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "hmg.cloudSolutions.mohem"
minSdkVersion 21
- targetSdkVersion 32
+ targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
+ signingConfigs {
+ release {
+ keyAlias keystoreProperties['keyAlias']
+ keyPassword keystoreProperties['keyPassword']
+ storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
+ storePassword keystoreProperties['storePassword']
+ }
+ }
buildTypes {
release {
- // TODO: Add your own signing config for the release build.
- // Signing with the debug keys for now, so `flutter run --release` works.
- signingConfig signingConfigs.debug
+ signingConfig signingConfigs.release
}
}
}
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 10d72b4..f187ebd 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -7,6 +7,7 @@
+
+
+
+
+
+
+
diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json
index b4cf456..a2f0aa1 100644
--- a/assets/langs/ar-SA.json
+++ b/assets/langs/ar-SA.json
@@ -520,6 +520,6 @@
"noUpcoming": "لا يوجد قادم",
"fakeLocation": ".لقد تتبعنا أنك تحاول استخدام موقع مزيف! يعتبر هذا مخالفة وقد تم إخطار الموارد البشرية",
"noWinner": "حزين! لم يفز أحد اليوم.",
- "myTeam" : "فريقي"
+ "myTeam" : "فريقي",
"youCanPlayDemo": "لكن يمكنك لعب العرض"
}
\ No newline at end of file
diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json
index 3d37c1b..2e6703a 100644
--- a/assets/langs/en-US.json
+++ b/assets/langs/en-US.json
@@ -520,6 +520,6 @@
"noUpcoming": "There is no upcoming",
"fakeLocation": "We traced out that you try to use a fake location! This is considered a violation, and HR has been notified.",
"noWinner": "Sad! No one won today.",
- "myTeam" : "My Team"
+ "myTeam" : "My Team",
"youCanPlayDemo": "But you can play demo"
}
\ No newline at end of file
diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift
index 70693e4..c1c9fd9 100644
--- a/ios/Runner/AppDelegate.swift
+++ b/ios/Runner/AppDelegate.swift
@@ -1,5 +1,7 @@
import UIKit
import Flutter
+import Firebase
+
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
@@ -7,6 +9,7 @@ import Flutter
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
+ FirebaseApp.configure()
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist
index f8d7b49..e326d8f 100644
--- a/ios/Runner/Info.plist
+++ b/ios/Runner/Info.plist
@@ -13,7 +13,7 @@
CFBundleInfoDictionaryVersion
6.0
CFBundleName
- mohem_flutter_app
+ MOHEMM
CFBundlePackageType
APPL
CFBundleShortVersionString
@@ -46,10 +46,14 @@
This app requires photo library access to select image as document & upload it.
NSMicrophoneUsageDescription
This app requires microphone access to for call.
+ NSPhotoLibraryUsageDescription
+ This app requires photo library access to select image as document & upload it.
UIBackgroundModes
remote-notification
+ FirebaseAppDelegateProxyEnabled
+
UILaunchStoryboardName
LaunchScreen
UIMainStoryboardFile
@@ -69,6 +73,13 @@
UIViewControllerBasedStatusBarAppearance
+ com.apple.developer.nfc.readersession.felica.systemcodes
+
+ 0000
+
+ ITSAppUsesNonExemptEncryption
+
+
com.apple.developer.nfc.readersession.formats
TAG
diff --git a/lib/api/chat/chat_api_client.dart b/lib/api/chat/chat_api_client.dart
index 87e684e..b4c0a2c 100644
--- a/lib/api/chat/chat_api_client.dart
+++ b/lib/api/chat/chat_api_client.dart
@@ -30,10 +30,13 @@ class ChatApiClient {
{
"employeeNumber": AppState().memberInformationList!.eMPLOYEENUMBER.toString(),
"password": "FxIu26rWIKoF8n6mpbOmAjDLphzFGmpG",
+ "isMobile": true,
+ "deviceToken": AppState().getDeviceToken,
},
);
+
if (!kReleaseMode) {
- logger.i("res: " + response.body);
+ logger.i("login-res: " + response.body);
}
if (response.statusCode == 200) {
userLoginResponse = user.userAutoLoginModelFromJson(response.body);
diff --git a/lib/api/items_for_sale/items_for_sale_api_client.dart b/lib/api/items_for_sale/items_for_sale_api_client.dart
index eae6ffb..a04651e 100644
--- a/lib/api/items_for_sale/items_for_sale_api_client.dart
+++ b/lib/api/items_for_sale/items_for_sale_api_client.dart
@@ -32,7 +32,7 @@ class ItemsForSaleApiClient {
getSaleCategoriesListObj.titleAr = "الجميع";
getSaleCategoriesListObj.isActive = true;
getSaleCategoriesListObj.content =
- '';
+ '';
getSaleCategoriesList.add(getSaleCategoriesListObj);
diff --git a/lib/api/offers_and_discounts_api_client.dart b/lib/api/offers_and_discounts_api_client.dart
index 6189612..1d3153c 100644
--- a/lib/api/offers_and_discounts_api_client.dart
+++ b/lib/api/offers_and_discounts_api_client.dart
@@ -30,7 +30,7 @@ class OffersAndDiscountsApiClient {
getSaleCategoriesListObj.categoryNameAr = "الجميع";
getSaleCategoriesListObj.isActive = true;
getSaleCategoriesListObj.content =
- '';
+ '';
getSaleCategoriesList.add(getSaleCategoriesListObj);
diff --git a/lib/app_state/app_state.dart b/lib/app_state/app_state.dart
index 1a69faa..731a45e 100644
--- a/lib/app_state/app_state.dart
+++ b/lib/app_state/app_state.dart
@@ -17,6 +17,12 @@ class AppState {
factory AppState() => _instance;
+ String? deviceToken = "";
+
+ set setDeviceToken(v) => deviceToken = v;
+
+ String? get getDeviceToken => deviceToken;
+
bool isAuthenticated = false;
set setIsAuthenticated(v) => isAuthenticated = v;
@@ -173,4 +179,13 @@ class AppState {
}
bool cancelRequestTrancsection = true;
+
+
+ String? _deviceNotificationToken;
+
+ String? get deviceNotificationToken => _deviceNotificationToken;
+
+ set deviceNotificationToken(String? deviceNotificationToken) {
+ _deviceNotificationToken = deviceNotificationToken;
+ }
}
diff --git a/lib/classes/notifications.dart b/lib/classes/notifications.dart
new file mode 100644
index 0000000..336b87c
--- /dev/null
+++ b/lib/classes/notifications.dart
@@ -0,0 +1,59 @@
+import 'dart:convert';
+import 'dart:io';
+import 'package:firebase_messaging/firebase_messaging.dart';
+import 'package:mohem_flutter_app/app_state/app_state.dart';
+import 'package:mohem_flutter_app/main.dart';
+import 'package:permission_handler/permission_handler.dart';
+
+//final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
+
+
+class AppNotifications {
+ static final AppNotifications _instance = AppNotifications._internal();
+
+ AppNotifications._internal();
+
+ factory AppNotifications() => _instance;
+
+ // Future requestPermissions() async {
+ // if (Platform.isIOS) {
+ // await flutterLocalNotificationsPlugin.resolvePlatformSpecificImplementation()?.requestPermissions(alert: true, badge: true, sound: true);
+ // } else if (Platform.isAndroid) {
+ // AndroidFlutterLocalNotificationsPlugin? androidImplementation = flutterLocalNotificationsPlugin.resolvePlatformSpecificImplementation();
+ // bool? granted = await androidImplementation?.requestPermission();
+ // if (granted == false) {
+ // print("-------------------- Permission Granted ------------------------");
+ // print(granted);
+ // await Permission.notification.request();
+ // }
+ // }
+ // }
+
+ // Future isAndroidPermGranted() async {
+ // if (Platform.isAndroid) {
+ // bool granted = await flutterLocalNotificationsPlugin.resolvePlatformSpecificImplementation()?.areNotificationsEnabled() ?? false;
+ // }
+ // }
+
+ void initNotification(String? firebaseToken) async {
+ // await requestPermissions();
+ AppState().setDeviceToken = firebaseToken;
+ // await Permission.notification.isDenied.then((value) {
+ // if (value) {
+ // Permission.notification.request();
+ // }
+ // });
+ RemoteMessage? initialMessage = await FirebaseMessaging.instance.getInitialMessage();
+ if (initialMessage != null) _handleMessage(initialMessage);
+
+ FirebaseMessaging.onMessage.listen((RemoteMessage message) {
+ if (message.notification != null) _handleMessage(message);
+ });
+ FirebaseMessaging.onMessageOpenedApp.listen(_handleMessage);
+ }
+
+ void _handleMessage(RemoteMessage message) {
+ print("Handle Message");
+ logger.w(json.encode(message));
+ }
+}
diff --git a/lib/classes/push-notification-handler.dart b/lib/classes/push-notification-handler.dart
new file mode 100644
index 0000000..b95ceb2
--- /dev/null
+++ b/lib/classes/push-notification-handler.dart
@@ -0,0 +1,59 @@
+import 'dart:async';
+import 'dart:io';
+
+import 'package:firebase_messaging/firebase_messaging.dart';
+import 'package:flutter/cupertino.dart';
+import 'package:flutter/material.dart';
+import 'package:mohem_flutter_app/app_state/app_state.dart';
+
+// |--> Push Notification Background
+Future backgroundMessageHandler(message) async {
+ print("Firebase backgroundMessageHandler!!!");
+}
+
+class PushNotificationHandler {
+ final BuildContext context;
+ static PushNotificationHandler? _instance;
+
+ PushNotificationHandler(this.context) {
+ PushNotificationHandler._instance = this;
+ }
+
+ static PushNotificationHandler getInstance() => _instance!;
+
+ void init() async {
+ FirebaseMessaging.onMessage.listen((RemoteMessage message) async {
+ if (Platform.isIOS) {
+ await Future.delayed(Duration(milliseconds: 3000)).then((value) {
+ newMessage(message);
+ });
+ } else {
+ newMessage(message);
+ }
+ });
+
+ FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) async {
+ if (Platform.isIOS) {
+ await Future.delayed(Duration(milliseconds: 3000)).then((value) {
+ newMessage(message);
+ });
+ } else {
+ newMessage(message);
+ }
+ });
+
+ FirebaseMessaging.instance.onTokenRefresh.listen((fcm_token) {
+ print("Push Notification onTokenRefresh: " + fcm_token);
+ AppState().setDeviceToken = fcm_token;
+ });
+
+ FirebaseMessaging.onBackgroundMessage(backgroundMessageHandler);
+ }
+
+ void newMessage(RemoteMessage remoteMessage) async {
+ print("Remote Message: " + remoteMessage.data.toString());
+ if (remoteMessage.data.isEmpty) {
+ return;
+ }
+ }
+}
diff --git a/lib/generated/codegen_loader.g.dart b/lib/generated/codegen_loader.g.dart
index f01aa0d..1563767 100644
--- a/lib/generated/codegen_loader.g.dart
+++ b/lib/generated/codegen_loader.g.dart
@@ -6,1048 +6,1063 @@ import 'dart:ui';
import 'package:easy_localization/easy_localization.dart' show AssetLoader;
-class CodegenLoader extends AssetLoader {
+class CodegenLoader extends AssetLoader{
const CodegenLoader();
@override
- Future