Objective c 如何构建在离线输入数据时同步的应用程序?

Objective c 如何构建在离线输入数据时同步的应用程序?,objective-c,ios,database,Objective C,Ios,Database,比如说,我用iphone应用程序构建了一个todo应用程序,用某种集中式数据库构建了一个web应用程序。如果我在没有互联网连接的情况下在iphone上添加TODO,我显然无法在web应用程序上看到它们。由于脱机时无法发出API请求,因此数据不在数据库中 为了防止脱机时添加的任务丢失,您是否将它们存储在本地,然后在建立internet连接时进行API调用以创建这些任务并将它们添加到数据库中 在iOS中如何做到这一点?我只是在本地构建对象吗?您如何使它知道特定任务不在数据库中,并且应该进行API调用

比如说,我用iphone应用程序构建了一个todo应用程序,用某种集中式数据库构建了一个web应用程序。如果我在没有互联网连接的情况下在iphone上添加TODO,我显然无法在web应用程序上看到它们。由于脱机时无法发出API请求,因此数据不在数据库中

为了防止脱机时添加的任务丢失,您是否将它们存储在本地,然后在建立internet连接时进行API调用以创建这些任务并将它们添加到数据库中


在iOS中如何做到这一点?我只是在本地构建对象吗?您如何使它知道特定任务不在数据库中,并且应该进行API调用以使其生效

您需要将所有数据存储在本地DB中,然后检查internet连接是否可用。如果internet可用,则通过API调用将数据发送到web,然后如果您收到服务器的响应,则从本地DB中删除数据。 这种方法在从服务器得到响应后删除ur本地数据库的每一行

对于此实现,您可以有:

-  create a database on mobile
-  Register User on Server, After registering client should get a response from server and a timestamp.
-  Save timestamp and register a Pending Intent for 12 / 24 hrs to Start a Background Service that would Sync the Data to Server.
-  In case of no availability of Internet while Service wants to Sync data, we should have a Broadcast Receiver that check for internet connectivity, and as soon as Internet is available it would silently Start Service (Sync Service) in background and send data to Server.
-  Server would again send a response with timestamp, on receiving timestamp we delete our local Database, and repeat step 3. This cycle will keep on repeating.

我认为这应该符合目的。关于如何实现这一点,请留下评论。

您需要将所有数据存储在本地数据库中,然后检查internet连接是否可用。如果internet可用,请通过API调用将数据发送到web,如果收到服务器的响应,则从本地数据库中删除数据。 这种方法在从服务器得到响应后删除ur本地数据库的每一行

对于此实现,您可以有:

-  create a database on mobile
-  Register User on Server, After registering client should get a response from server and a timestamp.
-  Save timestamp and register a Pending Intent for 12 / 24 hrs to Start a Background Service that would Sync the Data to Server.
-  In case of no availability of Internet while Service wants to Sync data, we should have a Broadcast Receiver that check for internet connectivity, and as soon as Internet is available it would silently Start Service (Sync Service) in background and send data to Server.
-  Server would again send a response with timestamp, on receiving timestamp we delete our local Database, and repeat step 3. This cycle will keep on repeating.
我认为这应该符合目的。在如何实施的情况下,请留下评论