Disable sound from NotificationChannel

前端 未结 15 1372
时光说笑
时光说笑 2020-11-27 15:50

Today I started targeting API 26 which forced me to use Notification Channels.

My problem is that now on each new notification (including updates to it) an annoying

15条回答
  •  广开言路
    2020-11-27 16:25

    You can use 2 different notification channel to send notification depending on there priority to user.

    If its a high priority notification the send it via

    new NotificationChannel("Channel ID", "Channel Name", NotificationManager.IMPORTANCE_HIGH);
    

    Your user will get sound and pop when they will receive a notification.

    If you want to send less important notification then use this channel.

    new NotificationChannel("Channel ID", "Channel Name", NotificationManager.IMPORTANCE_LOW);
    

    Your user will get a notification with no sound and pop up.

    check different priority from here - https://developer.android.com/reference/android/app/NotificationManager

提交回复
热议问题