|
|
@ -89,7 +89,8 @@ class App : Application() { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@RequiresApi(Build.VERSION_CODES.O) |
|
|
|
@RequiresApi(Build.VERSION_CODES.O) |
|
|
|
private fun createChannelId() { |
|
|
|
private fun createChannelId() { |
|
|
|
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager |
|
|
|
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as? NotificationManager |
|
|
|
|
|
|
|
notificationManager?.let { |
|
|
|
//用唯一的ID创建渠道对象 |
|
|
|
//用唯一的ID创建渠道对象 |
|
|
|
val downloadChannel = NotificationChannel( |
|
|
|
val downloadChannel = NotificationChannel( |
|
|
|
channelIdDownload, |
|
|
|
channelIdDownload, |
|
|
@ -124,6 +125,7 @@ class App : Application() { |
|
|
|
webChannel.setSound(null, null) |
|
|
|
webChannel.setSound(null, null) |
|
|
|
|
|
|
|
|
|
|
|
//向notification manager 提交channel |
|
|
|
//向notification manager 提交channel |
|
|
|
notificationManager.createNotificationChannels(Arrays.asList(downloadChannel, readAloudChannel, webChannel)) |
|
|
|
it.createNotificationChannels(Arrays.asList(downloadChannel, readAloudChannel, webChannel)) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|