Notifications dont work on SDK 33 Android 13 after upgrading from SDK 31 – Android

by
Ali Hasan
android android-notifications apple-push-notifications ionic-framework

The Problem:

After upgrading from SDK 31 to 33, notifications ceased functioning in Android 13, although the necessary permissions were added to the Android Manifest. The requestPermission() method returns false without displaying a permission dialog for local notifications, while returning true without displaying a permission dialog for FCM notifications.

The Solutions:

Solution 2: Add necessary permission

To resolve the issue, you need to add the necessary permission to your Android manifest file:

<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

This permission allows your app to display notifications to the user.

Once you have added the permission, you need to request the user to grant it at runtime. You can do this by calling the requestPermission() method on the NotificationManager class.

For example:

NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.requestPermission(this);

This will display a dialog to the user asking them if they want to grant your app permission to display notifications. If the user grants permission, your app will be able to display notifications normally.

Q&A

Solution to handle notification permission for android version 13?

Add ‘android.permission.POST_NOTIFICATIONS’ to manifest and request permission at runtime.

What caused the notification to not work on Android 13?

Outdated permissions library not including new permission required.

Video Explanation:

The following video, titled "Migrate your apps to Android 13 - YouTube", provides additional insights and in-depth exploration related to the topics discussed in this post.

Play video

... when you target the new SDK version, while others — mostly involving ... Android 13 (Runtime Permission of Notification) 'How bad is it'. 16 ...