title: How should I assign a notification channel to my existing Firebase notification class?
body: <p>Using Firebase, I send notifications to my app and open certain activity from the click-action of the notification data. The problem is, it works fine where API level is &lt;26. But as for the new versions, all notifications must be assigned to a channel. But I'm not sure how I can assign my existing system with a channel that works on API level 26 or higher?</p>
  
  <p>This is my <code>FirebaseMessagingService</code> java class:</p>
  
  <pre><code>public class FirebaseMessagingService extends com.google.firebase.messaging.FirebaseMessagingService {
      private static final String TAG = "FirebaseMessagingServic";
  
      public FirebaseMessagingService() {}
  
      @Override
      public void onMessageReceived(RemoteMessage remoteMessage) {
          if (remoteMessage.getData().size() &gt; 0) {
              Log.d(TAG, "Message data payload: " + remoteMessage.getData());
              try {
                  JSONObject data = new JSONObject(remoteMessage.getData());
                  String jsonMessage = data.getString("extra_information");
                  Log.d(TAG, "onMessageReceived: \n" +
                      "Extra Information: " + jsonMessage);
              } catch (JSONException e) {
                  e.printStackTrace();
              }
          }
  
          if (remoteMessage.getNotification() != null) {
              String title = remoteMessage.getNotification().getTitle(); //get title
              String message = remoteMessage.getNotification().getBody(); //get message
              String click_action = remoteMessage.getNotification().getClickAction(); //get click_action
  
              Log.d(TAG, "Message Notification Title: " + title);
              Log.d(TAG, "Message Notification Body: " + message);
              Log.d(TAG, "Message Notification click_action: " + click_action);
  
              sendNotification(title, message, click_action);
          }
      }
  
      @Override
      public void onDeletedMessages() {
  
      }
  
      private void sendNotification(String title, String messageBody, String click_action) {
          Intent intent;
          if (click_action.equals("SOMEACTIVITY")) {
              intent = new Intent(this, SomeActivity.class);
              intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
          } else {
              intent = new Intent(this, MainActivity.class);
              intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
          }
  
          PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */ , intent,
              PendingIntent.FLAG_ONE_SHOT);
  
          Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
          NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
              .setSmallIcon(R.mipmap.ic_launcher)
              .setContentTitle(title)
              .setContentText(messageBody)
              .setAutoCancel(true)
              .setSound(defaultSoundUri)
              .setContentIntent(pendingIntent);
  
          NotificationManager notificationManager =
              (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
  
          notificationManager.notify(0 /* ID of notification */ , notificationBuilder.build());
      }
  }
  </code></pre>
  
  <p>I'm really curious what should I change here to assign it to a channel?</p>
  
  <p>I'm also sharing my <code>ActivityMain</code> activity and Manifest xml below:</p>
  
  <pre><code>public class MainActivity {
  
      private FirebaseAuth mAuth;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          mAuth = FirebaseAuth.getInstance();
          FirebaseMessaging.getInstance().subscribeToTopic("DAILYDOSE");
      }
  
  }
  </code></pre>
  
  <p>And the manifest:</p>
  
  <pre><code>&lt;application
     android:allowBackup="true"
     android:icon="@mipmap/ic_launcher"
     android:label="@string/app_name"
     android:roundIcon="@mipmap/ic_launcher_round"
     android:supportsRtl="true"
     android:theme="@style/AppTheme"&gt;
     &lt;activity android:name=".MainActivity"&gt;
        &lt;intent-filter&gt;
           &lt;action android:name="android.intent.action.MAIN" /&gt;
           &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
        &lt;/intent-filter&gt;
     &lt;/activity&gt;
     &lt;activity android:name=".SomeActivity"&gt;
        &lt;intent-filter&gt;
           &lt;action android:name="SOMEACTIVITY" /&gt;
           &lt;category android:name="android.intent.category.DEFAULT" /&gt;
        &lt;/intent-filter&gt;
     &lt;/activity&gt;
     &lt;service android:name=".FirebaseMessagingService"&gt;
        &lt;intent-filter&gt;
           &lt;action android:name="com.google.firebase.MESSAGING_EVENT" /&gt;
        &lt;/intent-filter&gt;
     &lt;/service&gt;
     &lt;meta-data
        android:name="com.google.firebase.messaging.default_notification_color"
        android:resource="@color/colorAccent" /&gt;
  &lt;/application&gt;
  </code></pre>