Azure 移动应用程序 - 离线数据同步 - 应用程序不是 运行

Azure Mobile Apps - Offline Data sync - App is not running

以下是 Azure 移动应用程序的功能之一 - Office 数据同步

When your app is in offline mode, users can still create and modify data, which will be saved to a local store. When the app is back online, it can synchronize local changes with your Azure Mobile App backend.

根据上述,是否意味着本地更改的同步仅在应用程序在线时发生(用户需要明确打开应用程序)?或者当手机通过后台服务连接到互联网时,数据会自动同步到服务器?

正如 document 所说:

Changes are stored in a local database; once the device is back online, these changes are synced with the remote backend.

这意味着用户应该在同步数据之前先打开应用程序。

有关离线数据同步的概述,请参阅 Offline Data Sync in Azure Mobile Apps, particularly How offline synchronization works

对于同步操作本身,SDK 不会自动执行任何操作。您必须添加在计时器上同步的代码,或检测网络连接更改。如果您想将同步作为后台任务,则必须使用 OS 注册同步代码并在该代码中调用 PullAsync 和 PushAsync。

基本上,SDK 会为您跟踪更改并在您调用 PushAsync 时发送它们,但您的代码会在发生这种情况时进行管理。