Push Sync

If you're new to Amazon Cognito Sync, use AWS AppSync. Like Amazon Cognito Sync, AWS AppSync is
a service for synchronizing application data across devices.

It enables user data like app preferences or game state to be synchronized.
It also extends these capabilities by allowing multiple users to
synchronize and collaborate in real time on shared data.

Amazon Cognito automatically tracks the association between identity and devices.
Using the push
synchronization, or push sync, feature, you can ensure that every instance of a given
identity
is notified when identity data changes. Push sync ensures that, whenever the sync
store data
changes for a particular identity, all devices associated with that identity receive
a silent
push notification informing them of the change.

Note

Push sync is not supported for JavaScript, Unity, or Xamarin.

Before you can use push sync, you must first set up your account for push sync and
enable
push sync in the Amazon Cognito console.

Create an Amazon Simple Notification Service (Amazon SNS) App

Create and configure an Amazon SNS app for your supported platforms, as described
in the
SNS Developer
Guide.

In the Service role dropdown menu, select the IAM role that
grants Cognito permission to send an SNS notification. Click Create
role to create or modify the roles associated with your identity pool in
the AWS IAM Console.

Use Push Sync in Your App: Android

Your application will need to import the Google Play services. You can download the
latest version of the Google Play SDK via the Android SDK
manager. Follow the Android documentation on implementing a GCM client
to register your app and receive a registration ID from GCM. Once you have the registration
ID, you need to register the device with Amazon Cognito, as shown in the snippet below:

source: cognito-sync. This can serve as a differentiating factor
between notifications.

identityPoolId: The identity pool ID. This can be used for validation
or additional information, though it's not integral from the receiver's point of
view.

identityId: The identity ID within the pool.

datasetName: The name of the dataset that was updated. This is
available for the sake of the openOrCreateDataset call.

syncCount: The sync count for the remote dataset. You can use this as
a way to make sure that the local dataset is out of date, and that the incoming
synchronization is new.

Use Push Sync in Your App: iOS - Objective-C

To obtain a device token for your app, follow the Apple documentation on Registering
for
Remote Notifications. Once you've received the device token as an NSData object from
APNs,
you'll need to register the device with Amazon Cognito using the registerDevice: method
of the sync client, as shown below:

If you post a notification using notification handler, you can then respond to the
notification elsewhere in the application where you have a handle to your dataset.
If you
subscribe to the notification like this ...

source: cognito-sync. This can serve as a differentiating factor
between notifications.

identityPoolId: The identity pool ID. This can be used for validation
or additional information, though it's not integral from the receiver's point of
view.

identityId: The identity ID within the pool.

datasetName: The name of the dataset that was updated. This is
available for the sake of the openOrCreateDataset call.

syncCount: The sync count for the remote dataset. You can use this as a
way to make sure that the local dataset is out of date, and that the incoming
synchronization is new.

Use Push Sync in Your App: iOS - Swift

To obtain a device token for your app, follow the Apple documentation on Registering
for
Remote Notifications. Once you've received the device token as an NSData object from
APNs,
you'll need to register the device with Amazon Cognito using the registerDevice: method
of the sync
client, as shown
below:

If you post a notification using notification handler, you can then respond to the
notification elsewhere in the application where you have a handle to your dataset.
If you
subscribe to the notification like this ...