7

My Xamarin.Android app's push notification only works on Android 11 (Pixel 3 XL). Currently my app targets Android 11, however it also runs on Android 12 (Pixel 6 Pro). The only thing that is not working is Firebase push notifications. Below is the code that I am using. For the past week I have been researching the issue and saw posts about a specific issue with Android 12 (Pixel 6) not recieving push notifications. I performed changes to the phone configurations that others suggested and another app notification began to work, yet mine still has not. Any ideas would help.Thanks.

 if (Build.VERSION.SdkInt >= BuildVersionCodes.O)
            {
                // Notification channels are new in API 26 (and not a part of the
                // support library). There is no need to create a notification
                // channel on older versions of Android.


                var name = "NameOfChannel";
                var description = "Notification Channel";
                var channel = new NotificationChannel(CHANNEL_ID, name, NotificationImportance.Max)
                {
                    Description = description
                };

                var notificationManager = (NotificationManager)GetSystemService(NotificationService);
                notificationManager.CreateNotificationChannel(channel);

            }       
4
  • I am not sure what issue are you facing do you get an exception or is the notification not showing up...... Commented Feb 7, 2022 at 10:12
  • @FreakyAli when I send a test messge from firebase console to both Pixel 3 and Pixel 6 phones at the same time, only the Pixel 3 Android 11 recieved the message. There is not error that shows up on my logs for the Pixel 6 Android 12 phone. I have checked my code and FCM Token to make sure it is correct. Still nothing. Thanks. Commented Feb 7, 2022 at 15:10
  • Did you apply a breakpoint and check if you are receiving it at all? Commented Feb 8, 2022 at 5:29
  • As i know, Android 12 has some special on Network. You could get further help in the link below. github.com/xamarin/xamarin-android/issues Commented Feb 8, 2022 at 6:21

3 Answers 3

5

What I was missed is

PendingIntent.FLAG_IMMUTABLE

If Notification has pendingIntent then set mutable/immutable Flag to it

Sign up to request clarification or add additional context in comments.

Comments

4

Found the solution. Which was to add android:exported="false" on the Firebase service tag within the AndroidManifest.

3 Comments

What is the Firebase service tag? I'm not seeing anything like that in my AndroidManifest file and I'm having the same issue where Android 12 devices aren't getting push notifications
I already added exported="false" to FirebaseMessageService service but still hasn't received any notifications.
what does changing to false do?
4
               PendingIntent pendingIntent;
                if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.S)
                {
                pendingIntent=PendingIntent.getActivity(context,notificationId,notificationIntent,PendingIntent.FLAG_UPDATE_CURRENT|PendingIntent.FLAG_MUTABLE);
                }
                else
                {
                pendingIntent=PendingIntent.getActivity(context,notificationId,notificationIntent,PendingIntent.FLAG_UPDATE_CURRENT);
                }
                builder.setContentIntent(pendingIntent)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.