A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
Hello @Kim Strasser ,
Thanks for your question.
Your app is reachable on API 31 and 32, but PostNotifications only exists from API 33 onwards. If a user on Android 12 or Android 12L runs your app, this code will cause a crash.
I recommend using OperatingSystem.IsAndroidVersionAtLeast(33) as the version guard around your PostNotifications code.
You can refer to the following example code:
#if ANDROID
if (OperatingSystem.IsAndroidVersionAtLeast(33))
{
if (AndroidX.Core.App.ActivityCompat.CheckSelfPermission(
Android.App.Application.Context,
Android.Manifest.Permission.PostNotifications)
!= Android.Content.PM.Permission.Granted)
{
Pushnotactiveinsettings = false;
}
else
{
Pushnotactiveinsettings = true;
}
}
else
{
Pushnotactiveinsettings = true;
}
#endif
I hope this addresses your question. If this response was helpful, please consider following the guidance to provide feedback.