SHARE
TWEET

Untitled

a guest Feb 22nd, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. this.notificationListener = firebase
  2.   .notifications()
  3.   .onNotification((notification: Notification) => {
  4.  
  5.     const channel = new firebase.notifications.Android.Channel(
  6.       'test-channel',
  7.       'Test Channel',
  8.       firebase.notifications.Android.Importance.Max
  9.     ).setDescription('My apps test channel');
  10.  
  11.     if (notification && notification.data) {
  12.       const data = notification.data;
  13.       if (data && data.messageKey) {
  14.  
  15.         if (
  16.           data.messageKey === '3001' ||
  17.           data.messageKey === '3006'
  18.         ) {
  19.  
  20.           channel.setSound('alert');
  21.         } else {
  22.  
  23.           channel.setSound('chime');
  24.         }
  25.       }
  26.     }
  27.  
  28.     // Create the channel
  29.     firebase.notifications().android.createChannel(channel);
  30.     // Process your notification as required
  31.     notification
  32.     .android.setChannelId('test-channel')
  33.     .android.setSmallIcon(Images.logoSmall);
  34.  
  35.  
  36. firebase.notifications()
  37.     .displayNotification(notification);
  38.   });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top