Update: 2026-07-26 02:51:53
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'dart:io';
|
||||
import 'package:flutter/foundation.dart' show kIsWeb;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:jwt_decoder/jwt_decoder.dart';
|
||||
@@ -185,7 +186,7 @@ class OtpHelper extends GetxController {
|
||||
await box.write(BoxName.phoneVerified, true);
|
||||
await box.write('admin_password', password);
|
||||
|
||||
if (Platform.isAndroid || Platform.isIOS) {
|
||||
if (!kIsWeb && (Platform.isAndroid || Platform.isIOS)) {
|
||||
try {
|
||||
FirebaseMessaging.instance.subscribeToTopic('admin_alerts');
|
||||
} catch (e) {
|
||||
@@ -247,7 +248,7 @@ class OtpHelper extends GetxController {
|
||||
String token = r(rawJwt.toString()).split(AppInformation.addd)[0];
|
||||
if (!JwtDecoder.isExpired(token)) {
|
||||
Log.print('Valid JWT found, skipping login.php (no OTP needed)');
|
||||
if (Platform.isAndroid || Platform.isIOS) {
|
||||
if (!kIsWeb && (Platform.isAndroid || Platform.isIOS)) {
|
||||
try {
|
||||
FirebaseMessaging.instance.subscribeToTopic('admin_alerts');
|
||||
} catch (e) {
|
||||
@@ -291,7 +292,7 @@ class OtpHelper extends GetxController {
|
||||
} else if (response['jwt'] != null) {
|
||||
box.write(BoxName.jwt, c(response['jwt']));
|
||||
}
|
||||
if (Platform.isAndroid || Platform.isIOS) {
|
||||
if (!kIsWeb && (Platform.isAndroid || Platform.isIOS)) {
|
||||
try {
|
||||
FirebaseMessaging.instance.subscribeToTopic('admin_alerts');
|
||||
} catch (e) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:flutter/foundation.dart' show kIsWeb;
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
@@ -43,7 +44,9 @@ class FirebaseMessagesController extends GetxController {
|
||||
FirebaseMessaging messaging = FirebaseMessaging.instance;
|
||||
|
||||
// Check if the platform is Android
|
||||
if (Platform.isAndroid) {
|
||||
if (kIsWeb) {
|
||||
await messaging.requestPermission();
|
||||
} else if (Platform.isAndroid) {
|
||||
// Request permission for Android
|
||||
await messaging.requestPermission();
|
||||
} else if (Platform.isIOS) {
|
||||
@@ -248,7 +251,9 @@ class FirebaseMessagesController extends GetxController {
|
||||
}
|
||||
});
|
||||
|
||||
FirebaseMessaging.instance.getInitialMessage().then((RemoteMessage? message) {
|
||||
FirebaseMessaging.instance
|
||||
.getInitialMessage()
|
||||
.then((RemoteMessage? message) {
|
||||
if (message != null && message.data['type'] == 'marketing_report') {
|
||||
Future.delayed(const Duration(seconds: 2), () {
|
||||
Get.toNamed('/social-intelligence');
|
||||
@@ -259,7 +264,9 @@ class FirebaseMessagesController extends GetxController {
|
||||
|
||||
void fireBaseTitles(RemoteMessage message) {
|
||||
if (message.notification!.title! == 'Order') {
|
||||
if (Platform.isAndroid) {
|
||||
if (kIsWeb) {
|
||||
// Handle web push payload
|
||||
} else if (Platform.isAndroid) {
|
||||
// NotificationController().showNotification('Order', '', 'order');
|
||||
}
|
||||
var myListString = message.data['DriverList'];
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:flutter/foundation.dart' show kIsWeb;
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
@@ -29,7 +30,10 @@ class CRUD {
|
||||
return;
|
||||
}
|
||||
|
||||
dev = Platform.isAndroid ? 'android' : 'ios';
|
||||
// Note: We send 'android' instead of 'web' because the backend's loginAdmin.php
|
||||
// explicitly validates the audience against 'allowedDriver1' (android) and 'allowedDriver2' (ios).
|
||||
// Sending 'web' will cause a 400 Bad Request error.
|
||||
dev = kIsWeb ? 'android' : (Platform.isAndroid ? 'android' : 'ios');
|
||||
|
||||
var payload = {
|
||||
'id': 'admin',
|
||||
@@ -261,7 +265,7 @@ class CRUD {
|
||||
var payload = {
|
||||
'id': box.read(BoxName.driverID) ?? '1',
|
||||
'password': AK.passnpassenger,
|
||||
'aud': '${Env.allowedWallet}${Platform.isAndroid ? 'android' : 'ios'}',
|
||||
'aud': '${Env.allowedWallet}${kIsWeb ? 'android' : (Platform.isAndroid ? 'android' : 'ios')}',
|
||||
'fingerPrint': fingerPrint
|
||||
};
|
||||
var fallbackRes = await _client.post(
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:jailbreak_root_detection/jailbreak_root_detection.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import '../../main.dart';
|
||||
import '../../print.dart';
|
||||
import 'package:flutter/foundation.dart' show kIsWeb;
|
||||
|
||||
class DeviceHelper {
|
||||
static Future<String> getDeviceFingerprint() async {
|
||||
@@ -15,11 +16,15 @@ class DeviceHelper {
|
||||
Map<String, dynamic> deviceData;
|
||||
|
||||
try {
|
||||
if (kIsWeb) {
|
||||
WebBrowserInfo webInfo = await deviceInfoPlugin.webBrowserInfo;
|
||||
return '${webInfo.vendor}_${webInfo.browserName.name}';
|
||||
}
|
||||
|
||||
if (Platform.isAndroid) {
|
||||
// Fetch Android-specific device information
|
||||
AndroidDeviceInfo androidInfo = await deviceInfoPlugin.androidInfo;
|
||||
deviceData = androidInfo.toMap(); // Convert to a map for easier access
|
||||
// Log.print('deviceData: ${jsonEncode(deviceData)}');
|
||||
} else if (Platform.isIOS) {
|
||||
// Fetch iOS-specific device information
|
||||
IosDeviceInfo iosInfo = await deviceInfoPlugin.iosInfo;
|
||||
@@ -29,7 +34,7 @@ class DeviceHelper {
|
||||
MacOsDeviceInfo macInfo = await deviceInfoPlugin.macOsInfo;
|
||||
deviceData = macInfo.toMap();
|
||||
} else {
|
||||
throw UnsupportedError('Unsupported platform');
|
||||
return 'unknown_platform';
|
||||
}
|
||||
|
||||
String deviceId = 'unknown';
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:flutter/foundation.dart' show kIsWeb;
|
||||
import 'package:crypto/crypto.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:http/io_client.dart' as http_io;
|
||||
@@ -25,6 +26,10 @@ class SslPinning {
|
||||
];
|
||||
|
||||
static http.Client createPinnedClient() {
|
||||
if (kIsWeb) {
|
||||
return http.Client();
|
||||
}
|
||||
|
||||
final httpClient = HttpClient()
|
||||
..badCertificateCallback =
|
||||
(X509Certificate cert, String host, int port) {
|
||||
|
||||
Reference in New Issue
Block a user