AWSCognitoDataset Class Reference

Inherits from AWSCognitoDatasetMetadata : NSObject
Declared in AWSCognitoDataset.h
AWSCognitoDataset.m

Overview

An object that encapsulates the dataset. The dataset is the unit of sync for Amazon Cognito.

Other Methods

  conflictHandler

A conflict resolution handler that will receive calls when there is a conflict during a sync operation. A conflict will occur when both remote and local data have been updated since the last sync time. When not explicitly set, we will use the default conflict resolution of ‘last writer wins’, where the data most recently updated will be persisted.

@property (nonatomic, copy) AWSCognitoRecordConflictHandler conflictHandler

Declared In

AWSCognitoDataset.h

  datasetDeletedHandler

A deleted dataset handler. This handler will be called during a synchronization when the remote service indicates that a dataset has been deleted. Returning YES from the handler will cause the service to recreate the dataset on the remote on the next synchronization. Returning NO or leaving this property nil will cause the client to delete the dataset locally.

@property (nonatomic, copy) AWSCognitoDatasetDeletedHandler datasetDeletedHandler

Declared In

AWSCognitoDataset.h

  datasetMergedHandler

A merged dataset handler. This handler will be called during a synchronization when the remote service indicates that other datasets should be merged with this one. Merged datasets should be fetched, their data overlayed locally and then removed. Failing to implement this handler will result in merged datasets remaining on the service indefinitely.

@property (nonatomic, copy) AWSCognitoDatasetMergedHandler datasetMergedHandler

Declared In

AWSCognitoDataset.h

  synchronizeRetries

The number of times to attempt a synchronization before failing. Defaults to to the value on the AWSCognito client that opened this dataset.

@property (nonatomic, assign) uint32_t synchronizeRetries

Declared In

AWSCognitoDataset.h

  synchronizeOnWiFiOnly

Only synchronize if device is on a WiFi network. Defaults to to the value on the AWSCognito client that opened this dataset.

@property (nonatomic, assign) BOOL synchronizeOnWiFiOnly

Declared In

AWSCognitoDataset.h

– setString:forKey:

Sets a string object for the specified key in the dataset.

- (void)setString:(NSString *)aString forKey:(NSString *)aKey

Declared In

AWSCognitoDataset.h

– stringForKey:

Returns the string associated with the specified key.

- (NSString *)stringForKey:(NSString *)aKey

Declared In

AWSCognitoDataset.h

– synchronize

Synchronize local changes with remote changes on the service. First it pulls down changes from the service and attempts to overlay them on the local store. Then it pushes any local updates to the service. If at any point there is a conflict, conflict resolution is invoked. No changes are pushed to the service until all conflicts are resolved.

- (AWSTask *)synchronize

Declared In

AWSCognitoDataset.h

– synchronizeOnConnectivity

Attempts to synchronize when device has connectivity. First it checks connectivity, if device is online immediately invokes synchronize and returns the AWSTask associated with the attempt. If the device is offline, schedules a synchronize for the next time the device comes online and returns a AWSTask with a nil result. The scheduled synchronize is only valid for the lifecycle of the dataset object. The data will not be synchronized if the app is exited before connectivity is regained. If you want to be notified when events occur during the scheduled synchronize, you must add observers of the notifications found in AWSCognito

- (AWSTask *)synchronizeOnConnectivity

Declared In

AWSCognitoDataset.h

– subscribe

Subscribes this dataset to push notifications

- (AWSTask *)subscribe

Return Value

AWSTask with nil result. task.error will contain any errors.

Declared In

AWSCognitoDataset.h

– unsubscribe

Unsubscribes this dataset to push notifications

- (AWSTask *)unsubscribe

Return Value

AWSTask with nil result. task.error will contain any errors.

Declared In

AWSCognitoDataset.h

– getAllRecords

Returns all of the records in the dataset. Will return deleted records.

- (NSArray<AWSCognitoRecord*> *)getAllRecords

Return Value

NSArray of AWSCognitoRecord objects

Declared In

AWSCognitoDataset.h

– getAll

Returns all the key value pairs in the dataset, ignore any deleted data.

- (NSDictionary<NSString*,NSString*> *)getAll

Return Value

NSDictionary of all key value pairs. Contains no metadata.

Declared In

AWSCognitoDataset.h

– removeObjectForKey:

Remove a record from the dataset.

- (void)removeObjectForKey:(NSString *)aKey

Parameters

aKey

the key to remove

Declared In

AWSCognitoDataset.h

– recordForKey:

Returns the record associated with the specified key.

- (AWSCognitoRecord *)recordForKey:(NSString *)aKey

Parameters

aKey

the key to return

Return Value

AWSCognitoRecord for this particular record. Will return nil if record does not exist.

Declared In

AWSCognitoDataset.h

– clear

Clear this dataset locally. Dataset will not be removed from the service until the next synchronize call.

- (void)clear

Declared In

AWSCognitoDataset.h

– size

Returns the size in bytes for this dataset.

- (long)size

Declared In

AWSCognitoDataset.h

– sizeForKey:

Returns the size in bytes for the specified key.

- (long)sizeForKey:(NSString *)aKey

Parameters

aKey

the key to check

Declared In

AWSCognitoDataset.h

Other Methods

– syncPull:

The pull part of our sync 1. Do a list records, overlay changes 2. Resolve conflicts

- (AWSTask *)syncPull:(uint32_t)remainingAttempts

Declared In

AWSCognitoDataset.m

– syncPush:

The push part of the sync 1. Write any changes to remote 2. Restart sync if errors occur

- (AWSTask *)syncPush:(uint32_t)remainingAttempts

Declared In

AWSCognitoDataset.m