title: Flutter firebase messaging not receiving notifications
body: <p>I am currently working on flutter notification using firebase messaging, I couldn't receive any notification. I sent the notification via server using <code>curl</code>, I could get it work in native android app (Android Studio) but not in flutter, any help would be appreciated. Below is my code.</p>
  <p><strong>Flutter Notification code</strong></p>
  <pre><code>class FirebaseNotifications {
  FirebaseMessaging _firebaseMessaging;
  
  void setUpFirebase() {
  _firebaseMessaging = FirebaseMessaging();
  firebaseCloudMessaging_Listeners();
  }
  
  void firebaseCloudMessaging_Listeners() {
  if (Platform.isIOS) iOS_Permission();
  
  _firebaseMessaging.getToken().then((token) {
    print(token);
  });
  
  _firebaseMessaging.configure(
    onMessage: (Map&lt;String, dynamic&gt; message) async {
      print('on message $message');
    },
    onResume: (Map&lt;String, dynamic&gt; message) async {
      print('on resume $message');
    },
    onLaunch: (Map&lt;String, dynamic&gt; message) async {
      print('on launch $message');
    },
  );
  }
  
  void iOS_Permission() {
  _firebaseMessaging.requestNotificationPermissions(
      IosNotificationSettings(sound: true, badge: true, alert: true));
  _firebaseMessaging.onIosSettingsRegistered
      .listen((IosNotificationSettings settings) {
    print(&quot;Settings registered: $settings&quot;);
  });
  }
  }
  </code></pre>
  <p><strong>Android Studio code</strong></p>
  <pre><code>@Override
  public void onMessageReceived(RemoteMessage remoteMessage) {
  
      Map&lt;String, String&gt; params = remoteMessage.getData();
  
      JSONObject object = new JSONObject(params);
  
      showNotification(remoteMessage);
  }
  
  private void showNotification(RemoteMessage remoteMessage) { 
  Map data = remoteMessage.getData();
  
  String mesg = &quot;New Notification&quot;;
  
  Intent intent;
      PendingIntent pendingIntent;
      NotificationCompat.Builder builder;
  
      Intent i = new Intent(this,MainActivity.class);
      i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  
      NotificationManager mNotificationManager =
              (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
  
      if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.O) {
          int importance = NotificationManager.IMPORTANCE_HIGH;
          NotificationChannel mChannel = new NotificationChannel(id, name, importance);
          mChannel.setDescription(description);
          mChannel.enableLights(true);
          mChannel.setLightColor(Color.GREEN);
          mChannel.enableVibration(true);
          mChannel.setVibrationPattern(new long[]{0, 250, 250, 250});
          mNotificationManager.createNotificationChannel(mChannel);
  
          builder = new NotificationCompat.Builder(this, id);
  
          intent = new Intent(this, MainActivity.class);
          intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
          pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
  
          builder.setContentTitle(data.get(&quot;title&quot;).toString())  // required
                  //.setStyle(new 
   NotificationCompat.BigTextStyle().bigText(remoteMessage.getNotification()
  .getBod 
  y().toString()))
                  .setStyle(new 
  NotificationCompat.BigTextStyle().bigText(mesg)) //custom data
                  .setSmallIcon(R.drawable.ic_stat_notification_icon4) // 
  required
                
                  .setContentText(mesg) // custom data
                  .setWhen(System.currentTimeMillis())
                  .setDefaults(Notification.DEFAULT_ALL)
                  
  .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
                  .setAutoCancel(true)
                  .setContentIntent(pendingIntent)
                  .setVibrate(new long[]{0, 250, 250, 250});
      }
  }
  </code></pre>
  <p><strong>Server side code</strong></p>
  <pre><code>function sendtoUser($sendingTarget, $acc_name, $type_message, 
  $type_of_transaction, $check_amount)
  {
  
  #API access key from Google API's Console
  $API_ACCESS_KEY = &quot;adazxc&quot;;
  $registrationIds = $sendingTarget;
  #prep the bundle
  
  $fields = array(
      'to'        =&gt; $registrationIds,
      'data' =&gt; array(
          'title' =&gt; 'my title',
          'keyValue' =&gt; true,
          'receiverName' =&gt; $acc_name,
          'transType' =&gt; $type_of_transaction,
          'totalAmount' =&gt; $check_amount
      ),
  );
  
  $headers = array(
      'Authorization: key=' . $API_ACCESS_KEY,
      'Content-Type: application/json'
  );
  #Send Reponse To FireBase Server
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send');
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
  $result = curl_exec($ch);
  curl_close($ch);
  }
  </code></pre>
  <p><strong>EDIT</strong></p>
  <p>I somehow can receive notification but I noticed that my status bar not receiving the notification but it is printed in the console, however, when I close the app I can get the notification. So how do I able to receive notification in both situation?</p>