enablePushNotification static method

Future<TPUser?> enablePushNotification({
  1. dynamic errorCallback(
    1. int? errorCode,
    2. String? errorMessage
    )?,
})

Implementation

static Future<TPUser?> enablePushNotification(
    {
      Function(int? errorCode, String? errorMessage)? errorCallback
    }) async
{
  if (!_isInitialized(errorCallback: errorCallback)) { return null; }
  if (!_checkAuthInfo(errorCallback: errorCallback)) { return null; }

  try {
    Map<String, dynamic> body = Map.from({});
    String url = "/users/settings/push/enable";
    Map<String, dynamic> response = await HttpUtil.postJson(url, body);
    Map<String, dynamic> user = response["user"];
    _mUser = TPUser(user);
    return _mUser;
  } on TPException catch(e) {
    Logger.log("${e.getCode()}, ${e.getMessage()}");
    errorCallback?.call(e.getCode(), e.getMessage());
  } catch(e){
    Logger.log("$e");
    errorCallback?.call(-1, e.toString());
  }
  return null;
}