Share via

This call site is reachable on: 'Android' 31.0 and later. 'Manifest.Permission.PostNotifications' is only supported on: 'android' 33.0 and later.

Kim Strasser 2,641 Reputation points
2026-06-09T07:34:48+00:00

I get this warning in Game1.cs in my SharedCode project. Is it necessary to change something?

This call site is reachable on: 'Android' 31.0 and later. 'Manifest.Permission.PostNotifications' is only supported on: 'android' 33.0 and later.

#if ANDROID
                if (AndroidX.Core.App.ActivityCompat.CheckSelfPermission(Android.App.Application.Context, Android.Manifest.Permission.PostNotifications) != Android.Content.PM.Permission.Granted)
                    Pushnotactiveinsettings = false;
                else
                    Pushnotactiveinsettings = true;

Screenshot 2026-06-02 173657

Developer technologies | .NET | .NET Multi-platform App UI

2 answers

Sort by: Most helpful
  1. Nancy Vo (WICLOUD CORPORATION) 5,700 Reputation points Microsoft External Staff Moderator
    2026-06-11T06:05:21.7033333+00:00

    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.

    Was this answer helpful?

    0 comments No comments

  2. AI answer

    2026-06-09T07:35:23.8966667+00:00

    The warning means that the code can run on devices with Android 31+, but Manifest.Permission.PostNotifications only exists starting from Android 33. On devices < 33 the API is not available, so the compiler warns that the call site is reachable on OS versions where this member does not exist.

    To keep the code and remove the warning, guard the permission check with a runtime API-level check so it only runs on Android 33+; for example:

    #if ANDROID
    var sdkInt = (int)Android.OS.BuildVersionCodes.S;
    
    if ((int)Android.OS.Build.VERSION.SdkInt >= 33)
    {
        // Only call PostNotifications on Android 13 (API 33) and later
        Pushnotactiveinsettings =
            AndroidX.Core.App.ActivityCompat.CheckSelfPermission(
                Android.App.Application.Context,
                Android.Manifest.Permission.PostNotifications) !=
            Android.Content.PM.Permission.Granted;
    }
    else
    {
        // On older versions this permission does not exist
        Pushnotactiveinsettings = true; // or whatever default is appropriate
    }
    #endif
    

    No change to the project’s Target OS or Supported OS versions is required; the important part is to ensure the code that references PostNotifications only executes on API 33+.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

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