Mobile native

Sync Manager

Tizen provides notifications for a service application to maintain data consistency between a server and the device. You can manage the synchronization schedule for applications.

This feature is supported in mobile applications only.

The service and UI applications must have the same package name.

The main Sync Manager API features are:

  • Adding on-demand sync job schedules
  • Adding periodic sync job schedules
  • Adding data change sync job schedules
  • Removing registered sync job schedules
  • Iterating registered sync job schedules

The sync manager operates the sync jobs based on the rules defined in the following table.

Table: Sync job scheduling rules
Rule Description
Data changes on the server A server sends a push message to the account provider service and service applications. When the data is changed on the server, a push message is sent from the server. Then, the device which receives the push message can trigger an on-demand sync job.
Data changes on the device A subscribed callback function is invoked whenever a database change occurs for a registered capability. The data change listener notices the changes by using the Calendar, Contacts, and Media Content APIs. If there are any changes in the corresponding data, the sync manager notices the changes and schedules a sync job.

Changing data in the Calendar database includes adding, updating, and deleting books, events, and todos. Changing data in the Contacts database includes adding, removing, and modifying contacts.

The media content provides notifications for changes in media types, such as image, music, sound, and video.

Network availability When a status change in the Wi-Fi or data network is detected, a sync job occurs.
On demand sync The on-demand sync means that you can schedule a sync job once. You can use this feature with the sync_manager_on_demand_sync_job() function.
Periodic sync The periodic sync means that you can schedule a sync job to be performed regularly. You can use this feature with the sync_manager_add_periodic_sync_job() function. You can also use the sync intervals through various enumerators provided through the Sync Manager API.

When using the Sync Manager API, you can set an alarm indirectly. Consequently, the http://tizen.org/privilege/alarm.set privilege is required.

The following table lists the variables used with the sync manager.

Table: Sync manager variables
Variable Data type Mandatory Description
Account handle account_s* No Handle of the account module for managing account-related data.
Sync job name const char* Yes Sync job name for managing the jobs.

The on-demand and periodic sync jobs can be managed by a user-defined name. If the sync_manager_add_periodic_sync_job() function is called again with same sync job name (where all details except the name and sync job ID are changed), the function does not add a new sync job but updates the existing job. This is mainly used to reset the periodic interval.

Sync capability const char* Yes Capability for a data change sync job.

A data change sync job can provide a notification whenever a corresponding data change occurs. If the sync_manager_add_data_change_sync_job() function is used with a capability, it is operated for the related capability only. In the case of using the calendar or contact capability, the respective http://tizen.org/privilege/calendar.read or http://tizen.org/privilege/contact.read privilege is required.

The following capabilities are available:

#define SYNC_SUPPORTS_CAPABILITY_CALENDAR "http://tizen.org/sync/capability/calendar" 
#define SYNC_SUPPORTS_CAPABILITY_CONTACT "http://tizen.org/sync/capability/contact"
#define SYNC_SUPPORTS_CAPABILITY_IMAGE "http://tizen.org/sync/capability/image"
#define SYNC_SUPPORTS_CAPABILITY_MUSIC "http://tizen.org/sync/capability/music"
#define SYNC_SUPPORTS_CAPABILITY_SOUND "http://tizen.org/sync/capability/sound"
#define SYNC_SUPPORTS_CAPABILITY_VIDEO "http://tizen.org/sync/capability/video"
Sync period sync_period_e Yes Interval for a periodic sync job.

If the interval is provided, the sync job is performed periodically. If you set the periodic interval to 30 minutes, a time interval is set as a power of 2 less than 30. This means that a time interval set to 16 minutes operates the sync job every 16 minutes while skipping the first notification (so the first is in 32 minutes). The same logic applies to other cases.

This variable provides a periodic sync job with an inexact time. Coupling various periodic sync jobs with an interval as a power of 2 prevents the device from waking up the service application too many times.

The sync_period_e enumerator defines the available period intervals.

Sync option sync_option_e Yes Option for deciding the sync job behavior.

The behavior options can be used as an OR value. For example, the (SYNC_OPTION_EXPEDITED | SYNC_OPTION_NO_RETRY) expression is available, and means that the "Sync job is operated just once with priority".

The following options are available:

  • SYNC_OPTION_NONE: Sync job is operated normally
  • SYNC_OPTION_EXPEDITED: Sync job is operated as soon as possible
  • SYNC_OPTION_NO_RETRY: Sync job is not performed again when it fails
Sync job ID int* Yes Unique ID for managing sync jobs.

The ID is generated when a sync job is added. It is required to remove the sync job. The number of ID that can be generated is restricted to a hundred per a package.

Sync job user data bundle* No User data for a sync job.

The data can contain additional information related to the registered sync jobs.

User data void* No User data for the sync_manager_for_each_sync_job() function.

The data can contain additional information related to the foreach jobs.

Sync Adapter

Note
The Sync Adapter API operations must be carried out by a service application (which operates data synchronization) before using the Sync Manager API.

The number of service applications that can set callbacks is restricted to only one per a package.

The Sync Adapter API allows you to:

  • Register callbacks for notifications about the sync job start and cancellation.
  • Start a sync operation with an app control, so that the application's daemon needs not to stay awake.

    The Sync Adapter API allows you to use this mechanism without using the App Control API separately. In other words, when using the Sync Adapter API, you can use the App Control API indirectly.

Go to top