Share via

.net MAUI asks for SMS.RECEIVE forcibly permission on SMS permission

Ertan 41 Reputation points
Feb 19, 2023, 8:48 AM

Duplicate: https://github.com/dotnet/maui/issues/13446

Hello,

I'm moving my application that I wrote on a different platform to .NET MAUI and while installing this application, SEND_SMS permission was obtained and my application was published.

But I finished my application and in the background I added SMS.SEND to AndroidManifest on android, but when I try to send SMS it asks me to add android.permission.RECEIVE_SMS permission to AndroidManifest.

But my app is not doing any reading.

My app update was denied by PLAY STORE because it requested android.permission.RECEIVE_SMS as an additional permission.

What should I do so that it doesn't ask for the RECEIVE_SMS permission?

User's image

My code is like this:

   public void sendSMS(String phoneNumber, String message)
    {
        // Get the SMS manager
        SmsManager smsManager = SmsManager.Default;
        // Split text message content (SMS length limit)
        IList<string> divideContents = smsManager.DivideMessage(message);
        foreach (string text in divideContents)
        {
            smsManager.SendTextMessage(phoneNumber, null, text, null, null);
        }
    }

{Microsoft.Maui.ApplicationModel.PermissionException: You need to declare using the permission: `android.permission.RECEIVE_SMS` in your AndroidManifest.xml
   at Microsoft.Maui.ApplicationModel.Permissions.BasePlatformPermission.CheckStatusAsync() in D:\a\_work\1\s\src\Essentials\src\Permissions\Permissions.android.cs:line 62
   at Microsoft.Maui.ApplicationModel.Permissions.CheckStatusAsync[Sms]() in D:\a\_work\1\s\src\Essentials\src\Permissions\Permissions.shared.cs:line 10
   at App.MainPage.SMS_Send_Check() in C:\Users\App\Desktop\App\App\App\MainPage.xaml.cs:line 110}
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
4,039 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.