Last active
October 13, 2018 02:05
-
-
Save markchristopherng/f744e53d65cbbcf5922b6b6e7dbede15 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@TargetApi(Build.VERSION_CODES.O) | |
private void createNotificationChannels(AppConfig config) { | |
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && | |
config.getChannelGroups()!= null) { | |
for (AppConfig.ChannelGroup cg: config.getChannelGroups()) { | |
NotificationChannelGroup ncg = | |
new NotificationChannelGroup(cg.groupId, cg.groupName); | |
notificationManager.createNotificationChannelGroup(ncg); | |
for (AppConfig.Channel channel : cg.channels) { | |
NotificationChannel notificationChannel = | |
new NotificationChannel(channel.channelId, channel.channelName, channel.importance); | |
notificationChannel.setGroup(ncg.getId()); | |
notificationManager.createNotificationChannel(notificationChannel); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment