title: Firebase Messaging notification for specific device in flutter
body: <p>I am working on a flutter application whereby a lot of server requests were implemented on our custom server including login/signup. However, we decided to use Firebase Cloud Messaging for notifications. For example, included in the application is a chat feature. </p>
  
  <p>During end to end messaging, as messages get posted to our server, users should receive notifications on their specific devices. I have already successfully implemented and configured <code>firebase</code> within the app and can send messages from the console but i need to make it work on specific devices.</p>
  
  <pre><code>// Replace with server token from firebase console settings.
  final String serverToken = '&lt;Server-Token&gt;';
  final FirebaseMessaging firebaseMessaging = FirebaseMessaging();
  
  Future&lt;Map&lt;String, dynamic&gt;&gt; sendAndRetrieveMessage() async {
    await firebaseMessaging.requestNotificationPermissions(
      const IosNotificationSettings(sound: true, badge: true, alert: true, provisional: false),
    );
  
    await http.post(
      'https://fcm.googleapis.com/fcm/send',
       headers: &lt;String, String&gt;{
         'Content-Type': 'application/json',
         'Authorization': 'key=$serverToken',
       },
       body: jsonEncode(
       &lt;String, dynamic&gt;{
         'notification': &lt;String, dynamic&gt;{
           'body': 'this is a body',
           'title': 'this is a title'
         },
         'priority': 'high',
         'data': &lt;String, dynamic&gt;{
           'click_action': 'FLUTTER_NOTIFICATION_CLICK',
           'id': '1',
           'status': 'done'
         },
         'to': await firebaseMessaging.getToken(),
       },
      ),
    );
  </code></pre>
  
  <p>This is the documented way of sending messages within flutter. However, this will send notifications to all users not a single user. So, how do i target a specific user?</p>