ssk-flutter / get_phone_number

BSD 3-Clause "New" or "Revised" License
2 stars 2 forks source link

Not working on Samsung Devices #21

Open hussainhabib2 opened 1 month ago

hussainhabib2 commented 1 month ago

Hi there, would like to report the issue happening on Samsung devices, the plugin works great on other real devices like Redmi, Oppo but not on Samsung, may I know the reason? Is there something extra I have to configure for it to work?

Future<void> getPhone() async {
    String phoneNumber = await GetPhoneNumber().get();

         _connectionStatus += "\nPhone number: $phoneNumber";

  }

Android manifest:

  <uses-permission android:name="android.permission.READ_SMS"/>
    <uses-permission android:name="android.permission.READ_PHONE_STATE"
                     android:maxSdkVersion="29" />
    <uses-permission android:name="android.permission.READ_PHONE_NUMBERS" />

Build.gradle:

defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.app"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdkVersion 21
        targetSdkVersion 34
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

Would appreciate prompt response

deviankim commented 1 month ago

Hi there,

Thank you for reporting the issue with Samsung devices. Based on the information provided, it seems there might not be an issue with your setup. Here are a few additional steps to help diagnose the problem:

  1. Check if permissions are permanently denied: Samsung devices might have custom permission management settings. Users might need to manually grant permissions in the device settings. Please ensure the permissions are not permanently denied. You can guide users to the app settings if permissions are permanently denied.

    import 'package:permission_handler/permission_handler.dart';
    
    Future<void> getPhone() async {
     var status = await Permission.phone.status;
     if (!status.isGranted) {
       await Permission.phone.request();
     }
    
     if (await Permission.phone.isGranted) {
       String phoneNumber = await GetPhoneNumber().get();
       _connectionStatus += "\nPhone number: $phoneNumber";
     } else {
       _connectionStatus += "\nPhone number permission not granted";
     }
    
     if (await Permission.phone.isPermanentlyDenied) {
       openAppSettings();
     }
    }
  2. Device and software information: Please provide the model of the Samsung device and the version of Android it is running. The issue might be specific to certain device models or software versions.

  3. Additional diagnostics: If possible, try running the app on another Samsung device or a different Android version to see if the issue persists. This can help determine if the problem is specific to a particular model or configuration.

To summarize, please:

I have tested the package on my own Samsung device and did not encounter any issues. This suggests the problem might be related to specific device settings or permissions. Your additional information will help us better understand and resolve the issue.

Thank you for your cooperation.