New FCM notification was denied by the system


xiaotan828

Members
Nov 26, 2018
15
15
35809


I am using 21.3.31 on Mi 10 Pro. And FCM notification cannot be shown even FCM actually received and broadcasted the notification. This didn't happen in previous builds. And the China builds started to have this problem since two weeks ago, so it might be an issue from new restrictions in Chinese builds.
 
Quite simple cause of the issue:
Code:
    public static boolean isAllowLocalNotification(AppOpsManager appOpsManager, Notification notification, int uid, String pkg) {
        if ("com.xiaomi.xmsf".equals(pkg) || (notification.flags & Notification.FLAG_FOREGROUND_SERVICE) != 0 || appOpsManager.noteOpNoThrow(AppOpsManager.OP_POST_LOCAL_NOTIFICATION, uid, pkg) == 0) {
            return true;
        }
        Slog.i("NotificationService", "MIUILOG- Permission Denied to post local notification for " + pkg);
        return false;
    }
Posting local notifications by background services is not allowed by default.
Xiaomi has not added any code for controlling the AppOpsManager.OP_POST_LOCAL_NOTIFICATION operation in MIUI Permission Manager, it's not even mentioned there.
 
I am not exactly sure why I am having this issue so I am just guessing. The the thing I know is that I have exactly the same setting in EU 21.3.24 and 21.3.31, but issue occurs in the latter but not in the former.

I am gonna make it clearer:
EU 21.3.24:
App is able to auto-start when fcm push a notification to it, then the notification displays.

EU 21.3.31
App will still be able to auto-started when fcm push a notification to it, and the phone is able to vibrates due to the notification. but the notification cannot be display because it is denied as the #1 says

Both builds with auto-start permissions and other related notification permissions
 
Last edited:
The issue might not be about the NotificationService itself, but about changes to how the system handle the fcm notification. But in short, what is the correct or recommended setting in order to receive fcm notification?

The issue isn't solved with battery saver setting to no restriction and auto-start is enabled.
 
Could you please post your solution to the problem. I have a friend who does not receive notifications either
Hi, what I did was flashing the official EU ROM because I changed the EU ROM a bit and my issue was about this change.

If your friend is using an official EU ROM (downloaded from this forum), then my issue is nothing to do with your friend's. Then you should ask your friend to check if FCM has successfully broadcasted the notification. And whether auto-start for the app is switched on
 
  • Like
Reactions: Chilace