Skip to main content

Network and errors

Network options​

networkOptions tunes the request to the store:

PlayxUpdateOptions(
enableNetworkLogging: true, // log the request, response, errors and retries
networkOptions: PlayxNetworkOptions(
maxRetries: 2,
connectTimeout: Duration(seconds: 10),
headers: {'X-App': 'my-app'},
dio: myDio, // proxy, certificate pinning, your own interceptors
cancelToken: cancelToken, // cancel a pending check
),
)
OptionDefaultMeaning
maxRetries1retries for failures that can succeed later (timeouts, offline, throttling, 502-504). 0 disables
retryDelay1 secondbase delay between retries; it grows with every attempt
connectTimeout, sendTimeout, receiveTimeout30 s, 20 s, 30 srequest timeouts
headers—extra headers; they override the package defaults
dio—a custom Dio. The package only adds its logging interceptor to it
cancelToken—cancel the check. A cancelled check fails with NETWORK_REQUEST_CANCELED

Logging​

With enableNetworkLogging: true each request logs the method, URL and headers, then the status, headers, timing and a short preview of the body. Errors and retries are logged too. Headers whose name contains auth, cookie, token, secret, password or key are masked.

Errors​

Every failing call returns a PlayxVersionUpdateError with a message and a stable errorCode.

error: (error) {
if (error is PlayxVersionNetworkError) {
switch (error.errorCode) {
case NetworkErrorCode.noInternetConnection:
showOfflineBanner();
case NetworkErrorCode.appNotFound:
// wrong package id, or the app is not published in this country
break;
case NetworkErrorCode.consentRequired:
// Google asked for cookie consent, see below
break;
}
if (error.error.isRetryable) offerRetry();
print('HTTP status: ${error.statusCode}');
}
},

PlayxVersionNetworkError.error is the underlying NetworkException, which has an errorCode, a message, the original cause, and isRetryable.

Network error codes​

NetworkErrorCodeExceptionRetryable
NETWORK_NO_INTERNET_CONNECTIONNoInternetConnectionExceptionyes
NETWORK_REQUEST_TIMEOUTRequestTimeoutExceptionyes
NETWORK_SEND_TIMEOUTSendTimeoutExceptionyes
NETWORK_TOO_MANY_REQUESTSTooManyRequestsExceptionyes
NETWORK_SERVICE_UNAVAILABLEServiceUnavailableException (502, 503, 504)yes
STORE_APP_NOT_FOUNDAppNotFoundExceptionno
STORE_CONSENT_REQUIREDConsentRequiredExceptionno
NETWORK_NOT_FOUNDNotFoundExceptionno
NETWORK_BAD_REQUESTBadRequestExceptionno
NETWORK_UNAUTHORIZEDUnauthorizedRequestException (401, 403)no
NETWORK_CONFLICTConflictExceptionno
NETWORK_UNABLE_TO_PROCESSUnableToProcessExceptionno
NETWORK_INTERNAL_SERVER_ERRORInternalServerErrorExceptionno
NETWORK_API_ERRORDefaultApiException (other status codes)no
NETWORK_EMPTY_RESPONSEEmptyResponseExceptionno
NETWORK_INVALID_FORMATInvalidFormatExceptionno
NETWORK_BAD_CERTIFICATEBadCertificateExceptionno
NETWORK_REQUEST_CANCELEDRequestCanceledExceptionno
NETWORK_UNEXPECTED_ERRORUnexpectedErrorExceptionno

Store specifics:

  • App not found: Google Play answers 404, or the App Store lookup returns no result, for an id that is not on the store.
  • App Store 403: treated as throttling (NETWORK_TOO_MANY_REQUESTS); the lookup API is rate limited.

In some regions (the EU and UK) Google Play answers with a cookie-consent page instead of the app page, so the version cannot be read. This is reported as ConsentRequiredException (STORE_CONSENT_REQUIRED) and retrying does not help. Provide the version from your own backend with a version source (or newVersion), or send users to the store page with openStore.

Other errors​

errorCodeClassMeaning
PLAYX_VERSION_CANT_UPDATE_ERROR_CODEPlayxVersionCantUpdateErrorthe app is already up to date
VERSION_FORMAT_ERRORVersionFormatExceptiona version could not be read or compared
NOT_SUPPORTED_ERROR_CODENotSupportedExceptionthe platform has no store lookup or dialog
PLATFORM_NOT_SUPPORTED_ERRORPlatformNotSupportedErroran in-app update call on a platform other than Android
DEFAULT_FAILURE_ERRORDefaultFailureErrorany other failure

In-app update errors are listed in Android in-app updates.