NFC fixes

faiz_marathon_signalR_critical
haroon amjad 2 years ago
parent eb29553d26
commit e6405b2251

@ -67,5 +67,9 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>com.apple.developer.nfc.readersession.felica.systemcodes</key>
<array>
<string>0000</string>
</array>
</dict>
</plist>

@ -1,7 +1,7 @@
class ApiConsts {
//static String baseUrl = "http://10.200.204.20:2801/"; // Local server
static String baseUrl = "https://uat.hmgwebservices.com"; // UAT server
// static String baseUrl = "https://hmgwebservices.com"; // Live server
// static String baseUrl = "https://uat.hmgwebservices.com"; // UAT server
static String baseUrl = "https://hmgwebservices.com"; // Live server
static String baseUrlServices = baseUrl + "/Services/"; // server
// static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server
static String utilitiesRest = baseUrlServices + "Utilities.svc/REST/";

@ -158,16 +158,19 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
bool isConnected =
await WiFiForIoTPlugin.connect(AppState().getMohemmWifiSSID ?? "", password: AppState().getMohemmWifiPassword ?? "", joinOnce: true, security: NetworkSecurity.WPA, withInternet: false);
if (isConnected) {
Utils.showLoading(context);
await WiFiForIoTPlugin.forceWifiUsage(true);
Utils.showLoading(context);
await Future.delayed(Duration(seconds: 1));
try {
GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 3, nfcValue: "", isGpsRequired: isWifiLocationEnabled, lat: lat, long: lng);
bool status = await model.fetchAttendanceTracking(context);
Utils.hideLoading(context);
await closeWifiRequest();
// await closeWifiRequest();
} catch (ex) {
await closeWifiRequest();
print("performWifiAttendance: "+ex.toString());
// await closeWifiRequest();
Utils.hideLoading(context);
Utils.handleException(ex, context, (msg) {
Utils.confirmDialog(context, msg);
@ -179,7 +182,8 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
}
Future<bool> closeWifiRequest() async {
await WiFiForIoTPlugin.forceWifiUsage(false);
// await WiFiForIoTPlugin.forceWifiUsage(false);
// Future.delayed(Duration(seconds: 2));
return await WiFiForIoTPlugin.disconnect();
}

@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:nfc_manager/nfc_manager.dart';
@ -41,9 +42,13 @@ class _NfcLayoutState extends State<NfcLayout> {
NfcManager.instance.startSession(onDiscovered: (NfcTag tag) async {
print(tag.data);
var f = MifareUltralight(tag: tag, identifier: tag.data["nfca"]["identifier"], type: 2, maxTransceiveLength: 252, timeout: 22);
var f;
if (Platform.isAndroid) {
f = MifareUltralight(tag: tag, identifier: tag.data["nfca"]["identifier"], type: 2, maxTransceiveLength: 252, timeout: 22);
} else {
f = MifareUltralight(tag: tag, identifier: tag.data["mifare"]["identifier"], type: 2, maxTransceiveLength: 252, timeout: 22);
}
String identifier = f.identifier.map((e) => e.toRadixString(16).padLeft(2, '0')).join('');
// print(identifier); // => 0428fcf2255e81
nfcId = identifier;
setState(() {
@ -54,6 +59,12 @@ class _NfcLayoutState extends State<NfcLayout> {
Future.delayed(const Duration(seconds: 1), () {
NfcManager.instance.stopSession();
Navigator.pop(context);
// if (Platform.isAndroid) {
// Navigator.pop(context);
// } else {
// Navigator.pop(context);
// Navigator.pop(context);
// }
widget.onNcfScan(nfcId);
});
}).catchError((err) {

Loading…
Cancel
Save