public async Task <bool> SyncAsync() { try { await _mobileServiceSyncContext.PushAsync(); await PullLatestAsync(); return(true); } catch (MobileServicePushFailedException exception) { if (null != exception.PushResult) { foreach (var error in exception.PushResult.Errors) { if (MobileServiceTableOperationKind.Update == error.OperationKind && null != error.Result) { // Update failed, revert to server's copy await error.CancelAndUpdateItemAsync(error.Result); } else { // Discard local change await error.CancelAndDiscardItemAsync(); } } } return(false); } }
/// <summary> /// Replays all pending local operations against the remote tables. /// </summary> public static Task PushAsync(this IMobileServiceSyncContext context) => context.PushAsync(CancellationToken.None);