Skip to content

πŸ“£ πšƒπš‘πšŽ πš›πšŽπš™πš˜πšœπš’πšπš˜πš›πš’ πšπšŽπš–πš˜πš—πšœπšπš›πšŠπšπšŽπšœ πš‘πš˜πš  𝚝𝚘 𝚞𝚜𝚎 πš—πš˜πšπš’πšπš’πšŒπšŠπšπš’πš˜πš—πšœ πš’πš— πšŠπš•πš• πšŠπš—πšπš›πš˜πš’πš πšŸπšŽπš›πšœπš’πš˜πš—πšœ

License

Notifications You must be signed in to change notification settings

devrath/verbose-notification-channels

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

62 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

verbose-notification-channels πŸ§žβ€

π™Έπš—πšπš›πš˜πšπšžπšŒπšπš’πš˜πš— πŸ’‘

🏷️ This repository contains demonstrations on how to use notifications in android.
🏷️ Notifications are used to display a message outside the UI of the application. Each notification contains an option to add a action for it, which can be used to navigate into the application.

Banner

π™²πš˜πš—πšπšŽπš—πš
π™½πš˜πšπš’πšπš’πšŒπšŠπšπš’πš˜πš—πšœ πš‹πšŽπšπš˜πš›πšŽ π™Ύπš›πšŽπš˜
π™½πš˜πšπš’πšπš’πšŒπšŠπšπš’πš˜πš— πšŒπš‘πšŠπš—πš—πšŽπš• πš˜πš— π™Ύπš›πšŽπš˜ πšŠπš—πš π™·πš’πšπš‘πšŽπš›
πš†πš‘πšŠπš πš‘πšŠπš™πš™πšŽπš—πšœ πš πš‘πšŽπš— πšπš‘πšŽ 𝚌𝚘𝚍𝚎 𝚘𝚏 π™½πš˜πšπš’πšπš’πšŒπšŠπšπš’πš˜πš— πšŒπš‘πšŠπš—πš—πšŽπš•πšœ πš’πšœ πš’πš—πšŸπš˜πš”πšŽπš πš™πš›πš’πš˜πš› 𝚝𝚘 π™Ύπš›πšŽπš˜ πšπšŽπšŸπš’πšŒπšŽπšœ
π™·πš˜πš  πš—πš˜πšπš’πšπš’πšŒπšŠπšπš’πš˜πš—πšœ πš πš˜πš›πš”
π™Ύπšžπšπš™πšžπš 𝚘𝚏 πšπš‘πšŽ πšπšŽπš–πš˜
πš‚πšžπš™πš™πš˜πš›πš πšπš˜πš› πšŠπš—πšπš›πš˜πš’πš-𝟷𝟹

Notifications before Oreo

  • User could disable notifications per application basis and this was not useful for the user. If he ends up doing this, we would not be able to show any notifications at all.
  • Based on the channel we can make the user categorize the notifications.

Notification channel on Oreo and Higher

  • From Oreo which is API-26 displaying a notification became a little complex
  • Now we define a notification channel, purpose of using the notification channel is to give the user more control on notifications displayed and have access to the noise they make

What happens what the code of Notification channels are invoked prior to Oreo devices

  • There wont be any effect since the notification channels only work on oreo and higher versions.
  • There will not appear any crash as such.

How notifications work

blockdiagram

Output of demo

πš‚πš’πš–πš™πš•πšŽ πš—πš˜πšπš’πšπš’πšŒπšŠπšπš’πš˜πš— π™½πš˜πšπš’πšπš’πšŒπšŠπšπš’πš˜πš— πš πš’πšπš‘ 𝚊 πš‹πš’πš πš–πšŽπšœπšœπšŠπšπšŽ π™°πšπšπš’πš—πš πšŠπšŒπšπš’πš˜πš—
π™½πš˜πšπš’πšπš’πšŒπšŠπšπš’πš˜πš— πš πš’πšπš‘ πšπš›πš˜πšžπš™πš’πš—πš π™½πš˜πšπš’πšπš’πšŒπšŠπšπš’πš˜πš— πš πš’πšπš‘ πš’πš–πšŠπšπšŽ π™½πš˜πšπš’πšπš’πšŒπšŠπšπš’πš˜πš— πš πš’πšπš‘ πš™πš›πš˜πšπš›πšŽπšœπšœ
π™½πš˜πšπš’πšπš’πšŒπšŠπšπš’πš˜πš— πš πš’πšπš‘ πšŒπš‘πšŠπš πšŠπšŒπšπš’πš˜πš—

Support for android-13

π™±πšŠπšŒπš”πšπš›πš˜πšžπš—πš

  • There is a new change that android is bringing for android-13 which is also called Tiramisu and API-33 where there is a runtime permission, user has to approve before the notification has to be posted from a app in device.
  • This is different that the already existing permissions where user can turn on/off on per each notification channel.
  • Its protection level is marked dangerous ☣️

π™Όπš’πšπš›πšŠπšπš’πš˜πš— πš‹πšŽπš‘πšŠπšŸπš’πš˜πšžπš› πšπš›πš˜πš– πš™πš›πšŽ πšŠπš—πšπš›πš˜πš’πš-𝟷𝟹 𝚝𝚘 𝟷𝟹 πšŠπš—πš πšŠπš‹πš˜πšŸπšŽ ----> π™Άπš˜πš˜πšπš•πšŽ 𝚍𝚘𝚌 πš›πšŽπšπšŽπš›πšŽπš—πšŒπšŽ

π™±πšŽπšœπš πš™πš›πšŠπšŒπšπš’πšŒπšŽ πš˜πš— πš‘πš˜πš  𝚝𝚘 πšœπš‘πš˜πš  πšπš‘πšŽ πš›πšžπš—πšπš’πš–πšŽ πš™πšŽπš›πš–πš’πšœπšœπš’πš˜πš— ---> π™Άπš˜πš˜πšπš•πšŽ 𝚍𝚘𝚌 πš›πšŽπšπšŽπš›πšŽπš—πšŒπšŽ

π™Ύπš‹πšœπšŽπš›πšŸπšŠπšπš’πš˜πš—πšœ

π™²πš˜πš—πšπš’πšπš’πš˜πš— π™Ύπš‹πšœπšŽπš›πšŸπšŠπšπš’πš˜πš— π™Ύπšžπšπš™πšžπš
When the app is built with compile-SDK and target-SDK is API-31 which is android-12 also known as snow-clone 🏷️ When you run this on android-Pie which is API-28 device, no notification permission is displayed.
🏷️ We don't need to handle the runtime permission, instead just create the notification channels
When the app is built with compile-SDK and target-SDK is API-31 which is android-12 also known as snow-clone 🏷️ When you run this on android-13 which is API-33 device, even though we have not asked the app to display runtime permission, android device forcefully displays it if the code executes any lines that involve creation of channels.
🏷️ If the user approves it, application can post the notification.
🏷️ If the user denies it, this is dangerous since not only user will not be able to post notification also this dialog will never again unless you reinstall the app.
When the app is built with compile-SDK and target-SDK is API-33 which is android-13 also known as Tiramisu. After adding manifest permission and handeling the runtime permission 🏷️ Notifications appear only when the user approves the permission
🏷️ If the user dosen't approve it, the notifications will not appear.

π™²πš˜πš—πšπš›πš’πš‹πšžπšπšŽ πŸ™‹β€β™‚οΈ

Read contribution guidelines for more information regarding contribution.

π™΅πšŽπšŽπšπš‹πšŠπšŒπš” ✍️

Feature requests are always welcome, File an issue here.

π™΅πš’πš—πš πšπš‘πš’πšœ πš™πš›πš˜πš“πšŽπšŒπš πšžπšœπšŽπšπšžπš• ? ❀️

Support it by clicking the ⭐ button on the upper right of this page. ✌️

π™»πš’πšŒπšŽπš—πšœπšŽ Licence πŸ’³

This project is licensed under the Apache License 2.0 - see the LICENSE file for details


About

πŸ“£ πšƒπš‘πšŽ πš›πšŽπš™πš˜πšœπš’πšπš˜πš›πš’ πšπšŽπš–πš˜πš—πšœπšπš›πšŠπšπšŽπšœ πš‘πš˜πš  𝚝𝚘 𝚞𝚜𝚎 πš—πš˜πšπš’πšπš’πšŒπšŠπšπš’πš˜πš—πšœ πš’πš— πšŠπš•πš• πšŠπš—πšπš›πš˜πš’πš πšŸπšŽπš›πšœπš’πš˜πš—πšœ

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Languages