Test Sim Binding APK
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kmobile/api/services/send_sms_service.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
@@ -12,7 +11,8 @@ class SmsVerificationHelper {
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text("Permission Required"),
|
||||
content: const Text("SMS and Phone permissions are required for device verification. Please enable them in your app settings to continue."),
|
||||
content: const Text(
|
||||
"SMS and Phone permissions are required for device verification. Please enable them in your app settings to continue."),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text("Cancel"),
|
||||
@@ -39,17 +39,24 @@ class SmsVerificationHelper {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text("It seems your device is restricting this app from sending SMS messages, which is required for verification. Please follow these steps to enable it:\n"),
|
||||
Text("1. Open your device Settings.", style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
Text(
|
||||
"It seems your device is restricting this app from sending SMS messages, which is required for verification. Please follow these steps to enable it:\n"),
|
||||
Text("1. Open your device Settings.",
|
||||
style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
Text("2. Go to 'Apps' or 'Apps & notifications'."),
|
||||
Text("3. Find and tap on this app ('KMobile')."),
|
||||
Text("4. Tap on the three dots (⋮) in the top right corner."),
|
||||
Text("5. Select 'Allow restricted settings' and confirm. This is crucial to allow SMS permission."),
|
||||
Text(
|
||||
"5. Select 'Allow restricted settings' and confirm. This is crucial to allow SMS permission."),
|
||||
Text("6. Now you have two options to allow SMS permission:"),
|
||||
Text(" a. Tap on 'Permissions', then find 'SMS' is set to 'Allow'."),
|
||||
Text(" b. Alternatively, you can return to the KMobile app, and the SMS permission pop-up should appear again, allowing you to grant it directly."),
|
||||
Text("\nSome devices have an additional setting for 'Premium SMS'. If the above doesn't work, look for a 'Premium SMS access' setting (you can search for it in your Settings app) and set it to 'Always Allow' for this app.\n"),
|
||||
Text("After you've enabled the permission, please come back to the app."),
|
||||
Text(
|
||||
" a. Tap on 'Permissions', then find 'SMS' is set to 'Allow'."),
|
||||
Text(
|
||||
" b. Alternatively, you can return to the KMobile app, and the SMS permission pop-up should appear again, allowing you to grant it directly."),
|
||||
Text(
|
||||
"\nSome devices have an additional setting for 'Premium SMS'. If the above doesn't work, look for a 'Premium SMS access' setting (you can search for it in your Settings app) and set it to 'Always Allow' for this app.\n"),
|
||||
Text(
|
||||
"After you've enabled the permission, please come back to the app."),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -63,15 +70,6 @@ class SmsVerificationHelper {
|
||||
);
|
||||
}
|
||||
|
||||
void _showSnackBar(BuildContext context, String message) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(message),
|
||||
duration: const Duration(seconds: 3),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<String?> initiateSmsSequence({
|
||||
required BuildContext context,
|
||||
}) async {
|
||||
@@ -85,7 +83,9 @@ class SmsVerificationHelper {
|
||||
switch (status) {
|
||||
case PermissionStatusResult.granted:
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text("Permissions Granted! Proceeding..."), duration: Duration(seconds: 2)),
|
||||
const SnackBar(
|
||||
content: Text("Permissions Granted! Proceeding..."),
|
||||
duration: Duration(seconds: 2)),
|
||||
);
|
||||
hasPermission = true; // This will break the loop
|
||||
break;
|
||||
@@ -96,7 +96,8 @@ class SmsVerificationHelper {
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text("Permission Required"),
|
||||
content: const Text("This app requires SMS and Phone permissions to verify your device. Please grant the permissions to continue."),
|
||||
content: const Text(
|
||||
"This app requires SMS and Phone permissions to verify your device. Please grant the permissions to continue."),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text("Cancel"),
|
||||
@@ -136,9 +137,12 @@ class SmsVerificationHelper {
|
||||
var uuid = const Uuid();
|
||||
String uniqueId = uuid.v4();
|
||||
String smsMessage = uniqueId;
|
||||
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text("Attempting to send verification SMS... (${4 - retries})"), duration: const Duration(seconds: 2)),
|
||||
SnackBar(
|
||||
content:
|
||||
Text("Attempting to send verification SMS... (${4 - retries})"),
|
||||
duration: const Duration(seconds: 2)),
|
||||
);
|
||||
|
||||
bool isSmsSent = await _smsService.sendVerificationSms(
|
||||
@@ -148,21 +152,25 @@ class SmsVerificationHelper {
|
||||
);
|
||||
|
||||
if (isSmsSent) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text("SMS sent successfully!"), duration: Duration(seconds: 2)),
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text("SMS sent successfully!"),
|
||||
duration: Duration(seconds: 2)),
|
||||
);
|
||||
return uniqueId;
|
||||
} else {
|
||||
retries--;
|
||||
if (retries > 0) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text("SMS failed to send. Retrying in 5 seconds..."), duration: Duration(seconds: 4)),
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text("SMS failed to send. Retrying in 5 seconds..."),
|
||||
duration: Duration(seconds: 4)),
|
||||
);
|
||||
await Future.delayed(const Duration(seconds: 5));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// If all retries fail
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user