DEV Community

Chris Richmond
Chris Richmond

Posted on

1

Register for Notifications on Android SDK 33

Problem: Notifications are not being received after upgrading to Android SDK 33.

Solution: In Android SDK 33 you now have to request permissions to display Notifications. Asking for POST_NOTIFICATIONS alone wasn't sufficient, and some of these maybe overkill but this is what worked for me.

To get the notifications permission, you need to first request permission for the following items:

private string[] PermissionsForNotifications =
            {
                Manifest.Permission.ReceiveBootCompleted,
                Manifest.Permission.WakeLock,
                Manifest.Permission.Vibrate,
                Manifest.Permission.Internet,
                Manifest.Permission.AccessNetworkState,
                Manifest.Permission.PostNotifications,
                Manifest.Permission.ForegroundService,
                "com.google.android.c2dm.permission.RECEIVE",                "com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE",                "android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS",
                "android.permission.REQUEST_COMPANION_RUN_IN_BACKGROUND"
            };
Enter fullscreen mode Exit fullscreen mode

When calling the registration it seemed the Channel ID was also required.

private int RequestNotificationId = 1000;
ActivityCompat.RequestPermissions(CurrentActivity, PermissionsForNotifications, RequestNotificationId);
Enter fullscreen mode Exit fullscreen mode

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay