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. Suitable
    Notification Channel
    for each users
    Miyabi Gouji
    Nikkei Inc.

    View Slide

  2. who am I
    Miyabi Gouji
    - Nikkei Inc.
    - Develop 日経電子版/紙面ビューアー app
    - Analysis of app users
    - Planning application development projects

    View Slide

  3. We are Hiring :)
    https://hack.nikkei.com/jobs/android/

    View Slide

  4. 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.

    View Slide

  5. 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

    View Slide

  6. 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…

    View Slide

  7. Notification setting screen Channel setting screen

    View Slide

  8. 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

    View Slide

  9. 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

    View Slide

  10. 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

    View Slide

  11. 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

    View Slide

  12. 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

    View Slide

  13. When you receive the notice
    Long press on a received
    notification to know which
    channel belongs to 日経電子版

    View Slide

  14. 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.

    View Slide

  15. Example of channel optimization
    in Nikkei

    View Slide

  16. 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

    View Slide

  17. 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.

    View Slide

  18. Importance
    Popup Sound/Vibrations etc
    IMPORTANCE_HIGH ○ ○ -
    IMPORTANCE_DEFAULT × ○ -
    IMPORTANCE_LOW × × -
    IMPORTANCE_MIN × × Minimize to one line
    ON(not blocked)
    OFF(blocked) : IMPORTANCE_NONE

    View Slide

  19. 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

    View Slide

  20. 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

    View Slide

  21. (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.

    View Slide

  22. 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)

    View Slide

  23. name
    importance
    name
    description
    importance

    View Slide

  24. 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

    View Slide

  25. 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)

    View Slide

  26. Channel Group
    If groups are not explicitly created…
    The name "Other" is automatically
    assigned.

    View Slide

  27. 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.

    View Slide

  28. 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()

    View Slide

  29. 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)

    View Slide

  30. 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
    }
    }

    View Slide

  31. 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.

    View Slide

  32. Strike control with back end
    val workRequest =
    OneTimeWorkRequestBuilder()
    .setBackoffCriteria(
    BackoffPolicy.LINEAR,
    30L,
    TimeUnit.MINUTES)
    .setInputData(workParams)
    .setExpedited(OutOfQuotaPolicy.RUN_AS_NON_EXPEDITED_WORK_REQUEST)
    .build()

    View Slide

  33. Strike control with back end
    WorkManager.getInstance(context)
    .enqueueUniqueWork(
    "notification_state_change_worker",
    ExistingWorkPolicy.REPLACE,
    workRequest,
    )

    View Slide

  34. Event ③
    Strike control with back end
    Sync
    Event ①
    Event ②
    Worker ①
    Worker ②
    Worker ③
    replace
    replace

    View Slide

  35. 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

    View Slide

  36. No longer need the notification
    settings in the app?

    View Slide

  37. 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

    View Slide

  38. 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

    View Slide

  39. 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

    View Slide

  40. ‘All notification’ is ON ‘All notification’ is OFF

    View Slide

  41. 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.

    View Slide

  42. Notification permission operation
    (when all notifications are ON)

    View Slide

  43. Notification permission operation
    (when all notifications are OFF)
    ❌ Can't tap.

    View Slide

  44. Open the Notification Channel
    val intent: Intent =
    Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
    .putExtra(Settings.EXTRA_APP_PACKAGE,requireActivity().packageName)
    .putExtra(Settings.EXTRA_CHANNEL_ID, "01_breaking_group")
    startActivity(intent)

    View Slide

  45. Open the Notification Settings
    val intent: Intent = Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS)
    .putExtra(Settings.EXTRA_APP_PACKAGE,requireActivity().packageName)
    startActivity(intent)

    View Slide

  46. Permission OFF count after optimization

    View Slide

  47. 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

    View Slide

  48. 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.

    View Slide

  49. Appendix

    View Slide

  50. 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.

    View Slide

  51. Reference
    WorkManager:
    https://developer.android.com/topic/libraries/architecture/workm
    anager/how-to/define-work#backwards-compat

    View Slide