unregisterFCMToken method

  1. @override
Future<RequestResponse<FrappeResponse?>> unregisterFCMToken(
  1. String token
)

Removes the token from the currently signed in user.

If it fails, a failure is returned and the user should not be logged out.

Implementation

@override
Future<RequestResponse<FrappeResponse?>> unregisterFCMToken(
    String token) async {
  final response = await Request.initiateRequest(
      url: config.hostUrl,
      method: HttpMethod.POST,
      contentType: ContentTypeLiterals.APPLICATION_JSON,
      data: <String, dynamic>{'cmd': 'logout', 'fcm_token': token});

  if (response.isSuccess == true) {
    return RequestResponse.success(response.data,
        rawResponse: response.rawResponse);
  }
  response.isSuccess = false;
  return RequestResponse.fail(handleError(
      'fcm_unregister_client',
      response.error ??
          ErrorDetail(
              info: Information(
                  data: response.data,
                  httpCode: response.httpCode,
                  rawResponse: response.rawResponse)
                ..rawError = response.error?.info?.rawError)));
}