Created
October 19, 2018 22:16
-
-
Save flurrydev/3f7fb5f5ea1922e59795e57b6653e040 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
| // define channel attributes (name, description, and id) | |
| public static final String NOTIFICATION_CHANNEL_ID = "SomeChannelId" | |
| public static final String NOTIFICATION_CHANNEL_NAME = "UserFacingChannelName" | |
| public static final String NOTIFICATION_CHANNEL_DESCRIPTION = "User facing description of the channel" | |
| // create notification channel | |
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | |
| NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); | |
| NotificationChannel notificationChannel = notificationManager.getNotificationChannel(NOTIFICATION_CHANNEL_ID); | |
| if (notificationChannel == null) { | |
| // only create it if it hasn't been created already | |
| notificationChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, NOTIFICATION_CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH); | |
| notificationChannel.setDescription(NOTIFICATION_CHANNEL_DESCRIPTION); | |
| notificationChannel.enableLights(true); | |
| notificationChannel.enableVibration(true); | |
| notificationChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC); | |
| notificationManager.createNotificationChannel(notificationChannel); | |
| } | |
| } | |
| // pass Flurry the channel ID while setting up Marketing Module | |
| FlurryMarketingOptions flurryMarketingOptions = new FlurryMarketingOptions.Builder() | |
| ... | |
| .withDefaultNotificationChannelId(NOTIFICATION_CHANNEL_ID) | |
| ... | |
| .build(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment