Amazon Cognito | Store and sync data across devices Flashcards
Does the number of identities in the Cognito Identity console tell me how many users are using my app?
Store and sync data across devices
Amazon Cognito | Security, Identity & Compliance
The number of identities in the Cognito Identity console shows you how many identities were created via the Cognito Identity APIs. For Authenticated Identities (those logging in with a login provider such as Facebook or an OpenID Connect provider), each call to Cognito Identity’s GetId API will only ever create a single identity for each user. However, for Unauthenticated identities, each time the client in an app calls the GetId API will generate a new identity. Therefore, if your app calls GetId for unauthenticated identities multiple times for a single user it will appear that a single user has multiple identities. So it is important that you cache the response from GetId when using unauthenticated identities and not call it multiple times per user.
The Mobile SDK provides the logic to cache the Cognito Identity automatically so you don’t have to worry about this. If you’re looking for a complete analytics solution for your app, including the ability to track unique users, please look at Amazon Mobile Analytics.
What is the Amazon Cognito sync store?
Store and sync data across devices
Amazon Cognito | Security, Identity & Compliance
The Amazon Cognito Sync store is a key/value pair store linked to an Amazon Cognito identity. There is no limit to the number of identities you can create in your identity pools and sync store. Each Amazon Cognito identity within the sync store has its own user information store.
Is data saved directly to the Amazon Cognito sync store?
Store and sync data across devices
Amazon Cognito | Security, Identity & Compliance
No. The optional AWS Mobile SDK saves your data to an SQLite database on the local device, this way the data is always accessible to your app. The data is pushed to the Amazon Cognito sync store by calling the synchronize() method and, if push synchronization is enabled, all other devices linked to an identity are notified of the data change in the sync store via Amazon SNS.
How is data stored in the Amazon Cognito sync store?
Store and sync data across devices
Amazon Cognito | Security, Identity & Compliance
Data associated with an Amazon Cognito identity are organized as key/value pairs. A key is a label e.g. “MusicVolume”, and a value e.g. “11”. Key/value pairs are grouped and categorized using data sets. Data sets are a logical partition of key/value pairs and the most granular entity used by Amazon Cognito to perform sync operations.
What is the maximum size of a user information store within the Amazon Cognito sync store?
Store and sync data across devices
Amazon Cognito | Security, Identity & Compliance
Each user information store can have a maximum size of 20MB. Each data set within the user information store can contain up to 1MB of data. Within a data set you can have up to 1024 keys.
What kind of data can I store in a data set?
Store and sync data across devices
Amazon Cognito | Security, Identity & Compliance
Both keys and values within a data set are alphanumeric strings. There is no limit to the length of the strings other than the total amount of values in a dataset cannot exceed 1MB. Binary data can be stored as a base64 encoded string as a value provided it does not exceed the 1MB limit.
Why are data sets limited to 1MB?
Store and sync data across devices
Amazon Cognito | Security, Identity & Compliance
Limiting the data set size to 1MB increases the chances of a synchronization task completing successfully even when bandwidth is limited without lots of retries that consume battery life and data plans.
Are user identities and user information stores shared across developers?
Store and sync data across devices
Amazon Cognito | Security, Identity & Compliance
No, a user identity and information store is tied to a specific AWS account. If there are multiple apps from different publishers on a particular device that use Amazon Cognito, each app will use the information store created by each publisher.
How can I analyze and query the data stored in the Cognito Sync store?
Store and sync data across devices
Amazon Cognito | Security, Identity & Compliance
With Cognito Streams, you can push sync store data to a Kinesis stream in your AWS account. You can then consume this stream and store the data in a way that makes it easy for you to analyze such as a Amazon Redshift database, an RDS instance you own or even an S3 file. We have published sample Kinesis consumer application to show how to store the updates data in Amazon Redshift.
Why should I use Kinesis stream instead of a database export?
Store and sync data across devices
Amazon Cognito | Security, Identity & Compliance
By streaming the data to Kinesis you can receive all of the history of changes to your datasets in real-time. This means you receive all the changes an end user makes to a dataset and gives you the flexibility to store this data in a tool of your choice.
What if I already have data stored in Cognito?
Store and sync data across devices
Amazon Cognito | Security, Identity & Compliance
When you enable the Kinesis stream feature you will be able to start a bulk publish. This process asynchronously sends all of the data currently stored in your Cognito sync store to the Kinesis stream you selected.
What is the price of this feature?
Store and sync data across devices
Amazon Cognito | Security, Identity & Compliance
Cognito pushes the data to a Kinesis stream you own. There is no difference in Cognito’s per-synchronization price if this feature is enabled. You will be charged Kinesis’ standard rates for your shards.
Can I validate data before it is saved?
Store and sync data across devices
Amazon Cognito | Security, Identity & Compliance
Amazon Cognito Events allows developers to run an AWS Lambda function in response to important events in Cognito. The Sync Trigger event is an event that occurs when any dataset is synchronized. Developers can write an AWS Lambda function to intercept the synchronization event. The function can evaluate the changes to the underlying Dataset and manipulate the data before it is stored in the cloud and synchronized back to the user’s other devices. Alternatively, the AWS Lambda function could fail the sync operation so that the data is not synchronized to the user’s other devices.
How is data synchronized with Amazon Cognito?
Store and sync data across devices
Amazon Cognito | Security, Identity & Compliance
You can programmatically trigger the sync of data sets between client devices and the Amazon Cognito sync store by using the synchronize() method in the AWS Mobile SDK. The synchronize() method reads the latest version of the data available in the Amazon Cognito sync store and compares it to the local, cached copy. After comparison, the synchronize() method writes the latest updates as necessary to the local data store and the Amazon Cognito sync store. By default Amazon Cognito maintains the last-written version of the data. You can override this behavior and resolve data conflicts programmatically. In addition, push synchronization allows you to use Amazon Cognito to send a silent push notification to all devices associated with an identity to notify them that new data is available.
What is a silent push notification?
Store and sync data across devices
Amazon Cognito | Security, Identity & Compliance
Amazon Cognito uses the Amazon Simple Notification Service (SNS) to send silent push notifications to devices. A silent push notification is a push message that is received by your application on a user’s device that will not be seen by the user.