Hello,
Welcome to our Microsoft Q&A platform!
Please register your SMSReceiver with explicit broadcast
like following code, I test it my pixel, it worked.
public class MainActivity : AppCompatActivity
{
SMSReceiver sMSReceiver;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.activity_main);
sMSReceiver= new SMSReceiver();
var intentFilter = new IntentFilter("android.provider.Telephony.SMS_RECEIVED");
intentFilter.Priority = 999;
RegisterReceiver(sMSReceiver, intentFilter);
}
protected override void OnDestroy()
{
base.OnDestroy();
UnregisterReceiver(sMSReceiver);
}
}
And please add and grand the runtime permission.
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.BROADCAST_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
And please let your application running in the foreground is better, if you make your application in the background, if you do not use foreground service, your application will be killed.
Best Regards,
Leon Lu
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our [documentation][1] to enable e-mail notifications if you want to receive the related email notification for this thread.
One of the devices is a pixel with vanilla Android yes.