clearPushToken method

Future<void> clearPushToken()

Unregisters the push token.

Implementation

Future<void> clearPushToken() async {
  await _ensureLoaded();
  final push = _stored.pushToken;
  final token = _token;
  await _persist(_stored.copyWith(clearPush: true));
  _pushDirty = false;
  _pushRegisteredFor = null;
  if (push != null && token != null) {
    try {
      await _api.deleteDevice(token: token, pushToken: push);
    } on HatangException catch (e) {
      _log.warn('device removal failed: $e');
    }
  }
}