public class CognitoSyncManager extends Object
Dataset
in SQLite database. Here is a sample usage:
CognitoCachingCredentialsProvider provider = new CognitoCachingCredentialsProvider(context, awsAccountId, identityPoolId, unauthRoleArn, authRoleArn, Regions.US_EAST_1); CognitoClientManager client = new CognitoClientManager(context, Regions.US_EAST_1, provider); Dataset dataset = client.openOrCreateDataset("default_dataset"); dataset.put("high_score", "100"); dataset.synchronize(new SyncCallback() { // override callbacks });
Constructor and Description |
---|
CognitoSyncManager(android.content.Context context,
Regions region,
CognitoCachingCredentialsProvider provider)
Constructs a CognitoSyncManager object.
|
CognitoSyncManager(android.content.Context context,
String identityPoolId,
Regions region,
CognitoCachingCredentialsProvider provider)
Deprecated.
Please use the constructor without an identityPoolId
|
Modifier and Type | Method and Description |
---|---|
PushSyncUpdate |
getPushSyncUpdate(android.content.Intent intent)
Converts the notification from Cognito push sync to an object that has
easy access to all of the relevant information.
|
boolean |
isDeviceRegistered()
Checks the cache to see if the registration information from a registration
with push synchronization is saved to the device
|
List<DatasetMetadata> |
listDatasets()
Retrieves a list of datasets from local storage.
|
Dataset |
openOrCreateDataset(String datasetName)
Opens or creates a dataset.
|
void |
refreshDatasetMetadata()
Refreshes dataset metadata.
|
void |
registerDevice(String platform,
String token)
Register device for push sync.
|
void |
subscribe(List<String> datasetNames)
Subscribes the user to some set of datasets from the total list that the
device knows of, giving the user push sync notifications for all in that
set
|
void |
subscribeAll()
Subscribes the user to all datasets that the local device knows of for
push sync notifications, so that any changes to any of these datasets
will result in notifications to this device.
|
void |
unregisterDevice()
Unregisters the device for push sync.
|
void |
unsubscribe(List<String> datasetNames)
Unsubscribes the user to some set of datasets from the total list that
the device knows of, ending any reception of push sync notifications
|
void |
unsubscribeAll()
Unsubscribes the user to all datasets that the local device knows of from
push sync notifications, so that no changes to any of these datasets
will result in notifications to this device.
|
void |
wipeData()
Wipes all user data cached locally, including identity id, session
credentials, dataset metadata, and all records.
|
@Deprecated public CognitoSyncManager(android.content.Context context, String identityPoolId, Regions region, CognitoCachingCredentialsProvider provider)
context
- a context of the appidentityPoolId
- Cognito identity pool idregion
- Cognito sync regionprovider
- a credentials providerpublic CognitoSyncManager(android.content.Context context, Regions region, CognitoCachingCredentialsProvider provider)
context
- a context of the appregion
- Cognito sync regionprovider
- a credentials providerpublic Dataset openOrCreateDataset(String datasetName)
refreshDatasetMetadata()
, it will throw
IllegalStateException
.datasetName
- dataset name, must be [a-zA-Z0=9_.:-]+public List<DatasetMetadata> listDatasets()
public void refreshDatasetMetadata() throws DataStorageException
DataStorageException
- thrown when fail to refresh dataset metadatapublic void wipeData()
public void registerDevice(String platform, String token)
platform
- Platform of the device, one of GCM, ADMtoken
- Device token of the device, gotten when registered for the
platform in question.public boolean isDeviceRegistered()
public void unregisterDevice()
public void subscribeAll()
public void subscribe(List<String> datasetNames)
datasetNames
- The list of names of datasets to subscribe topublic void unsubscribeAll()
public void unsubscribe(List<String> datasetNames)
datasetNames
- The list of names of datasets to unsubscribe frompublic PushSyncUpdate getPushSyncUpdate(android.content.Intent intent)
extras
- the bundle returned from the intent.getExtras() callCopyright © 2010 Amazon Web Services, Inc. All Rights Reserved.