last login token updated.

wala_plus_with_dialog_removal
Sultan khan 2 weeks ago
parent 7043f0f91c
commit a517e4e48b

@ -703,7 +703,7 @@
"copyLink": "Copy Link", "copyLink": "Copy Link",
"done": "Done", "done": "Done",
"linkCopied": "Link copied to clipboard", "linkCopied": "Link copied to clipboard",
"mazayaAccessRevoked": "Mazaya access revoked", "mazayaAccessRevoked": "Mazaya Access",
"mazayaAccessRevokedDesc": "You are not authorized to access the Mazaya Program.", "mazayaAccessRevokedDesc": "You are not authorized to access the Mazaya Program.",
"contactYourSponsor": "Contact your sponsor", "contactYourSponsor": "Contact your sponsor",
"contactYourSponsorDesc": "Ask your sponsor to allow Mazaya access again from Dependent Details. Only the sponsor can restore access.", "contactYourSponsorDesc": "Ask your sponsor to allow Mazaya access again from Dependent Details. Only the sponsor can restore access.",

@ -1,6 +1,7 @@
import 'dart:async'; import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:mohem_flutter_app/api/api_client.dart'; import 'package:mohem_flutter_app/api/api_client.dart';
@ -114,23 +115,50 @@ class LoginApiClient {
} }
Future<GenericResponseModel?> insertMobileLoginInfoNEW( Future<GenericResponseModel?> insertMobileLoginInfoNEW(
String email, int sessionId, String employeeName, int loginType, String mobileNumber, String userName, String deviceToken, String deviceType, String email, int sessionId, String employeeName, int loginType, String mobileNumber, String userName, String? deviceToken, String deviceType,
{int? memberType}) async { {int? memberType}) async {
String url = "${ApiConsts.erpRest}Mohemm_InsertMobileLoginInfo"; String url = "${ApiConsts.erpRest}Mohemm_InsertMobileLoginInfo";
String devType = deviceType.isNotEmpty ? deviceType : (Platform.isAndroid ? "android" : "ios");
String devToken = (deviceToken != null && deviceToken.isNotEmpty && deviceToken != "null")
? deviceToken
: (AppState().getIsHuawei ? AppState().getHuaweiPushToken : (AppState().getDeviceToken ?? ""));
if (devToken.isEmpty || devToken == "null") {
try {
String savedToken = await Utils.getStringFromPrefs("P_DEP_DEVICE_TOKEN");
if (savedToken.isNotEmpty && savedToken != "null") {
devToken = savedToken;
}
} catch (_) {}
}
if (devToken.isEmpty || devToken == "null") {
try {
if (!AppState().getIsHuawei) {
String? tok = await FirebaseMessaging.instance.getToken();
if (tok != null && tok.isNotEmpty) {
devToken = tok;
AppState().setDeviceToken = tok;
Utils.saveStringFromPrefs("P_DEP_DEVICE_TOKEN", tok);
}
}
} catch (_) {}
}
Map<String, dynamic> postParams = { Map<String, dynamic> postParams = {
"MobileNumber": mobileNumber, "MobileNumber": mobileNumber,
"P_USER_NAME": userName, "P_USER_NAME": userName,
"UserName": userName, "UserName": userName,
"CompanyID": 1, // todo 'sikander' @discuss umer for companyID "CompanyID": 1, // todo 'sikander' @discuss umer for companyID
"DeviceToken": deviceToken, "DeviceToken": devToken,
"LoginType": loginType, "LoginType": loginType,
"EmployeeName": employeeName, "EmployeeName": employeeName,
"P_SESSION_ID": sessionId, "P_SESSION_ID": sessionId,
"P_EMAIL_ADDRESS": email, "P_EMAIL_ADDRESS": email,
"MemberType": memberType ?? ApiConsts.selectedMemberType.value, "MemberType": memberType ?? ApiConsts.selectedMemberType.value,
}; };
postParams["DeviceToken"] = deviceToken; postParams["DeviceToken"] = devToken;
postParams["DeviceType"] = deviceType; postParams["DeviceType"] = devType;
postParams.addAll(AppState().postParamsJson); postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject((json) {
GenericResponseModel? responseData = GenericResponseModel.fromJson(json); GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
@ -159,10 +187,32 @@ class LoginApiClient {
}) async { }) async {
String url = "${ApiConsts.erpRest}Mohemm_InsertMobileLoginInfo_Dependent"; String url = "${ApiConsts.erpRest}Mohemm_InsertMobileLoginInfo_Dependent";
String devType = deviceType ?? (Platform.isAndroid ? "android" : "ios"); String devType = deviceType ?? (Platform.isAndroid ? "android" : "ios");
String devToken = (deviceToken != null && deviceToken.isNotEmpty) String devToken = (deviceToken != null && deviceToken.isNotEmpty && deviceToken != "null")
? deviceToken ? deviceToken
: (AppState().getIsHuawei ? AppState().getHuaweiPushToken : (AppState().getDeviceToken ?? "")); : (AppState().getIsHuawei ? AppState().getHuaweiPushToken : (AppState().getDeviceToken ?? ""));
if (devToken.isEmpty || devToken == "null") {
try {
String savedToken = await Utils.getStringFromPrefs("P_DEP_DEVICE_TOKEN");
if (savedToken.isNotEmpty && savedToken != "null") {
devToken = savedToken;
}
} catch (_) {}
}
if (devToken.isEmpty || devToken == "null") {
try {
if (!AppState().getIsHuawei) {
String? tok = await FirebaseMessaging.instance.getToken();
if (tok != null && tok.isNotEmpty) {
devToken = tok;
AppState().setDeviceToken = tok;
Utils.saveStringFromPrefs("P_DEP_DEVICE_TOKEN", tok);
}
}
} catch (_) {}
}
String effectiveToken = (tokenID != null && tokenID.isNotEmpty) String effectiveToken = (tokenID != null && tokenID.isNotEmpty)
? tokenID ? tokenID
: (AppState().postParamsObject?.tokenID ?? AppState().authenticationTokenID ?? ""); : (AppState().postParamsObject?.tokenID ?? AppState().authenticationTokenID ?? "");

@ -104,7 +104,17 @@ class _DashboardScreenForDependetState extends State<DashboardScreenForDependet>
} }
int sessionId = AppState().postParamsObject?.pSessionId ?? 0; int sessionId = AppState().postParamsObject?.pSessionId ?? 0;
String email = AppState().postParamsObject?.pEmailAddress ?? ""; String email = AppState().postParamsObject?.pEmailAddress ?? "";
String deviceToken = AppState().getIsHuawei ? AppState().getHuaweiPushToken : (AppState().getDeviceToken ?? ""); String deviceToken = AppState().getIsHuawei
? AppState().getHuaweiPushToken
: ((AppState().getDeviceToken != null && AppState().getDeviceToken!.isNotEmpty && AppState().getDeviceToken != "null")
? AppState().getDeviceToken!
: "");
if (deviceToken.isEmpty || deviceToken == "null") {
String savedToken = await Utils.getStringFromPrefs("P_DEP_DEVICE_TOKEN");
if (savedToken.isNotEmpty && savedToken != "null") {
deviceToken = savedToken;
}
}
await LoginApiClient().insertMobileLoginInfoDependent( await LoginApiClient().insertMobileLoginInfoDependent(
loginType: loginType, loginType: loginType,

@ -405,10 +405,26 @@ class _LoginScreenState extends State<LoginScreen> {
AppState().setMohemmWifiPassword = mohemmWifiPassword; AppState().setMohemmWifiPassword = mohemmWifiPassword;
} }
Utils.hideLoading(context); Utils.hideLoading(context);
if (firebaseToken == null || firebaseToken!.isEmpty || firebaseToken == "null") {
if (AppState().getDeviceToken != null && AppState().getDeviceToken!.isNotEmpty && AppState().getDeviceToken != "null") {
firebaseToken = AppState().getDeviceToken;
} else {
String saved = await Utils.getStringFromPrefs("P_DEP_DEVICE_TOKEN");
if (saved.isNotEmpty && saved != "null") {
firebaseToken = saved;
}
}
}
String effectiveTokenArg = (firebaseToken != null && firebaseToken!.isNotEmpty && firebaseToken != "null")
? firebaseToken!
: (AppState().getDeviceToken ?? "");
if (_autoLogin && loginInfo != null) { if (_autoLogin && loginInfo != null) {
if (loginInfo!.deviceToken == null || loginInfo!.deviceToken!.isEmpty || loginInfo!.deviceToken == "null") {
loginInfo!.deviceToken = effectiveTokenArg;
}
Navigator.pushReplacementNamed(context, AppRoutes.verifyLastLogin, arguments: loginInfo); Navigator.pushReplacementNamed(context, AppRoutes.verifyLastLogin, arguments: loginInfo);
} else { } else {
Navigator.pushNamed(context, AppRoutes.verifyLogin, arguments: "$firebaseToken"); Navigator.pushNamed(context, AppRoutes.verifyLogin, arguments: effectiveTokenArg);
} }
Utils.saveStringFromPrefs(SharedPrefsConsts.password, password.text); Utils.saveStringFromPrefs(SharedPrefsConsts.password, password.text);
} catch (ex) { } catch (ex) {
@ -969,7 +985,14 @@ class _LoginScreenState extends State<LoginScreen> {
if (checkOtpResponse?.authenticationTokenID != null && checkOtpResponse!.authenticationTokenID!.trim().isNotEmpty) { if (checkOtpResponse?.authenticationTokenID != null && checkOtpResponse!.authenticationTokenID!.trim().isNotEmpty) {
Utils.saveStringFromPrefs("P_DEP_AUTHENTICATION_TOKEN_ID", checkOtpResponse.authenticationTokenID!.trim()); Utils.saveStringFromPrefs("P_DEP_AUTHENTICATION_TOKEN_ID", checkOtpResponse.authenticationTokenID!.trim());
} }
Utils.saveStringFromPrefs("P_DEP_DEVICE_TOKEN", AppState().getIsHuawei ? AppState().getHuaweiPushToken : firebaseToken ?? ""); String tokenToSave = AppState().getIsHuawei
? AppState().getHuaweiPushToken
: ((firebaseToken != null && firebaseToken!.isNotEmpty && firebaseToken != "null")
? firebaseToken!
: (AppState().getDeviceToken ?? ""));
if (tokenToSave.isNotEmpty && tokenToSave != "null") {
Utils.saveStringFromPrefs("P_DEP_DEVICE_TOKEN", tokenToSave);
}
Utils.saveStringFromPrefs("P_DEP_LOGIN_TYPE", loginType.toString()); Utils.saveStringFromPrefs("P_DEP_LOGIN_TYPE", loginType.toString());
if (navigateToDashboard && ApiConsts.ISDependetLogin) { if (navigateToDashboard && ApiConsts.ISDependetLogin) {
@ -977,6 +1000,30 @@ class _LoginScreenState extends State<LoginScreen> {
} }
} }
void _ensureDeviceTokenLoaded() async {
if (firebaseToken == null || firebaseToken!.isEmpty || firebaseToken == "null") {
if (AppState().getDeviceToken != null && AppState().getDeviceToken!.isNotEmpty && AppState().getDeviceToken != "null") {
firebaseToken = AppState().getDeviceToken;
} else {
String saved = await Utils.getStringFromPrefs("P_DEP_DEVICE_TOKEN");
if (saved.isNotEmpty && saved != "null") {
firebaseToken = saved;
AppState().setDeviceToken = saved;
} else if (!AppState().getIsHuawei) {
try {
await Firebase.initializeApp();
String? tok = await FirebaseMessaging.instance.getToken();
if (tok != null && tok.isNotEmpty) {
firebaseToken = tok;
AppState().setDeviceToken = tok;
Utils.saveStringFromPrefs("P_DEP_DEVICE_TOKEN", tok);
}
} catch (_) {}
}
}
}
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (isAppOpenBySystem == null) { if (isAppOpenBySystem == null) {
@ -992,7 +1039,11 @@ class _LoginScreenState extends State<LoginScreen> {
// 13777 // 13777
// Ab12345cd // Ab12345cd
} }
if (isAppOpenBySystem!) checkFirebaseToken(); if (isAppOpenBySystem!) {
checkFirebaseToken();
} else {
_ensureDeviceTokenLoaded();
}
} }
// username.text = "15444"; // username.text = "15444";
@ -1013,10 +1064,12 @@ class _LoginScreenState extends State<LoginScreen> {
children: [ children: [
LocaleKeys.english.tr().toText14(color: AppState().isArabic(context) ? null : MyColors.textMixColor).onPress(() { LocaleKeys.english.tr().toText14(color: AppState().isArabic(context) ? null : MyColors.textMixColor).onPress(() {
context.setLocale(const Locale("en", "US")); context.setLocale(const Locale("en", "US"));
_ensureDeviceTokenLoaded();
}), }),
Container(width: 1, color: MyColors.darkWhiteColor, height: 16, margin: const EdgeInsets.only(left: 10, right: 10)), Container(width: 1, color: MyColors.darkWhiteColor, height: 16, margin: const EdgeInsets.only(left: 10, right: 10)),
LocaleKeys.arabic.tr().toText14(color: !AppState().isArabic(context) ? null : MyColors.textMixColor).onPress(() { LocaleKeys.arabic.tr().toText14(color: !AppState().isArabic(context) ? null : MyColors.textMixColor).onPress(() {
context.setLocale(const Locale("ar", "SA")); context.setLocale(const Locale("ar", "SA"));
_ensureDeviceTokenLoaded();
}), }),
], ],
), ),

@ -388,6 +388,11 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
Future<void> performDirectApiCall(String _title, String _icon, int _flag, String value, TextEditingController? _pinPutController, {bool isDirectLogin = false}) async { Future<void> performDirectApiCall(String _title, String _icon, int _flag, String value, TextEditingController? _pinPutController, {bool isDirectLogin = false}) async {
try { try {
GenericResponseModel? genericResponseModel = await LoginApiClient().checkActivationCode(true, AppState().memberLoginList?.pMOBILENUMBER, value, AppState().getUserName); GenericResponseModel? genericResponseModel = await LoginApiClient().checkActivationCode(true, AppState().memberLoginList?.pMOBILENUMBER, value, AppState().getUserName);
String devToken = AppState().getIsHuawei
? AppState().getHuaweiPushToken
: ((mobileLoginInfoListModel?.deviceToken != null && mobileLoginInfoListModel!.deviceToken!.isNotEmpty && mobileLoginInfoListModel!.deviceToken != "null")
? mobileLoginInfoListModel!.deviceToken!
: (AppState().getDeviceToken ?? ""));
GenericResponseModel? genericResponseModel1 = await LoginApiClient().insertMobileLoginInfoNEW( GenericResponseModel? genericResponseModel1 = await LoginApiClient().insertMobileLoginInfoNEW(
AppState().memberLoginList?.pEMAILADDRESS ?? "", AppState().memberLoginList?.pEMAILADDRESS ?? "",
genericResponseModel?.pSESSIONID ?? 0, genericResponseModel?.pSESSIONID ?? 0,
@ -395,7 +400,7 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
_flag, _flag,
AppState().memberLoginList?.pMOBILENUMBER ?? "", AppState().memberLoginList?.pMOBILENUMBER ?? "",
AppState().getUserName!, AppState().getUserName!,
AppState().getIsHuawei ? AppState().getHuaweiPushToken : (mobileLoginInfoListModel?.deviceToken ?? AppState().getDeviceToken ?? ""), devToken,
Platform.isAndroid ? "android" : "ios", Platform.isAndroid ? "android" : "ios",
memberType: MemberType.employee.value, memberType: MemberType.employee.value,
); );

@ -55,7 +55,18 @@ class _VerifyLoginScreenState extends State<VerifyLoginScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
firebaseToken ??= ModalRoute.of(context)!.settings.arguments as String; Object? rawArg = ModalRoute.of(context)?.settings.arguments;
if (rawArg != null) {
String argStr = rawArg.toString().trim();
if (argStr.isNotEmpty && argStr != "null") {
firebaseToken ??= argStr;
}
}
if (firebaseToken == null || firebaseToken!.isEmpty || firebaseToken == "null") {
if (AppState().getDeviceToken != null && AppState().getDeviceToken!.isNotEmpty && AppState().getDeviceToken != "null") {
firebaseToken = AppState().getDeviceToken;
}
}
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
@ -642,6 +653,11 @@ class _VerifyLoginScreenState extends State<VerifyLoginScreen> {
Utils.showLoading(context); Utils.showLoading(context);
try { try {
GenericResponseModel? genericResponseModel = await LoginApiClient().checkActivationCode(true, AppState().memberLoginList?.pMOBILENUMBER, value, AppState().getUserName); GenericResponseModel? genericResponseModel = await LoginApiClient().checkActivationCode(true, AppState().memberLoginList?.pMOBILENUMBER, value, AppState().getUserName);
String devToken = AppState().getIsHuawei
? AppState().getHuaweiPushToken
: ((firebaseToken != null && firebaseToken!.isNotEmpty && firebaseToken != "null")
? firebaseToken!
: (AppState().getDeviceToken ?? ""));
GenericResponseModel? genericResponseModel1 = await LoginApiClient().insertMobileLoginInfoNEW( GenericResponseModel? genericResponseModel1 = await LoginApiClient().insertMobileLoginInfoNEW(
AppState().memberLoginList?.pEMAILADDRESS ?? "", AppState().memberLoginList?.pEMAILADDRESS ?? "",
genericResponseModel?.pSESSIONID ?? 0, genericResponseModel?.pSESSIONID ?? 0,
@ -649,7 +665,7 @@ class _VerifyLoginScreenState extends State<VerifyLoginScreen> {
_flag, _flag,
AppState().memberLoginList?.pMOBILENUMBER ?? "", AppState().memberLoginList?.pMOBILENUMBER ?? "",
AppState().getUserName!, AppState().getUserName!,
AppState().getIsHuawei ? AppState().getHuaweiPushToken : firebaseToken!, devToken,
Platform.isAndroid ? "android" : "ios", Platform.isAndroid ? "android" : "ios",
memberType: MemberType.employee.value); memberType: MemberType.employee.value);
if (genericResponseModel?.errorMessage != null) { if (genericResponseModel?.errorMessage != null) {

@ -866,21 +866,21 @@ class _AddDependentVerifyScreenState extends State<AddDependentVerifyScreen> {
} }
} }
// 14. Ticket / Education / Medical Insurance Eligibility // 14. Ticket / Education / Medical Insurance Eligibility
else if (prompt.contains('ticket') || colName.contains('TICKET') || // else if (prompt.contains('ticket') || colName.contains('TICKET') ||
prompt.contains('education') || colName.contains('EDU') || // prompt.contains('education') || colName.contains('EDU') ||
prompt.contains('insurance') || colName.contains('MED')) { // prompt.contains('insurance') || colName.contains('MED')) {
if (eServices != null && eServices.isNotEmpty) { // if (eServices != null && eServices.isNotEmpty) {
for (var opt in eServices) { // for (var opt in eServices) {
String valCol = (opt.vALUECOLUMNNAME ?? '').toLowerCase(); // String valCol = (opt.vALUECOLUMNNAME ?? '').toLowerCase();
String idCol = (opt.iDCOLUMNNAME ?? '').toUpperCase(); // String idCol = (opt.iDCOLUMNNAME ?? '').toUpperCase();
if (idCol == 'Y' || valCol.contains('eligible') || valCol.contains('مؤهل') || valCol.contains('نعم') || valCol.contains('yes')) { // if (idCol == '' || valCol.contains('eligible') || valCol.contains('مؤهل') || valCol.contains('نعم') || valCol.contains('yes')) {
details.sEGMENTVALUEDSP = opt.vALUECOLUMNNAME; // details.sEGMENTVALUEDSP = opt.vALUECOLUMNNAME;
details.vARCHAR2VALUE = opt.iDCOLUMNNAME; // details.vARCHAR2VALUE = opt.iDCOLUMNNAME;
break; // break;
} // }
} // }
} //}
} // }
// 15. Relationship Start Date // 15. Relationship Start Date
else if (prompt.contains('start') || colName.contains('DATE_START') || colName.contains('START_DATE')) { else if (prompt.contains('start') || colName.contains('DATE_START') || colName.contains('START_DATE')) {
String startVal = ymdDob.isNotEmpty ? ymdDob : DateFormat('yyyy-MM-dd').format(DateTime.now()); String startVal = ymdDob.isNotEmpty ? ymdDob : DateFormat('yyyy-MM-dd').format(DateTime.now());

Loading…
Cancel
Save