Guest User

Untitled

a guest
Oct 20th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. // define channel attributes (name, description, and id)
  2.  
  3. public static final String NOTIFICATION_CHANNEL_ID = "SomeChannelId"
  4.  
  5. public static final String NOTIFICATION_CHANNEL_NAME = "UserFacingChannelName"
  6.  
  7. public static final String NOTIFICATION_CHANNEL_DESCRIPTION = "User facing description of the channel"
  8.  
  9. // create notification channel
  10.  
  11. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
  12.  
  13. NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
  14.  
  15. NotificationChannel notificationChannel = notificationManager.getNotificationChannel(NOTIFICATION_CHANNEL_ID);
  16.  
  17. if (notificationChannel == null) {
  18.  
  19. // only create it if it hasn't been created already
  20.  
  21. notificationChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, NOTIFICATION_CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH);
  22.  
  23. notificationChannel.setDescription(NOTIFICATION_CHANNEL_DESCRIPTION);
  24.  
  25. notificationChannel.enableLights(true);
  26.  
  27. notificationChannel.enableVibration(true);
  28.  
  29. notificationChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
  30.  
  31. notificationManager.createNotificationChannel(notificationChannel);
  32.  
  33. }
  34.  
  35. }
  36.  
  37. // pass Flurry the channel ID while setting up Marketing Module
  38.  
  39. FlurryMarketingOptions flurryMarketingOptions = new FlurryMarketingOptions.Builder()
  40.  
  41. ...
  42.  
  43. .withDefaultNotificationChannelId(NOTIFICATION_CHANNEL_ID)
  44.  
  45. ...
  46.  
  47. .build();
Add Comment
Please, Sign In to add comment