BlockstoreClient

public interface BlockstoreClient implements HasApiKey<Api.ApiOptions.NoOptions>

The interface for clients to access Blockstore.

Clients should call storeBytes(StoreBytesData) to store authentication credentials byte[] bytes to enable seamless sign-in on other devices.

Clients should call retrieveBytes() to fetch the authentication credentials to seamlessly sign in users on a newly setup device.

Constant Summary

int MAX_SIZE Maximum allowed size of byte blobs that can be stored using BlockstoreClient#storeBytes.

Public Method Summary

abstract Task<byte[]>
retrieveBytes()
Returns a Task which asynchronously retrieves the previously-stored bytes, if any.
abstract Task<Integer>
storeBytes(StoreBytesData storeBytesData)
Returns a Task which asynchronously stores the provided byte[] bytes.

Constants

public static final int MAX_SIZE

Maximum allowed size of byte blobs that can be stored using BlockstoreClient#storeBytes.

Constant Value: 1024

Public Methods

public abstract Task<byte[]> retrieveBytes ()

Returns a Task which asynchronously retrieves the previously-stored bytes, if any. The maximum size of the byte[] is the MAX_SIZE.

The byte[] may have been written on the same device or may have been transferred during the device setup.

Use this API to seamlessly sign-in users to the apps on a new device.

If no data is found, returns an empty byte array. Note that the data may be cleared by Google Play Services on certain user actions, like user clearing app storage (among others).

public abstract Task<Integer> storeBytes (StoreBytesData storeBytesData)

Returns a Task which asynchronously stores the provided byte[] bytes.

The relevant data is stored locally and will be transferred to a new device when during the device-to-device restore and if a google account is also transferred. In the future, this data may be backed up to cloud for cloud restore events.

The maximum size of the byte[] bytes allowed is BlockstoreClient#MAX_SIZE, otherwise, the API will throw an Exception.

The Integer return value is the size of byte[] bytes successfully stored.

Use this API to store small data blobs that can enable seamless sign in for your apps. The API may be called periodically (for example, a few times per day) to refresh the data blob. Successive calls to this API would overwrite the existing bytes.