Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Suitable Notification Channel for each users

Suitable Notification Channel for each users

MiyabiGouji

October 06, 2022
Tweet

More Decks by MiyabiGouji

Other Decks in Programming

Transcript

  1. who am I Miyabi Gouji - Nikkei Inc. - Develop

    日経電子版/紙面ビューアー app - Analysis of app users - Planning application development projects
  2. Introduction Notifications are an important feature that allows us to

    communicate with users outside of our app. Many apps use notifications to inform more users of news of high importance. However, getting users to accept notifications is becoming more and more difficult every year. In this session, we will introduce the optimization of notification channels as one of our efforts to get users to receive notifications.
  3. Purpose of this session • Who should hear to this

    session ◦ Developers considering channel optimization ◦ Managers who want to improve notification acceptance rates • What I will talk about ◦ Benefits of optimizing notification channel ◦ How to migrate from in-app settings • What I won’t talk about ◦ Notification support specific to Android 13
  4. About Notification Channel • A feature to manage notifications in

    detail introduced in Android 8 (Oreo). ◦ All notifications must be assigned to a channel • Allows users to set in detail whether and how they will receive ◦ Sound ◦ Popup ◦ Display on lock screen…
  5. If we do not optimize notification channel More than one

    channel exists because Android 8 or later requires the implementation of channels All notifications correspond to one channel
  6. Problems for users • Unable to determine which classification the

    notification I want comes in. • They can't make individual settings. ◦ They want to receive notifications, but they don't want them to pop up, etc. • Settings are scattered throughout the app and the OS, making it difficult to understand. • The absolute number of notifications increases
  7. Problems for app providers • Lack of segmentation of settings

    makes it easy to turn off notification permissions ◦ Once the permission for notifications is turned off, it is difficult to get people to turn it back on. • Management of permission is complicated because it coexists with settings in the app. • More notifications make it easier for people to turn off permissions
  8. Effects of channel optimization for users • Individualized and freely

    configurable display of notifications and privacy considerations that you wish to receive. • Reduce the number of notifications • (If permission information is centralized in the OS, ) there is no need to configure it in both the app and the OS
  9. Effects of channel optimization for app provider • Reduces risk

    of all notifications being turned off • Settings that were previously held separately in the OS and apps can now be centralized in the OS
  10. When you receive the notice Long press on a received

    notification to know which channel belongs to 日経電子版
  11. About runtime permission in Android13 From Android 13, it is

    necessary to obtain notification permissions. It will be significant to have the channel set by transitioning to the OS settings rather than the settings in the app.
  12. What we need • Organizing Notification Classification • Creating Channels

    • Migration of existing settings • Getting status from a channel • Receive operation events synchronously from a channel • Rebuild the in-app settings screen ◦ Functions ◦ Design
  13. Elements required for channel creation - channel_id: IDs to uniquely

    represent channels. Note that they are listed in order of name, not order of creation - name: Labels displayed on notification management screen and channel screen - importance: Importance of notification - description: (Optional) Channel Description. Note that long descriptions may be omitted depending on the OS version and device.
  14. Importance Popup Sound/Vibrations etc IMPORTANCE_HIGH ◦ ◦ - IMPORTANCE_DEFAULT ×

    ◦ - IMPORTANCE_LOW × × - IMPORTANCE_MIN × × Minimize to one line ON(not blocked) OFF(blocked) : IMPORTANCE_NONE
  15. Importance Override official doc: Once the channel is sent to

    NotificationManager, the importance level is unchangeable Users can change the app's channel settings at any time behavior: Can be changed as long as it is less than the set value until the user operates it after first sending it to NotificationManager
  16. Importance Override // Apps are allowed to downgrade channel importance

    if the user has not changed any // fields on this channel yet. ….. https://cs.android.com/android/platform/superproject/+/master:framewo rks/base/services/core/java/com/android/server/notification/Preferences Helper.java;l=900;drc=20ffbd23f13b00dd32f6cc4c7cfed2cc8ea46614
  17. (Optional) Importance Override If the user turns it ON after

    turning it OFF once, it will return to the default value specified by the app on many devices, but be aware that some devices may default to the device's default value. Example: If IMPORTANCE_HIGH is set on the app side, but the user turns OFF => ON, it becomes equivalent to IMPORTANCE_DEFAULT.
  18. Create Channel val notificationManager = NotificationManagerCompat.from(context) val channel = NotificationChannel(

    "01_breaking_news", "速報", NotificationManager.IMPORTANCE_HIGH ).apply { this.description = "Important News Notifications" } notificationManager.createNotificationChannel(channel)
  19. Channel Group Use to organize and display the settings screen

    group name A setting to turn off all notification permissions for each group will be added
  20. Create Channel Group val group = NotificationChannelGroup("01_breaking_group","速報") notificationManager.createNotificationChannelGroup(group) val channel

    = NotificationChannel( "01_breaking_news", "速報", NotificationManager.IMPORTANCE_HIGH ).apply { this.description = "重要なニュースの通知" this.group = "01_breaking_group" } notificationManager.createNotificationChannel(channel)
  21. Delete Channel / Channel Group // delete channel notificationManager.deleteNotificationChannel("01_breaking_news") //

    delete channel group notificationManager.deleteNotificationChannelGroup("01_breaking_group") If a channel is deleted once and then re-created with the same ID, the settings before deletion are inherited.
  22. Getting Notification Settings // Permission for each channel val notificationChannel

    = notificationManager.getNotificationChannel("01_breaking_group") val enabled = notificationChannel.importance != NotificationManager.IMPORTANCE_NONE // Permission for all notices val enabledBase = notificationManager.areNotificationsEnabled()
  23. Receive permission operation events Over API level 28 can be

    received by BroadcaseReceiver if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) { return } // The blockedState is returned, true if disabled, false if enabled. val isEnabled = !intent.getBooleanExtra(NotificationManager.EXTRA_BLOCKED_STATE, false)
  24. Receive permission operation events when (intent.action) { NotificationManager.ACTION_APP_BLOCK_STATE_CHANGED -> {

    // Processing upon receipt of all notification permission events } NotificationManager.ACTION_NOTIFICATION_CHANNEL_BLOCK_STATE_CHANGED -> {  val channelId = intent.getStringExtra(NotificationManager.EXTRA_NOTIFICATION_CHANNEL_ID) // Processing when a channel permission event is received } }
  25. Notes on synchronizing with the backend • We know from

    experience that the permission is cut off at the same time the notification is struck, and a large number of requests may be sent to the back end • when a switch is hit repeatedly, it is not possible to control It is necessary to thwart the event with the BroadcastReceiver that receives it.
  26. Strike control with back end val workRequest = OneTimeWorkRequestBuilder<NotificationStateChangeWorker>() .setBackoffCriteria(

    BackoffPolicy.LINEAR, 30L, TimeUnit.MINUTES) .setInputData(workParams) .setExpedited(OutOfQuotaPolicy.RUN_AS_NON_EXPEDITED_WORK_REQUEST) .build()
  27. Event ③ Strike control with back end Sync Event ①

    Event ② Worker ① Worker ② Worker ③ replace replace
  28. Strike control with back end • Set priority jobs for

    Android 12 or later. • Do not set this option if less than 12, as the foreground service may start (displaying a notification) as backward compatible. ◦ recommended: to sync regularly when the app is launched as it may not always be activated
  29. Notification setting in the app • Maintain permission settings in

    the app and persist them in the DB • Change permissions in the settings screen • Controls sending notifications in conjunction with backend setting in the app before optimization
  30. Why leave the settings for notifications in the app? •

    Save users who had previously been set up in the app. ◦ A certain number of users are unaware of OS notification settings • In the future, when permission settings for each user are created, they can be managed on the same screen. ※ Our application does not support Android 7 from 2022
  31. Notification settings screen in the app Desired information • Notification

    channel name • Notification Channel Permission State • (Optional) Channel description Desired Features • Permission can be turned on/off
  32. notification settings in the app (per-user settings) • If you

    want to set up notifications on a per-user basis rather than per-device basis, place them on the same screen • Directly within the app Image is an example.
  33. Review on this session • Benefits of notification channels optimization

    • Steps to move to a notification channel, with real-life examples ◦ Craete Channel ◦ Notification Settings and behavior in the application ◦ Get channel status ◦ Receive permission change events
  34. Conclusion Optimized channels now allow users to fine-tune how they

    receive notifications. This is expected to reduce the risk of notification permissions being turned off. In addition, the centralization of permission information in the OS makes it easier to organize the classification of notifications. We will continue to improve notifications while observing changes in permissions.
  35. Control the display on the lock screen The system can

    also specify whether notification content should be displayed on the lock screen, but the user's lock screen settings take precedence. VISIBILITY_PUBLIC View full content of notifications VISIBILITY_SECRET Do not display some of the notifications on the lock screen VISIBILITY_PRIVATE Basic information such as the icon and content title of the notification is displayed. The complete content of the notification is not displayed.