第11章 $fh.sync
Sync API は、クライアントアプリとバックエンドのデータストア間におけるデータ同期に回復性の高いメカニズムを提供します。Sync API 使用時には、クライアントアプリは $fh.cloud コールではなく、Sync API ですべてのデータ操作を実行します。
データセットを制限するためにバックエンドデータストアに渡されるクエリパラメーターとともに、データセットは manage を呼び出し、データセットの一意の ID を指定することで、Sync サービスの制御下に置かれます。
Sync クライアントは、新規レコードを受信した場合や更新がバックエンドにコミットされた場合など、データの状態が変更されるとイベントを使用してアプリに通知します。Sync Service についての詳細な説明は、データ同期フレームワーク を参照してください。
サポートされるプラットフォーム
JavaScript SDK
- Cordova
- Web Apps
- Android SDK
- iOS Objective-C SDK
- iOS Swift SDK
.NET SDK
- Windows
- Xamarin
詳細なバージョン情報については、Supported Configurations (英語) を参照してください。
11.1. $fh.sync.init
$fh.sync.init(options);
11.1.1. 詳細
クライアントデータ sync servicew を初期化します。
11.1.2. 例
JavaScript
$fh.sync.init({
// How often to synchronize data with the cloud, in seconds.
// Optional. Default: 10
"sync_frequency": 10,
// Should local changes be synchronized to the cloud immediately, or should they wait for the next synchronization interval.
// Optional. Default: true
"auto_sync_local_updates": true,
// Should a notification event be triggered when loading or saving to client storage fails.
// Optional. Default: true
"notify_client_storage_failed": true,
// Should a notification event be triggered when a synchronization cycle with the server has been started.
// Optional. Default: true
"notify_sync_started": true,
// Should a notification event be triggered when a synchronization cycle with the server has been completed.
// Optional. Default: true
"notify_sync_complete": true,
// Should a notification event be triggered when an attempt was made to update a record while offline.
// Optional. Default: true
"notify_offline_update": true,
// Should a notification event be triggered when an update failed due to data collision.
// Optional. Default: true
"notify_collision_detected": true,
// Should a notification event be triggered when an update was applied to the local data store.
// Optional. Default: true
"notify_local_update_applied": true,
// Should a notification event be triggered when an update failed for a reason other than data collision.
// Optional. Default: true
"notify_remote_update_failed": true,
// Should a notification event be triggered when an update was applied to the remote data store.
// Optional. Default: true
"notify_remote_update_applied": true,
// Should a notification event be triggered when a delta was received from the remote data store.
// Optional. Default: true
"notify_delta_received": true,
// Should a notification event be triggered when a delta was received from the remote data store for a record.
// Optional. Default: true
"notify_record_delta_received": true,
// Should a notification event be triggered when the synchronization loop failed to complete.
// Optional. Default: true
"notify_sync_failed": true,
// Should log statements be written to console.log. Will be useful for debugging.
// Optional. Default: false
"do_console_log": false,
// How many synchronization cycles to check for updates on crashed in-flight updates.
// Optional. Default: 10
"crashed_count_wait" : 10,
// If crashed_count_wait limit is reached, should the client retry sending the crashed in flight pending records.
// Optional. Default: true
"resend_crashed_updates" : true,
// Is the background synchronization with the cloud currently active. If this is set to false, the synchronization loop will not start automatically. You need to call startSync to start the synchronization loop.
// Optional. Default: true
"sync_active" : true,
// Storage strategy to use for the underlying client storage framework Lawnchair. Valid values include 'dom', 'html5-filesystem', 'webkit-sqlite', 'indexed-db'.
// Multiple values can be specified as an array and the first valid storage option will be used.
// Optional. Default: 'html5-filesystem'
"storage_strategy" : "html5-filesystem",
// Amount of space to request from the HTML5 filesystem API when running in browser
// Optional. Default: 50 * 1024 * 1024
"file_system_quota" : 50 * 1024 * 1024,
// If the app has legacy custom cloud sync function (the app implemented the data CRUDL operations in main.js file in FH V2 apps), it should be set to true. If set to false, the default MBaaS sync implementation will be used. When set to null or undefined, a check will be performed to determine which implementation to use.
// Optional. Default: null
"has_custom_sync" : null,
// ios only. If set to true, the file will be backed by icloud.
// Optional.Default: false
"icloud_backup" : false
});
Android (Java)
FHSyncConfig syncConfig = new FHSyncConfig();
// Should local changes be synchronized to the cloud immediately, or should
// they wait for the next synchronization interval.
// Optional. Default: false
syncConfig.setAutoSyncLocalUpdates(false);
// How many synchronization cycles to check for updates on crashed in-flight
// updates.
// Optional. Default: 10
syncConfig.setCrashCountWait(10);
// Should a notification event be triggered when loading or saving to client
//storage fails.
// Optional. Default: false
syncConfig.setNotifyClientStorageFailed(false);
// Should a notification event be triggered when a delta was received from the
//remote data store.
// Optional. Default: false
syncConfig.setNotifyDeltaReceived(false);
// Should a notification event be triggered when an update was applied to the local
//data store.
// Optional. Default: false
syncConfig.setNotifyLocalUpdateApplied(false);
// Should a notification event be triggered when an attempt was made to update a
//record while offline.
// Optional. Default: false
syncConfig.setNotifyOfflineUpdate(false);
// Should a notification event be triggered when an update was applied to the remote
//data store.
// Optional. Default: false
syncConfig.setNotifyRemoteUpdateApplied(false);
// Should a notification event be triggered when a synchronization cycle with the
//server has been started.
// Optional. Default: false
syncConfig.setNotifySyncStarted(false);
// Should a notification event be triggered when the synchronization loop failed to complete.
// Optional. Default: false
syncConfig.setNotifySyncFailed(false);
// Should a notification event be triggered when a synchronization cycle with the
// server has been completed.
// Optional. Default: false
syncConfig.setNotifySyncComplete(false);
// Should a notification event be triggered when an update failed due to data collision.
// Optional. Default: false
syncConfig.setNotifySyncCollisions(false);
// Should a notification event be triggered when an update failed for a reason other
//than data collision.
// Optional. Default: false
syncConfig.setNotifyUpdateFailed(false);
// If the limit set in setCrashCountWait is reached, should the client
// retry sending the crashed in-flight pending records.
// Optional. Default: true
syncConfig.setResendCrashedUpdates(true);
// How often to synchronize data with the cloud, in seconds.
// Optional. Default: 10
syncConfig.setSyncFrequency(10);
// If the app has legacy custom cloud sync function (the app implemented the data
//CRUDL operations in main.js file in FH V2 apps), it should be set to true. If set
//to false, the default MBaaS sync implementation will be used.
// Optional. Default: false
syncConfig.setUseCustomSync(false);
syncClient = FHSyncClient.getInstance();
syncClient.init(appContext, syncConfig, new FHSyncListener() {
/**The implementation for this class
* is discussed later in this document
**/
});
iOS (Swift)
let conf = FHSyncConfig() // How often to synchronize data with the cloud, in seconds. // Optional. Default: 10 conf.syncFrequency = 10 // Should local changes be synchronized to the cloud immediately, or should they wait for the next synchronization interval. // Optional. Default: true conf.autoSyncLocalUpdates = true // Should a notification event be triggered when loading or saving to client storage fails. // Optional. Default: false conf.notifyClientStorageFailed = true // Should a notification event be triggered when a synchronization cycle with the server has been started. // Optional. Default: false conf.notifySyncStarted = true // Should a notification event be triggered when a synchronization cycle with the server has been completed. // Optional. Default: false conf.notifySyncCompleted = true // Should a notification event be triggered when an attempt was made to update a record while offline. // Optional. Default: false conf.notifyOfflineUpdate = true // Should a notification event be triggered when an update failed due to data collision. // Optional. Default: false conf.notifySyncCollision = true // Should a notification event be triggered when an update was applied to the local data store. // Optional. Default: false conf.notifyLocalUpdateApplied = true // Should a notification event be triggered when an update failed for a reason other than data collision. // Optional. Default: false conf.notifyRemoteUpdateFailed = true // Should a notification event be triggered when an update was applied to the remote data store. // Optional. Default: false conf.notifyRemoteUpdateApplied = true // Should a notification event be triggered when a delta was received from the remote data store. // Optional. Default: false conf.notifyDeltaReceived = true // Should a notification event be triggered when the synchronization loop failed to complete. // Optional. Default: false conf.notifySyncFailed = true // Should log statements be written to console.log. Will be useful for debugging. // Optional. Default: false conf.debug = true // How many synchronization cycles to check for updates on crashed in-flight updates. // Optional. Default: 10 conf.crashCountWait = 10 // If crashCountWait limit is reached, should the client retry sending the crashed in flight pending records. // Optional. Default: true conf.resendCrashedUpdates = true // If the app has legacy custom cloud sync function (the app implemented the data CRUDL operations in main.js file in FH V2 apps), it should be set to true. If set to false, the default MBaaS sync implementation will be used. When set to null or undefined, a check will be performed to determine which implementation to use. // Optional. Default: false conf.hasCustomSync = false // iOS only. If set to YES, the file will be backed by icloud. // Optional.Default: false conf.icloud_backup = false syncClient = FHSyncClient(config: conf)
iOS (Objective-C)
FHSyncConfig* conf = [[FHSyncConfig alloc] init]; // How often to synchronize data with the cloud, in seconds. // Optional. Default: 10 conf.syncFrequency = 10; // Should local changes be synchronized to the cloud immediately, or should they wait for the next synchronization interval. // Optional. Default: YES conf.autoSyncLocalUpdates = YES; // Should a notification event be triggered when loading or saving to client storage fails. // Optional. Default: NO conf.notifyClientStorageFailed = YES; // Should a notification event be triggered when a synchronization cycle with the server has been started. // Optional. Default: NO conf.notifySyncStarted = YES; // Should a notification event be triggered when a synchronization cycle with the server has been completed. // Optional. Default: NO conf.notifySyncCompleted = YES; // Should a notification event be triggered when an attempt was made to update a record while offline. // Optional. Default: NO conf.notifyOfflineUpdate = YES; // Should a notification event be triggered when an update failed due to data collision. // Optional. Default: NO conf.notifySyncCollision = YES; // Should a notification event be triggered when an update was applied to the local data store. // Optional. Default: NO conf.notifyLocalUpdateApplied = YES; // Should a notification event be triggered when an update failed for a reason other than data collision. // Optional. Default: NO conf.notifyRemoteUpdateFailed = YES; // Should a notification event be triggered when an update was applied to the remote data store. // Optional. Default: NO conf.notifyRemoteUpdateApplied = YES; // Should a notification event be triggered when a delta was received from the remote data store. // Optional. Default: NO conf.notifyDeltaReceived = YES; // Should a notification event be triggered when the synchronization loop failed to complete. // Optional. Default: NO conf.notifySyncFailed = YES; // Should log statements be written to console.log. Will be useful for debugging. // Optional. Default: NO conf.debug = YES; // How many synchronization cycles to check for updates on crashed in-flight updates. // Optional. Default: 10 conf.crashCountWait = 10; // If crashCountWait limit is reached, should the client retry sending the crashed in flight pending records. // Optional. Default: YES conf.resendCrashedUpdates = YES; // If the app has legacy custom cloud sync function (the app implemented the data CRUDL operations in main.js file in FH V2 apps), it should be set to true. If set to false, the default MBaaS sync implementation will be used. When set to null or undefined, a check will be performed to determine which implementation to use. // Optional. Default: NO conf.hasCustomSync = NO; // iOS only. If set to YES, the file will be backed by icloud. // Optional.Default: NO conf.icloud_backup = NO; FHSyncClient* syncClient = [[FHSyncClient alloc] initWithConfig:conf];
.NET (C#)
var client = FHSyncClient.GetInstance(); var config = new FHSyncConfig(); /// How often to synchronize data with the cloud, in seconds. /// Default Value : 10 config.SyncFrequency = 10; /// Should local changes be synchronized to the cloud immediately, or should they wait for the next synchronization interval. /// Default value : true config.AutoSyncLocalUpdates = true; /// How many synchronization cycles to check for updates on crashed in-flight updates. /// Default value : 10 config.CrashedCountWait = 10; /// If CrashedCountWait limit is reached, should the client retry sending the crashed in flight pending records. /// Default value : true config.ResendCrashedUpdated = true; /// Is the background sync with the cloud currently active. If this is set to false, the sync loop will not start automatically. You need to call Start to start the synchronization loop. /// Default value : true config.SyncActive = true; /// Set whether to use a legacy FH V2 sync Cloud App, the MBaaS sync service, /// or automatically select. /// Values are SyncCloudType.Auto, SyncCloudType.Legacy, SyncCloudType.Mbbas /// Default value : Auto config.SyncCloud = SyncCloudType.Auto; client.Initialise(config);
11.2. $fh.sync.notify
$fh.sync.notify(callback(data));
11.2.1. 詳細
sync サービスにクライアントへの通知がある場合、callback 関数が起動するように登録する。
11.2.2. 例
JavaScript
$fh.sync.notify(function(event) {
// The dataset that the notification is associated with
var dataset_id = event.dataset_id;
// The unique identifier that the notification is associated with.
// This will be the unique identifier for a record if the notification is related to an individual record,
// or the current hash of the dataset if the notification is associated with a full dataset
// (for example, sync_complete)
var uid = event.uid;
// Optional free text message with additional information
var message = event.message;
// The notification message code
var code = event.code;
/* Codes:
* client_storage_failed: Loading or saving to client storage failed. This is a critical error and the Sync Client will not work properly without client storage.
* sync_started: A synchronization cycle with the server has been started.
* sync_complete: A synchronization cycle with the server has been completed.
* offline_update: An attempt was made to update or delete a record while offline.
* collision_detected: Update failed due to data collision.
* remote_update_failed: Update failed for a reason other than data collision.
* remote_update_applied: An update was applied to the remote data store.
* local_update_applied: An update was applied to the local data store.
* delta_received: A change was received from the remote data store for the dataset. It is best to listen to this notification and update the UI accordingly.
* record_delta_received: A delta was received from the remote data store for the record. It is best to listen to this notification and update UI accordingly.
* sync_failed: Synchronization loop failed to complete.
*/
});
Android (Java)
同期イベントは、syncClient.init を使用して登録した FHSyncListener インスタンスに送信されます。リスナーの各メソッドには、null でない NotificationMessage パラメーターが提供されます。
public class SampleSyncListener implements FHSyncListener {
public void onSyncStarted(NotificationMessage notificationMessage) {
/*Data sync is available. Update your UI, enable editing fields,
display messages to the user, etc.*/
}
public void onSyncCompleted(NotificationMessage notificationMessage) {
/*Sync has completed. Data has been successfully sent to the server or
successfully received from the server. In either case you should refresh
the data presented to the user.
You may retrieve your latest data for this message with
FHSyncClient.getInstance().list(notificationMessage.getDataId())*/
}
public void onUpdateOffline(NotificationMessage notificationMessage) {
/*A create, delete, or update operation was called, but the device is
not connected to the network. The UI should be updated, fields disabled,
user notified, etc.*/
}
public void onCollisionDetected(NotificationMessage notificationMessage) {
/* The update could not be applied to the server. There are many reasons
why this could happen and it is up to the application developer to
resolve the collision.
After the data has been updated to synchronize cleanly, the methods
FHSyncClient.listCollisions and FHSyncClient.removeCollision can be used
to view and resolve the collision entries.
Use FHSyncClient.getInstance().read(notificationMessage.getDataId(),
notificationMessage.getUID())
to view the data record.
*/
}
public void onRemoteUpdateFailed(NotificationMessage notificationMessage) {
/* The remote updated failed. You may use notificationMessage.getExtraMessage()
to get additional details.
Use FHSyncClient.getInstance().read(notificationMessage.getDataId(),
notificationMessage.getUID())
to view the data record.*/
}
public void onRemoteUpdateApplied(NotificationMessage notificationMessage) {
/* An update was successfully processed by the remote server.
Use FHSyncClient.getInstance().read(notificationMessage.getDataId(),
notificationMessage.getUID())
to view the data record.
*/
}
public void onLocalUpdateApplied(NotificationMessage notificationMessage) {
/* An update is applied locally and waiting to be sent to the remote
server.
Use FHSyncClient.getInstance().read(notificationMessage.getDataId(),
notificationMessage.getUID())
to view the data record.
*/
}
public void onDeltaReceived(NotificationMessage notificationMessage) {
/*An incoming update has been applied. The UI should be updated if appropriate.
Use FHSyncClient.getInstance().read(notificationMessage.getDataId(),
notificationMessage.getUID())
to view the data record.
Use FHSyncClient.getInstance().list(notificationMessage.getDataId())
to load all data records.
notificationMessage.getExtraMessage() will return the type of operation
(update, delete, create) which was performed.
*/
}
public void onSyncFailed(NotificationMessage notificationMessage) {
/*
For some reason the sync loop was unable to complete. This could be for
many different reasons such as network connectivity, authentication
issues, programming errors, etc.
Use notificationMessage.getExtraMessage() to get extra information.
*/
}
public void onClientStorageFailed(NotificationMessage notificationMessage) {
/*
Sync was not able to store data locally. This indicates a device error
such as out of space, invalid permissions, etc
Use notificationMessage.getExtraMessage() to get extra information.
*/
}
}iOS (Objective-C)
同期通知は、標準の NSNotificationCenter 機能で配布されます。kFHSyncStateChangedNotification 通知の受信を開始するには、NSNotificationCenter の addObserver:selector:name:object: または addObserverForName:object:queue:usingBlock: メソッドを使用して登録します。
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onSyncMessage:) name:kFHSyncStateChangedNotification object:nil];
* (void) onSyncMessage:(NSNotification*) note
{
FHSyncNotificationMessage* msg = (FHSyncNotificationMessage*) [note object];
NSString* code = msg.code;
if([code isEqualToString:REMOTE_UPDATE_APPLIED_MESSAGE]) {
}
/* Codes:
*
* NSString *const SYNC_STARTED_MESSAGE = @"SYNC_STARTED";
* A synchronization cycle with the server has been started.
*
* NSString *const SYNC_COMPLETE_MESSAGE = @"SYNC_COMPLETE";
* A synchronization cycle with the server has been completed.
*
* NSString *const SYNC_FAILED_MESSAGE = @"SYNC_FAILED";
* Synchronization loop failed to complete.
*
* NSString *const OFFLINE_UPDATE_MESSAGE = @"OFFLINE_UPDATE";
* An attempt was made to update or delete a record while offline.
*
* NSString *const COLLISION_DETECTED_MESSAGE = @"COLLISION_DETECTED";
* Update failed due to data collision.
*
* NSString *const REMOTE_UPDATE_FAILED_MESSAGE = @"REMOTE_UPDATE_FAILED";
* Update failed for a reason other than data collision.
*
* NSString *const REMOTE_UPDATE_APPLIED_MESSAGE = @"REMOTE_UPDATE_APPLIED";
* An update was applied to the remote data store.
*
* NSString *const LOCAL_UPDATE_APPLIED_MESSAGE = @"LOCAL_UPDATE_APPLIED";
* An update was applied to the local data store.
*
* NSString *const DELTA_RECEIVED_MESSAGE = @"DELTA_RECEIVED";
* An change was received from the remote data store for the dataset.
* It's best to listen to this notification and update UI accordingly.
*
* NSString *const CLIENT_STORAGE_FAILED_MESSAGE = @"CLIENT_STORAGE_FAILED";
* Loading or saving to client storage failed. This is a critical error and the Sync Client will not work properly without client storage.
*/
}iOS (Swift)
同期通知は、標準の NSNotificationCenter 機能で配布されます。kFHSyncStateChangedNotification 通知の受信を開始するには、NSNotificationCenter の addObserver(\_:selector:name:object:) または addObserverForName(\_:object:queue:usingBlock:) メソッドを使用して登録します。
NSNotificationCenter.defaultCenter().addObserver(self, selector:Selector("onSyncMessage:"), name:"kFHSyncStateChangedNotification", object:nil)
public func onSyncMessage(note: NSNotification) {
if let msg = note.object as? FHSyncNotificationMessage, let code = msg.code {
if code == REMOTE_UPDATE_APPLIED_MESSAGE {
}
/* Codes:
*
* let SYNC_STARTED_MESSAGE = "SYNC_STARTED"
* A synchronization cycle with the server has been started.
*
* let SYNC_COMPLETE_MESSAGE = "SYNC_COMPLETE"
* A synchronization cycle with the server has been completed.
*
* let SYNC_FAILED_MESSAGE = "SYNC_FAILED"
* Synchronization loop failed to complete.
*
* let OFFLINE_UPDATE_MESSAGE = "OFFLINE_UPDATE"
* An attempt was made to update or delete a record while offline.
*
* let COLLISION_DETECTED_MESSAGE = "COLLISION_DETECTED"
* Update failed due to data collision.
*
* let REMOTE_UPDATE_FAILED_MESSAGE = "REMOTE_UPDATE_FAILED"
* Update failed for a reason other than data collision.
*
* let REMOTE_UPDATE_APPLIED_MESSAGE = "REMOTE_UPDATE_APPLIED"
* An update was applied to the remote data store.
*
* let LOCAL_UPDATE_APPLIED_MESSAGE = "LOCAL_UPDATE_APPLIED"
* An update was applied to the local data store.
*
* let DELTA_RECEIVED_MESSAGE = "DELTA_RECEIVED"
* An change was received from the remote data store for the dataset.
* It's best to listen to this notification and update UI accordingly.
*
* let CLIENT_STORAGE_FAILED_MESSAGE = "CLIENT_STORAGE_FAILED"
* Loading or saving to client storage failed. This is a critical error and the Sync Client will not work properly without client storage.
*/
}.NET (C#)
以下のセクションでは、client は設定済みかつ初期化済みの FHSyncClient インスタンスです。タイプが EventHandler<FHSyncNotificationEventArgs> のイベントハンドラーをクライアントがサポートする別のイベントタイプに設定することができます。
/// The event arguments that will be sent to the sync event listeners
public class FHSyncNotificationEventArgs : EventArgs
{
/// The id of the dataset
public string DatasetId { set; get; }
/// The unique universal id of the record
public string Uid { private get; set; }
/// Type fo the notification.
public SyncNotification Code { get; set; }
/// An message associated with the event argument. Could be empty.
public string Message { get; set; }
}
/// Loading or saving to client storage failed. This is a critical error and the Sync Client will not work properly without client storage.
client.ClientStorageFailed += async (sender, args) => { };
/// A synchronization cycle with the server has been started.
client.SyncStarted += async (sender, args) => { };
/// A synchronization cycle with the server has been completed.
client.SyncCompleted += async (sender, args) => { };
/// An attempt was made to update or delete a record while offline.
client.OfflineUpdate += async (sender, args) => { };
/// Update failed due to data collision.
client.CollisionDetected += async (sender, args) => { };
/// Update failed for a reason other than data collision.
client.RemoteUpdateFailed += async (sender, args) => { };
/// An update was applied to the local data store.
client.LocalUpdateApplied += async (sender, args) => { };
/// An update was applied to the remote data store.
client.RemoteUpdateApplied += async (sender, args) => { };
/// A change was received from the remote data store for the dataset. It's best to listen to this notification and update UI accordingly.
client.DeltaReceived += async (sender, args) => { };
/// A delta was received from the remote data store for the record. It's best to listen to this notification and update UI accordingly.
client.RecordDeltaReceived += async (sender, args) => { };
/// Synchronization loop failed to complete.
client.SyncFailed += async (sender, args) => { };11.2.3. 同期通知
このセクションでは、JavaScript SDK 向けの通知構造について説明します。Objective-C、Swift、Android および .NET のすべての SDK は専用のオブジェクトで通知構造を定義しますが、JavaScript 情報もこれらすべての SDK に便利なものです。
JavaScript SDK 内の通知は以下の構造になります。
{
"dataset_id": String,
"uid": [String],
"code": String,
"message": Object|String
}ここでは、
-
dataset_idは通知に関連するデータセットの名前になります。 -
uidは関連レコードの UID です。これは永続的でないレコード (レコードハッシュ) の UID、または永続的レコードの永続的 UID のどちらでも構いません。sync_started、sync_failedおよびlocal_update_appliedなど特定のレコードを通知が参照しない場合は、uidの値をnullとすることができます。また、sync_completeなどの通知の場合は、uidエントリーはありません。詳細については、個別の通知構造を参照してください。 -
codeはsync_startedなど、通知のタイプの識別子になります。 -
messageは通知とともに送信される追加データで、各通知ごとに異なります。詳細については、個別の通知を参照してください。
11.2.3.1. Sync Started
同期ループが開始されます。この通知はクライアントがオンラインかオフラインかに関係なく、同期ループごとに送信されます。
11.2.3.1.1. 通知コード
-
Javascript -
sync_started -
Objective-C/Swift -
SYNC_STARTED
11.2.3.1.2. 通知の構造
{
"dataset_id": "myDataset",
"uid": null, 1
"code": "sync_started",
"message": null 2
}11.2.3.2. Sync Complete
同期ループが完了します。同期ループには、バックエンドへの初期同期要求やその他の要求、応答の結果として実行されるアクションが含まれます。この通知は sync_failed イベントと同じ同期ループでは発生しません。つまり、同期ループは完了するか失敗するかのいずれかになります。
11.2.3.2.1. 通知コード
-
JavaScript -
sync_complete -
Objective-C/Swift -
SYNC_COMPLETE
11.2.3.2.2. 通知の構造
{
"dataset_id": "myDataset",
"code": "sync_complete",
"message": "online" // message is always "online"
}
uid がこの構造に表示されることはありません。
11.2.3.3. Sync Failed
同期ループが完全に失敗しました。これは以下の 2 つの場合に発生します。同期ループ中に sync クライアントがオフラインだった。または、sync レコード要求が 500 などエラーコードを応答で受け取った。Sync failed 通知が送信されるのは、notify_sync_failed オプションが true に設定されている場合のみです。
11.2.3.3.1. 通知コード
-
JavaScript -
sync_failed -
Objective-C/Swift -
SYNC_FAILED
11.2.3.3.2. 通知の構造
{
"dataset_id": "myDataset",
"uid": "a3387ce5d175cf73ec5f5d7614c7c6b4f44393f2_1",
"code": "sync_failed",
"message": "offline" 1
}- 1
- クライアントがオフラインの場合は、
messageは "offline" になります。その他の場合は、メッセージには同期サーバーから失敗した回答メッセージが含まれます。
11.2.3.4. Record Delta Received
この通知は JavaScript SDK にのみあります。Delta Received は、他のすべての SDK で同一タスクを実行します。
変更がレコードのリモートデータストアで受信されます。この通知は、同期応答で返される各変更 (update, delete, create) で発生します。
11.2.3.4.1. 通知コード
-
JavaScript -
record_delta_received
11.2.3.4.2. 通知の構造
{
"dataset_id": "myDataset",
"uid": "58e3b2cff7fc7297eb635053",
"code": "record_delta_received",
"message": "update" 1
}- 1
messageは "create"、"update" または "delete" のいずれかになります。
11.2.3.5. Delta Received
変更がデータセットのリモートデータストアで受信されます。JavaScript SDK では、各同期レコードコールごとに発生します。複数の変更があってイベントオブジェクトがグローバルハッシュを提供する場合でも 1 回しか発生しないので、record_delta_received イベントとは異なります。更新をバックエンドから受信したかどうか確認するには、この通知を使用します。ただし、変更についての知識は必要ありません。
Objective-C、Swift および Android の SDK では、この通知は record_delta_received 通知として機能します。つまり、同期サーバーによって返される各更新ごとに 1 回発生します。
11.2.3.5.1. 通知コード
-
JavaScript -
delta_received -
Objective-C/Swift -
DELTA_RECEIVED
11.2.3.5.2. 通知の構造
{
"dataset_id": "myDataset",
"uid": "a3387ce5d175cf73ec5f5d7614c7c6b4f44393f2_1",
"code": "delta_received",
"message": "partial dataset" 1
}- 1
messageは常に "partial dataset" です。
11.2.3.6. Local Update Applied
変更がローカルデータセットに適用されます。これは以下の状況で発生します。* データセットがローカルのデータストレージから読み込まれる。* データセットがローカルで新規の保留中レコードで更新される (例えば、ユーザーが新規レコードを作成する場合など)。別のクライアントが元になっているサーバーから変更を受け取った場合には、この通知は発生しません。このような変更のタイプを確認する場合は、record_delta_received イベントを使用します。
11.2.3.6.1. 通知コード
-
JavaScript -
local_update_applied -
Objective-C/Swift -
LOCAL_UPDATE_APPLIED
11.2.3.6.2. 通知の構造
{
"dataset_id":"myDataset",
"uid":"8783f802c8d43053ee2bf02009dd79d89b186afb",
"code":"local_update_applied",
"message":"update" 1
}- 1
messageは "load"、"create"、"update" または "delete" のいずれかになります。
11.2.3.7. Remote Update Applied
更新がリモートデータストアに適用されます。この通知は、バックエンドで正常に適用された各レコードごとに発生します。
11.2.3.7.1. 通知コード
-
JavaScript -
remote_update_applied -
Objective-C/Swift -
REMOTE_UPDATE_APPLIED
11.2.3.7.2. 通知の構造
{
"dataset_id":"myDataset",
"uid":"58e3b2e6f7fc7297eb635100",
"code":"remote_update_applied",
"message":{ 1
"_id":"58e3b2e60d6412349926e95b",
"action":"create",
"cuid":"5733885DDC134A6FA9754BA67E4E4BAC",
"hash":"66c3961bc1dc7139427a95d3471a27ae30d4cb96",
"msg":null,
"oldUid":"66c3961bc1dc7139427a95d3471a27ae30d4cb96",
"timestamp":1491317478112,
"type":"applied",
"uid":"58e3b2e6f7fc7297eb635100"
}
}- 1
messageは、同期サーバーから受信したupdateオブジェクトです。
11.2.3.8. Remote Update Failed
更新のリモートデータストアへの適用に失敗しました。この通知は、適用に失敗した各レコードごとに発生します。更新失敗の一般的な理由は、データがリモートデータストアに維持されないためです。
11.2.3.8.1. 通知コード
-
JavaScript -
remote_update_failed -
Objective-C/Swift -
REMOTE_UPDATE_FAILED
11.2.3.8.2. 通知の構造
remote_update_applied と似ていますが、code が変更されています。
11.2.3.9. Collision Detected
同期サーバーで競合が見つかりました。この通知は、同期サーバーが検出した競合ごとに発生します。競合は、古くなったクライアントが状態の変わったレコードを更新しようとすると発生します。競合の処理方法は、サーバー側の競合ハンドラーが決定します。
11.2.3.9.1. 通知コード
-
JavaScript -
collision_detected -
Objective-C/Swift -
COLLISION_DETECTED
11.2.3.9.2. 通知の構造
remote_update_applied と似ていますが、code が変更されています。
11.2.3.10. Offline Update
クライアントがオフラインの間にデータセットからレコードが追加、更新または削除されます。
11.2.3.10.1. 通知コード
-
JavaScript -
offline_update -
Objective-C/Swift -
OFFLINE_UPDATE
11.2.3.10.2. 通知の構造
{
"dataset_id":"myDataset",
"uid":"58e3b2cff7fc7297eb635053",
"code":"offline_update",
"message":"update" 1
}- 1
messageは "create"、"update" または "delete" のいずれかになります。
11.2.3.11. Client Storage Failed
同期の基礎的なデータストレージ (Lawnchair) が問題に遭遇しました。これは、クエリが完了に失敗した場合に発生します。
11.2.3.11.1. 通知コード
-
JavaScript -
client_storage_failed -
Objective-C/Swift -
CLIENT_STORAGE_FAILED
11.2.3.11.2. 通知の構造
{
"dataset_id": "myDataset",
"uid": null, 1
"code": "client_storage_failed",
"message": "load from local storage failed"
}- 1
uidは常にnullです。
11.3. $fh.sync.manage
$fh.sync.manage(dataset_id, options, query_params, meta_data, callback);
11.3.1. 詳細
データセットを sync service の管理下に置きます。同一データセットで manage を複数回呼び出すとオプションと query_params を更新しますが、データセットは複数回同期されません。
11.3.2. 例
JavaScript
var dataset_id = 'tasks';
// Configuration options object.
// These override the options passed to init.
var options = {
"sync_frequency": 30 // Sync every 30 seconds for the 'tasks' dataset
};
// Parameters object to be passed to the cloud sync service.
// It will be passed to the dataHandler when listing dataset on the back end.
// If the default MBaaS cloud implementation is used (which uses $fh.db for data handlers), all the valid list options can be used here.
// For example, to list the tasks that are assigned to a user called "Tom", the query params should be
var query_params = {
"eq": {
"assigned": "Tom"
}
};
// Extra params that will be sent to the back-end data handlers.
var meta_data = {};
$fh.sync.manage(dataset_id, options, query_params, meta_data, function(){
console.log('dataset ' + dataset_id + ' is now managed by sync');
});
Android (Java)
//queryParams are any query supported by $fh.db JSONObject queryParams = new JSONObject(); //MetaData such as sessionTokens, userIds, etc JSONObject metaData = new JSONObject(); //Any String identifier String dataSet = "myDataSetId"; // If configOverride is null then the config provided in FHSyncClient.init // will be used instead. FHSyncConfig configOverride = null; FHSyncClient.getInstance().manage(dataSet, configOverride, queryParams, metaData);
iOS (Objective-C)
// Unique Id for the dataset to manage.
#define DATA_ID @"tasks"
// Configuration options object.
// These override the options passed to init.
FHSyncConfig* conf = [[FHSyncConfig alloc] init];
conf.syncFrequency = 10;
// Parameters object to be passed to the cloud sync service.
// For example, to list the tasks that are assigned to a user called "Tom":
NSDictionary* query = @{@"assigned": @"Tom"};
// Extra params that will be sent to the back-end data handlers.
NSMutableDictionary* metaData = nil;
// Initialise Sync Client
FHSyncClient* syncClient = [[FHSyncClient alloc] initWithConfig:conf];
// Put a dataset under the management of the sync service.
[syncClient manageWithDataId:DATA_ID AndConfig:conf AndQuery:query AndMetaData:metaData];
iOS (Swift)
public let DATA_ID = "tasks" // Configuration options object. // These override the options passed to init. let conf = FHSyncConfig() conf.syncFrequency = 10 // Parameters object to be passed to the cloud sync service. // For example, to list the tasks that are assigned to a user called "Tom": let query = ["assigned": "Tom"] // Initialise Sync Client let syncClient = FHSyncClient(config: conf) // Put a dataset under the management of the sync service. syncClient.manageWithDataId(DATA_ID, andConfig:conf, andQuery:query)
.NET (C#)
以下のセクションでは、client は設定済みかつ初期化済みの FHSyncClient インスタンスです。Windows プラットフォーム上で FHSyncClient が管理するデータセットは、インターフェース IFHSyncModel を実装する必要があります。
/// The datasetId needs to be unique for your app and will be used to name the
/// collection in the cloud.
const string DatasetId = "tasks";
/// Query is a Dictionary of parameters to be sent to the server with each sync
/// operation. If the default MBaaS cloud implementation is used (which uses
/// $fh.db for data handlers), all the valid list options can be used here.
/// For example, to list the tasks that are assigned to a user called "Tom",
/// the query params should be
Dictionary<string, string> query = new Dictionary<string, string>
{
{"eq", "{"assigned", "Tom"}"}
};
/// When you manage a DataSet you may set new configuration parameters to
/// override the parameters for the sync client. If you do not wish to do this,
/// you may pass null into the FHSyncClient.manage method.
var config = new FHSyncConfig();
config.SyncFrequency = 100;
/// Put a dataset under the management of the sync service. Note that Task
/// is an implementation of the IFHSyncModel.
client.Manage<Task>(DatasetId, config, query);11.4. $fh.sync.doList
$fh.sync.doList(dataset_id, success, failure);
11.4.1. 詳細
データセットのレコード一覧を取得します。
11.4.2. 例
JavaScript
// Unique Id for the dataset to manage.
// This must correspond to an “act” function which represents the cloud portion of the sync contract.
var dataset_id = 'tasks';
$fh.sync.doList(dataset_id, function(res) {
// The data returned by the sync service.
// Always a full data set (even in the case of deltas).
console.log(res);
//res is a JSON object
for(var key in res){
if(res.hasOwnProperty(key)){
// Unique Id of the record, used for read, update & delete operations (string).
var uid = key;
// Record data, opaque to sync service.
var data = res[key].data;
// Unique hash value for this record
var hash = res[key].hash;
}
}
}, function(code, msg) {
// Error code. Currently only 'unknown_dataset' is possible
console.error(code);
// Optional free text message with additional information
console.error(msg);
});
Android (Java)
FHClient fhClient = FHSyncClient.getInstance();
// Unique Id for the dataset being manage.
String dataSetId = "photos";
// The data returned by the sync service.
// Always a full data set (even in the case of deltas).
JSONObject allData = fhClient.getSyncClient().list("photos");
Iterator<String> keysIterator = allData.keys();
List<Project> itemsToSync = new ArrayList<>();
while (keysIterator.hasNext()) {
// Unique Id of the record, used for read,
//update & delete operations (string).
String uid = keysIterator.next();
// Record data
JSONObject record = allData.getJSONObject(uid);
// The synced data object. In Android this can be a JSON serialized POJO
JSONObject dataObj = data.getJSONObject("data");
// Unique hash value for this record
String hash = records.getString("hash");
}
projects.addAll(itemsToSync);
bus.post(new ProjectsAvailable(new ArrayList<Project>(projects)));
iOS (Objective-C)
// Unique Id for the dataset to manage.
#define DATA_ID @"tasks"
// The data returned by the sync service.
// Always a full data set (even in the case of deltas).
NSDictionary* items = [syncClient listWithDataId:DATA_ID];
[items enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
// Unique Id of the record, used for read,
// update & delete operations (string).
NSString* uid = key; +
// Record data
NSDictionary* object = obj;
NSDictionary* dataObj = object[@"data"];
uid = object[@"uid"];
}];
iOS (Swift)
// Unique Id for the dataset to manage.
public let DATA_ID = "tasks"
// The data returned by the sync service.
// Always a full data set (even in the case of deltas).
let items = syncClient.listWithDataId(DATA_ID)
for (key, value) in items {
if let data = value["data"], let uid = value["uid"] {
// do something with item
}
}
.NET (C#)
/// The datasetId needs to be unique for your app and will be used to name the
/// collection in the cloud.
const string DatasetId = "tasks";
foreach (var item in client.List<Task>(DatasetId))
{
/// Do Something with item
}
11.5. $fh.sync.doCreate
$fh.sync.doCreate(dataset_id, data, success, failure);
11.5.1. 詳細
一意の ID に関連付けられているデータを更新します。
11.5.2. 例
JavaScript
var dataset_id = 'tasks';
// Record data to create, opaque to sync service.
var data = {
"name": "Organise widgets",
"time": Date.now() + 100000,
"user": "joe@bloggs.com"
};
$fh.sync.doCreate(dataset_id, data, function(res) {
// The update record which will be sent to the cloud
console.log(res);
}, function(code, msg) {
// Error code. One of 'unknown_dataset' or 'unknown_id'
console.error(code);
// Optional free text message with additional information
console.error(msg);
});
Android (Java)
String dataSetId = "tasks";
// Record data to create
JSONObject data = new JSONObject();
data.put("name", "Organise widgets");
data.put("time", new Date().getTime() + 100000);
data.put("user", "joe@bloggs.com");
syncClient.create(dataSetId, data);
iOS (Objective-C)
// Unique Id for the dataset to manage. #define DATA_ID @"tasks" NSDate* now = [NSDate date]; NSMutableDictionary* data = [NSMutableDictionary dictionary]; [data setObject:shoppingItem.name forKey:@"name"]; [data setObject:[NSNumber numberWithLongLong:[now timeIntervalSince1970]*1000] forKey:@"created"]; [syncClient createWithDataId:DATA_ID AndData:data];
iOS (Swift)
// Unique Id for the dataset to manage. public let DATA_ID = "tasks" let myItem: [String: AnyObject] = ["name": name, "created": created*1000] syncClient.createWithDataId(DATA_ID, andData: myItem)
.NET (C#)
以下のセクションでは、client は設定済みかつ初期化済みの FHSyncClient インスタンスです。Task は IFHSyncModel を実装するクラスで、string Name プロパティーを持っています。
/// The datasetId needs to be unique for your app and will be used to name the /// collection in the cloud. const string DatasetId = "tasks"; Task task = new Task(); task.Name = "task name"; client.Create(MainPage.DatasetId, task);
11.6. $fh.sync.doRead
$fh.sync.doRead(dataset_id, uid, success, failure);
11.6.1. 詳細
単一のデータレコードを読み取ります。
11.6.2. 例
JavaScript
var dataset_id = 'tasks';
// Unique Id of the record to read.
var uid = '42abcdefg';
$fh.sync.doRead(dataset_id, uid, function(data) {
// The record data
console.log(data.data); //the data fileds
console.log(data.hash); //the hash value of the data
}, function(code, msg) {
// Error code. One of 'unknown_dataset' or 'unknown_id'
console.error(code);
// Optional free text message with additional information
console.error(msg);
});
Android (Java)
//name of dataset to manage
String dataSetId = "tasks";
// Unique Id of the record to read.
String uid = "42abcdefg";
JSONObject record = FHSyncClient.getInstance().read(dataSetId, uid);
if (data != null) {
JSONObject document = record.getJSONObject("data");
String uid = record.getString("uid");
}
iOS (Objective-C)
// Unique Id for the dataset to manage. #define DATA_ID @"tasks" // The data returned by the sync service. // Always a full data set (even in the case of deltas). NSDictionary* item = [syncClient readWithDataId:DATA_ID AndUID:@"42abcdefg"];
iOS (Swift)
// Unique Id for the dataset to manage. public let DATA_ID = "tasks" // The data returned by the sync service. // Always a full data set (even in the case of deltas). let item = syncClient.readWithDataId(DATA_ID, andUID: "42abcdefg")
.NET (C#)
string datasetId = "tasks"; /// Unique Id of the record to read. string uid = "42abcdefg"; Task task = client.Read(datasetId, uid);
11.7. $fh.sync.doUpdate
$fh.sync.doUpdate(dataset_id, uid, data, success, failure);
11.7.1. 詳細
一意の ID に関連付けられているデータを更新します。
11.7.2. 例
JavaScript
var dataset_id = 'tasks';
// Unique Id of the record to update.
var uid = '42abcdefg';
// Record data to update. Note that you need to provide the FULL data to update.
$fh.sync.doRead(dataset_id, uid, function(data){
var fields = data.data;
fields.name = "Organise layouts";
$fh.sync.doUpdate(dataset_id, uid, fields, function(data) {
// The updated record which will be send to the cloud
console.log(data);
}, function(code, msg) {
// Error code. One of 'unknown_dataset' or 'unknown_id'
console.error(code);
// Optional free text message with additional information
console.error(msg);
});
});
Android (Java)
// name of dataset to manage
String dataSetId = "tasks";
// Unique Id of the record to read and update.
String uid = "42abcdefg";
// Fetch a record
JSONObject record = FHSyncClient.getInstance().read(dataSetId, uid);
// Fetch the data of the record and change a field
JSONObject data = record.getJSONObject("data");
data.set("newField","newValue");
// Update the data in the sync system
FHSyncClient.getInstance().update(dataSetId, uid, data);
iOS (Objective-C)
// Unique Id for the dataset to manage. #define DATA_ID @"tasks" // The Updated data NSDate* now = [NSDate date]; NSMutableDictionary* data = [NSMutableDictionary dictionary]; [data setObject:shoppingItem.name forKey:@"name"]; [data setObject:[NSNumber numberWithLongLong:[now timeIntervalSince1970]*1000] forKey:@"created"]; NSDictionary* item = [syncClient updateWithDataId:DATA_ID AndUID:@"42abcdefg" AndData:data];
iOS (Swift)
// Unique Id for the dataset to manage. public let DATA_ID = "tasks" // The Updated data let myItem: [String: AnyObject] = ["name": name, "created": created*1000] syncClient.updateWithDataId(DATA_ID, andUID: uid, andData: myItem)
.NET (C#)
string datasetId = "tasks"; /// Unique Id of the record to read. string uid = "42abcdefg"; Task task = client.Read(datasetId, uid); task.Name = "new name"; Task task = client.Update(datasetId, task);
11.8. $fh.sync.doDelete
$fh.sync.doDelete(dataset_id, uid, success, failure);
11.8.1. 詳細
一意の ID に関連付けられているデータを削除します。
11.8.2. 例
JavaScript
var dataset_id = 'tasks';
// Unique Id of the record to delete.
var uid = '42abcdefg';
$fh.sync.doDelete(dataset_id, uid, function(data) {
// The deleted record data sent to the cloud.
console.log(data);
}, function(code, msg) {
// Error code. One of 'unknown_dataset' or 'unknown_id'
console.error(code);
// Optional free text message with additional information
console.error(msg);
}
Android (Java)
// name of dataset to manage String dataSetId = "tasks"; // Unique Id of the record to remove. String uid = "42abcdefg"; FHSyncClient.getInstance().delete(dataSetId, uid);
iOS (Objective-C)
// Unique Id for the dataset to manage. #define DATA_ID @"tasks" NSDictionary* item = [syncClient deleteWithDataId:DATA_ID AndUID:@"42abcdefg"];
<div class="tab-pane" id="example-doDelete-swift">
// Unique Id for the dataset to manage. public let DATA_ID = "tasks" syncClient.deleteWithDataId(DATA_ID, andUID: uid)
.NET (C#)
string datasetId = "tasks"; /// Unique Id of the record to delete. string uid = "42abcdefg"; client.Delete(datasetId, uid);
11.9. $fh.sync.startSync
$fh.sync.startSync(dataset_id, success, failure)
11.9.1. 詳細
'sync_active' オプションが false に設定されている場合、sync loop を開始します。
11.9.2. 例
JavaScript
var dataset_id = 'tasks';
$fh.sync.startSync(dataset_id, function(){
console.log('sync loop started');
}, function(error){
console.log('failed to start sync loop. Error : ' + error);
});
Android (Java)
FHSyncListener が Activity または Fragment を参照する場合は、アクティビティのライフサイクル管理 を検討する必要があります。この状況では、pauseSync および resumeSync のメソッドが作成されます。また、同期を完全にシャットダウンする destroy メソッドもあります。
// Synchronization is automatically started by the FHSyncClient.init method.
// However, synchronization may be paused and resumed in the Activity
// lifecycle onPause and onResume methods.
@Override
public void onPause() {
super.onPause();
FHSyncClient.getInstance().pauseSync();
}
@Override
public void onResume() {
super.onResume();
FHSyncClient.getInstance().resumeSync(new FHSyncListener() { });
}
public void onDestroy() {
super.onDestroy();
FHSyncClient.getInstance().destroy();
}iOS (Objective-C)
iOS Synchronization API には startSync メソッドがありません。同期は init メソッドで開始されます。
iOS (Swift)
iOS Synchronization API には startSync メソッドがありません。同期は init メソッドで開始されます。
.NET (C#)
string datasetId = "tasks"; client.Start(datasetId);
11.10. $fh.sync.stopSync
$fh.sync.stopSync(dataset_id, success, failure)
11.10.1. 詳細
データセットの sync loop を停止します。
11.10.2. 例
JavaScript
var dataset_id = 'tasks';
$fh.sync.stopSync(dataset_id, function(){
console.log('sync loop stopped');
}, function(error){
console.log('failed to stop sync loop. Error : ' + error);
});
Android (Java)
stop 関数はデータセットの同期を停止しますが、FHSyncClient インスタンスにアタッチされている FHSyncListener は削除されません。
String dataSetId = "tasks"; FHSyncClient.getInstance().stop(dataSetId);
iOS (Objective-C)
// Unique Id for the dataset to manage. #define DATA_ID @"tasks" [syncClient stopWithDataId:DATA_ID];
iOS (Swift)
// Unique Id for the dataset to manage. public let DATA_ID = "tasks" syncClient.stopWithDataId(DATA_ID)
.NET (C#)
string datasetId = "tasks"; client.Stop(datasetId);
11.11. $fh.sync.doSync
$fh.sync.doSync(dataset_id, success, failure)
11.11.1. 詳細
sync_active が true の場合、sync loop をほぼ即座に (500 ミリ秒以内) 実行します。
11.11.2. 例
JavaScript
var dataset_id = 'tasks';
$fh.sync.doSync(dataset_id, function(){
console.log('sync loop will run');
}, function(error){
console.log('failed to run sync loop. Error : ' + error);
});
Android (Java)
Android SDK には doSync メソッドはありません。代わりに forceSync を使用してください。
iOS (Objective-C)
iOS Synchronization API には doSync メソッドがありません。代わりに forceSync を使用してください。
iOS (Swift)
iOS Synchronization API には doSync メソッドがありません。代わりに forceSync を使用してください。
NET (C#)
Windows Synchronization API には doSync メソッドがありません。代わりに forceSync を使用してください。
11.12. $fh.sync.forceSync
$fh.sync.forceSync(dataset_id, success, failure)
11.12.1. 詳細
sync_active が false の場合でも、sync loop をほぼ即座に (500 ミリ秒以内) 実行します。
11.12.2. 例
JavaScript
var dataset_id = 'tasks';
$fh.sync.forceSync(dataset_id, function(){
console.log('sync loop will run');
}, function(error){
console.log('failed to run sync loop. Error : ' + error);
});
Android (Java)
FHSyncClient が FHSyncClient.destroy() で破棄されている場合は、forceSync を呼び出す前に init を再度呼び出す必要があります。同期が一時停止されると同期ループは実行されたままになりますが、リスナーはアタッチされず、イベントは起動されません。
String dataSetId = "tasks"; FHSyncClient.getInstance().forceSync(dataSetId);
iOS (Objective-C)
// Unique Id for the dataset to manage. #define DATA_ID @"tasks" [syncClient forceSync:DATA_ID];
iOS (Swift)
// Unique Id for the dataset to manage. public let DATA_ID = "tasks" syncClient.forceSync(DATA_ID)
.NET (C#)
string datasetId = "tasks"; client.ForceSync(datasetId);

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.