Normal Notification Builder doesn't show notifications on Android O.
How could I show notification on Android 8 Oreo?
Is there any new piece of code to add for showing notification on Android O?
Normal Notification Builder doesn't show notifications on Android O.
How could I show notification on Android 8 Oreo?
Is there any new piece of code to add for showing notification on Android O?
Following method will show Notification, having big text and freeze enabled( Notification will not get removed even after user swipes ). We need NotificationManager service
Method to Remove Notifications
Source Link
In addition to this answer, you need to create the notification channel before it can be used.
Also you need to use channels only if your targetSdkVersion is 26 or higher.
If you are using NotificationCompat.Builder, you also need to update to the beta version of the support library: https://developer.android.com/topic/libraries/support-library/revisions.html#26-0-0-beta2 (to be able to call
setChannelId
on the compat builder).Be careful as this library update raises minSdkLevel to 14.
If you can't get the push notification in 26+ SDK version?
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, channel_id)
-> Here you will get push notification using
channel_id
in your device which is consist 26+ SDK version.-> Because, the
NotificationCompat.Builder(context)
is deprecated method now you will use an updated version which is having two parameters one is context, other is channel_id.->
NotificationCompat.Builder(context, channel_id)
updated method. try it.-> In 26+ SDK version of device you will create channel_id every time.
Here's how you do it
Read full tutorial at => https://developer.android.com/training/notify-user/build-notification
For anyone struggling with this after trying the above solutions, ensure that the channel id used when creating the notification channel is identical to the channel id you set in the Notification builder.