Skip to content

SendSmsInBackground exception #118

@lpereira98

Description

@lpereira98

Bug Information

Version Number of Plugin: 5.2.0

Android Version: 11

Version of VS: 16.11.5

Version of Xamarin: 16.11


Hello, i'm very new to Xamarin development and I'm trying to send a background SMS.

my AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.helloworld" android:installLocation="preferExternal">
	<uses-permission android:name="android.permission.SEND_SMS" />
	<uses-permission android:name="android.permission.READ_SMS" />
	<uses-permission android:name="android.permission.RECEIVE_SMS" />
	<uses-permission android:name="android.permission.WRITE_SMS" />
	<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30" />
	<application android:label="HelloWorld.Android" android:theme="@style/MainTheme">
		<provider android:name="android.support.v4.content.FileProvider" android:authorities="HelloWorld.Android.fileprovider" android:exported="false" android:grantUriPermissions="true">
			<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"></meta-data>
		</provider>
	</application>
</manifest>

This code works but it doesn't send the SMS automatically.
Code:

            var smsMessenger = CrossMessaging.Current.SmsMessenger;
            if (smsMessenger.CanSendSms)
            {
                try
                {
                    smsMessenger.SendSms("+351xxxxxxxxx", "Well hello there from Xam.Messaging.Plugin");
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }

When i try to run this code, i get this Exception:
Untitled

The error clearly indicates that the tag android.permission.SEND_SMS isn't present, but it is .. and smsMessenger.SendSms works fine..
Sorry if this is a newbie question, but i would be much appreciated if you could help me :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions