Limit Added to SMS enabled device

This commit is contained in:
2025-11-04 15:29:56 +05:30
parent 530e5c0493
commit 1ae3e7c0a6
12 changed files with 674 additions and 320 deletions

View File

@@ -23,6 +23,46 @@
_loadVersion();
_initiateSmsSequence();
}
Future<void> _showRestrictedSmsDialog() async {
await showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text("SMS Permission Restricted"),
content: const SingleChildScrollView(
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("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("6. Now you have two options to allow SMS permission:"),
Text(" a. Tap on 'Permissions', then find 'SMS' and ensure it's 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."),
],
),
),
actions: [
TextButton(
child: const Text("I've Enabled It"),
onPressed: () => Navigator.of(context).pop(),
),
TextButton(
child: const Text("Open Settings"),
onPressed: () {
openAppSettings();
Navigator.of(context).pop();
},
),
],
),
);
}
void _showSnackBar(String message) {
if (!mounted) return;
@@ -76,32 +116,13 @@
// Wait for user to return from settings
await Future.delayed(const Duration(seconds: 5));
break;
case PermissionStatusResult.restricted:
if (mounted) {
await showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text("Permission Restricted"),
content: const Text(
"SMS and Phone permissions are restricted on this device. Please check your device settings or parental controls and enable them for this app."),
actions: [
TextButton(
child: const Text("Cancel"),
onPressed: () => Navigator.of(context).pop(),
),
TextButton(
child: const Text("Open Settings"),
onPressed: () {
openAppSettings();
Navigator.of(context).pop();
},
),
],
),
);
}
await Future.delayed(const Duration(seconds: 5));
break;
case PermissionStatusResult.restricted:
if (mounted) {
await _showRestrictedSmsDialog();
}
// Wait for user to return from settings
await Future.delayed(const Duration(seconds: 10));
break;
}
}