sendRegistrationToken method

Future<void> sendRegistrationToken()

Implementation

Future<void> sendRegistrationToken() async {
  final url = Uri.parse('http://172.16.1.51:3000/register');
  var token = await _firebaseMessaging.getToken();
  var data = '''
  {
    "notification": {
      "body": "this is a body",
      "title": "this is a title"
    },
    "priority": "high",
    "data": {
      "click_action": "FLUTTER_NOTIFICATION_CLICK"
    },
    "token": "$token",
    "topics": "test"
  }
''';

  final response = await http.post(
    url,
    headers: <String, String>{
      "Content-Type": "application/json",
      "Keep-Alive": "timeout=5",
      "Authorization": "$token"
    },
    body: data,
  );
  print(response.statusCode);
  print(response.body);
}