crateFcmToken method

Future<Response> crateFcmToken()

to create fcm token for firebase cloud messaging services

Implementation

Future<http.Response> crateFcmToken() async {
  Uri url = Uri.parse("$_baseUrl/user/fcm/token/create");

  final body = jsonEncode({
    "token": fcmToken,
    "type": "fcm",
    "token_from": "client",
  });

  printMessage(body);

  http.Response response = await http.Client()
      .post(url, body: body, headers: kAuthenticatedPostRequestHeader);

  if (response.statusCode == 200) {
    printMessage("CREATE FCM TOKEN RESPONSE = ${response.body}");
    return response;
  } else {
    printMessage("CREATE FCM TOKEN RESPONSE = ${response.statusCode}");
    printMessage("CREATE FCM TOKEN RESPONSE = ${response.body}");
    return response;
  }
}