enablePushNotification static method
Future<TPUser?>
enablePushNotification(
{ - dynamic errorCallback(
- int? errorCode,
- 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;
}