firebase-admin-dotnet icon indicating copy to clipboard operation
firebase-admin-dotnet copied to clipboard

Android Notification when phone is closed/screen turned of

Open Light407 opened this issue 1 year ago • 2 comments

We're having the problem that the notifications always gets delivered for both iOS and Android but on Android there is no sound/display/vibration when the notification is received. Oddly enough it is working on a very old Android phone we are testing with but with newer phones the notification just gets "silently" delivered i.e. shows up in the Android navbar but the user doesn't see/hear it unless opening the screen.

Could somebody somebody who has Android notifications working (with sound/vibration/screen popup) share payload/snippet of what is being sent to make this work? We're using .NET Framework 4.8

Light407 avatar Nov 21 '24 02:11 Light407

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

google-oss-bot avatar Nov 21 '24 02:11 google-oss-bot

Hi, just a guess - don't forget to grant notification permission for newer androids. Checking code in Java:

public static boolean CheckIfHaveNotificationPermission()
{
    // This is only necessary for API level >= 33 (TIRAMISU)
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU)
    {
        if (ContextCompat.checkSelfPermission(MyApplication.getContext(), Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED)
            return false;
    }

    return true;
}

alexeygritsenko avatar Dec 04 '24 20:12 alexeygritsenko