iPhone : How to sync data with the web-service when internet is reachable?









up vote
0
down vote

favorite
1












I know how to check internet connection. Tell me how to sync app data.



How does the synchronization works when internet is available ?



My confusion :



I have app which uses the web-service to display data on iPhone and also on site. Now I can update user's work when the net is available by calling web-service at same time when user does some task.



But when internet is not available, I have to keep user's data locally(say SQLite) in iPhone and when the internet is reachable I have to update all the data on server.



For Example, 

If internet is reachable, user works on some task and I update the data on server at the dame time.

But Now internet is not reachable, user works on `N task`. I can not update on server, I have to wait for internet
How can I update all task on web-server at time?


So my question is :



How can I update all the data when net is available ?


Any link or code which can help me ?










share|improve this question























  • do you use Reachability class?
    – user784625
    Feb 2 '12 at 14:13










  • so what you actually want is a SQLlite crash course?!?
    – AnthonyBlake
    Feb 2 '12 at 14:59











  • @AnthonyBlake: I want basic knowledge of Sync process.
    – Devang
    Feb 2 '12 at 16:24














up vote
0
down vote

favorite
1












I know how to check internet connection. Tell me how to sync app data.



How does the synchronization works when internet is available ?



My confusion :



I have app which uses the web-service to display data on iPhone and also on site. Now I can update user's work when the net is available by calling web-service at same time when user does some task.



But when internet is not available, I have to keep user's data locally(say SQLite) in iPhone and when the internet is reachable I have to update all the data on server.



For Example, 

If internet is reachable, user works on some task and I update the data on server at the dame time.

But Now internet is not reachable, user works on `N task`. I can not update on server, I have to wait for internet
How can I update all task on web-server at time?


So my question is :



How can I update all the data when net is available ?


Any link or code which can help me ?










share|improve this question























  • do you use Reachability class?
    – user784625
    Feb 2 '12 at 14:13










  • so what you actually want is a SQLlite crash course?!?
    – AnthonyBlake
    Feb 2 '12 at 14:59











  • @AnthonyBlake: I want basic knowledge of Sync process.
    – Devang
    Feb 2 '12 at 16:24












up vote
0
down vote

favorite
1









up vote
0
down vote

favorite
1






1





I know how to check internet connection. Tell me how to sync app data.



How does the synchronization works when internet is available ?



My confusion :



I have app which uses the web-service to display data on iPhone and also on site. Now I can update user's work when the net is available by calling web-service at same time when user does some task.



But when internet is not available, I have to keep user's data locally(say SQLite) in iPhone and when the internet is reachable I have to update all the data on server.



For Example, 

If internet is reachable, user works on some task and I update the data on server at the dame time.

But Now internet is not reachable, user works on `N task`. I can not update on server, I have to wait for internet
How can I update all task on web-server at time?


So my question is :



How can I update all the data when net is available ?


Any link or code which can help me ?










share|improve this question















I know how to check internet connection. Tell me how to sync app data.



How does the synchronization works when internet is available ?



My confusion :



I have app which uses the web-service to display data on iPhone and also on site. Now I can update user's work when the net is available by calling web-service at same time when user does some task.



But when internet is not available, I have to keep user's data locally(say SQLite) in iPhone and when the internet is reachable I have to update all the data on server.



For Example, 

If internet is reachable, user works on some task and I update the data on server at the dame time.

But Now internet is not reachable, user works on `N task`. I can not update on server, I have to wait for internet
How can I update all task on web-server at time?


So my question is :



How can I update all the data when net is available ?


Any link or code which can help me ?







iphone objective-c ios cocoa-touch






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 2 '12 at 14:23

























asked Feb 2 '12 at 14:08









Devang

6,869135493




6,869135493











  • do you use Reachability class?
    – user784625
    Feb 2 '12 at 14:13










  • so what you actually want is a SQLlite crash course?!?
    – AnthonyBlake
    Feb 2 '12 at 14:59











  • @AnthonyBlake: I want basic knowledge of Sync process.
    – Devang
    Feb 2 '12 at 16:24
















  • do you use Reachability class?
    – user784625
    Feb 2 '12 at 14:13










  • so what you actually want is a SQLlite crash course?!?
    – AnthonyBlake
    Feb 2 '12 at 14:59











  • @AnthonyBlake: I want basic knowledge of Sync process.
    – Devang
    Feb 2 '12 at 16:24















do you use Reachability class?
– user784625
Feb 2 '12 at 14:13




do you use Reachability class?
– user784625
Feb 2 '12 at 14:13












so what you actually want is a SQLlite crash course?!?
– AnthonyBlake
Feb 2 '12 at 14:59





so what you actually want is a SQLlite crash course?!?
– AnthonyBlake
Feb 2 '12 at 14:59













@AnthonyBlake: I want basic knowledge of Sync process.
– Devang
Feb 2 '12 at 16:24




@AnthonyBlake: I want basic knowledge of Sync process.
– Devang
Feb 2 '12 at 16:24












3 Answers
3






active

oldest

votes

















up vote
3
down vote



accepted










Try to put a Field as isOfflinerecord in your database (In case If you are using Database) and when connectivity comes back update or Insert only those data.
This could be your initial step.






share|improve this answer



























    up vote
    1
    down vote













    This question might be able to help you. using the Reachability class from Apple.



    ` How to check for an active Internet connection on iOS or OSX?






    share|improve this answer






















    • I know how to check internet connection. Tell me something about syncing data
      – Devang
      Feb 2 '12 at 14:24










    • Well, the way to do that would be to make a request to the server every so often when there is internet, and download the latest updates, and save them locally. Depending on the size of your online database you could just download it all at once.
      – Amit Shah
      Feb 2 '12 at 14:27










    • oh !! and how to upload app data on server ?
      – Devang
      Feb 2 '12 at 14:28










    • Depending on how your server is set up, you would just send a POST request containing the data. Using NSURLConnection is the simplest HTTP library to use, but there are others.
      – Amit Shah
      Feb 2 '12 at 14:30










    • @Devang so you want a SQLLite crash course AND a webservices crash course?
      – AnthonyBlake
      Feb 2 '12 at 15:01

















    up vote
    1
    down vote













    use reachability class and then you can set a notifier that will notify when there will be a change of the network status



    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkNetworkStatus:) name:kReachabilityChangedNotification object:nil];

    hostReachable = [[Reachability reachabilityWithHostName: @"www.google.com"] retain];
    [hostReachable startNotifier];


    - (void) checkNetworkStatus:(NSNotification *)notice

    // called after network status changes

    NetworkStatus hostStatus = [hostReachable currentReachabilityStatus];
    switch (hostStatus)


    case NotReachable:

    break;


    case ReachableViaWiFi:


    break;


    case ReachableViaWWAN:


    break;









    share|improve this answer






















    • I know how to check internet connection. Tell me something about syncing data.
      – Devang
      Feb 2 '12 at 14:24










    • run the web service you have multiple times?
      – user784625
      Feb 2 '12 at 14:38






    • 1




      @Devang How you sync the data will depend on your server and what you are transmitting. It is entirely up to you how you do this and if you ask 10 developers, you will probably get 10 different solutions. I suggest you go and think about it and come up with your own solution as this is quite a broad question to ask.
      – Nick Bull
      Feb 2 '12 at 15:41










    • @NickBull : I dont have any basic knowledge. I am just asking for basic knowledge.
      – Devang
      Feb 2 '12 at 16:19










    • @Devang Seriously, if you don't have any idea where to start with this, then I think you need to start learning some more basics of programming
      – Nick Bull
      Feb 2 '12 at 21:40










    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f9113727%2fiphone-how-to-sync-data-with-the-web-service-when-internet-is-reachable%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    3
    down vote



    accepted










    Try to put a Field as isOfflinerecord in your database (In case If you are using Database) and when connectivity comes back update or Insert only those data.
    This could be your initial step.






    share|improve this answer
























      up vote
      3
      down vote



      accepted










      Try to put a Field as isOfflinerecord in your database (In case If you are using Database) and when connectivity comes back update or Insert only those data.
      This could be your initial step.






      share|improve this answer






















        up vote
        3
        down vote



        accepted







        up vote
        3
        down vote



        accepted






        Try to put a Field as isOfflinerecord in your database (In case If you are using Database) and when connectivity comes back update or Insert only those data.
        This could be your initial step.






        share|improve this answer












        Try to put a Field as isOfflinerecord in your database (In case If you are using Database) and when connectivity comes back update or Insert only those data.
        This could be your initial step.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 17 '12 at 13:40









        Heena

        1,51012752




        1,51012752






















            up vote
            1
            down vote













            This question might be able to help you. using the Reachability class from Apple.



            ` How to check for an active Internet connection on iOS or OSX?






            share|improve this answer






















            • I know how to check internet connection. Tell me something about syncing data
              – Devang
              Feb 2 '12 at 14:24










            • Well, the way to do that would be to make a request to the server every so often when there is internet, and download the latest updates, and save them locally. Depending on the size of your online database you could just download it all at once.
              – Amit Shah
              Feb 2 '12 at 14:27










            • oh !! and how to upload app data on server ?
              – Devang
              Feb 2 '12 at 14:28










            • Depending on how your server is set up, you would just send a POST request containing the data. Using NSURLConnection is the simplest HTTP library to use, but there are others.
              – Amit Shah
              Feb 2 '12 at 14:30










            • @Devang so you want a SQLLite crash course AND a webservices crash course?
              – AnthonyBlake
              Feb 2 '12 at 15:01














            up vote
            1
            down vote













            This question might be able to help you. using the Reachability class from Apple.



            ` How to check for an active Internet connection on iOS or OSX?






            share|improve this answer






















            • I know how to check internet connection. Tell me something about syncing data
              – Devang
              Feb 2 '12 at 14:24










            • Well, the way to do that would be to make a request to the server every so often when there is internet, and download the latest updates, and save them locally. Depending on the size of your online database you could just download it all at once.
              – Amit Shah
              Feb 2 '12 at 14:27










            • oh !! and how to upload app data on server ?
              – Devang
              Feb 2 '12 at 14:28










            • Depending on how your server is set up, you would just send a POST request containing the data. Using NSURLConnection is the simplest HTTP library to use, but there are others.
              – Amit Shah
              Feb 2 '12 at 14:30










            • @Devang so you want a SQLLite crash course AND a webservices crash course?
              – AnthonyBlake
              Feb 2 '12 at 15:01












            up vote
            1
            down vote










            up vote
            1
            down vote









            This question might be able to help you. using the Reachability class from Apple.



            ` How to check for an active Internet connection on iOS or OSX?






            share|improve this answer














            This question might be able to help you. using the Reachability class from Apple.



            ` How to check for an active Internet connection on iOS or OSX?







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited May 23 '17 at 12:11









            Community

            11




            11










            answered Feb 2 '12 at 14:20









            Amit Shah

            3,89221726




            3,89221726











            • I know how to check internet connection. Tell me something about syncing data
              – Devang
              Feb 2 '12 at 14:24










            • Well, the way to do that would be to make a request to the server every so often when there is internet, and download the latest updates, and save them locally. Depending on the size of your online database you could just download it all at once.
              – Amit Shah
              Feb 2 '12 at 14:27










            • oh !! and how to upload app data on server ?
              – Devang
              Feb 2 '12 at 14:28










            • Depending on how your server is set up, you would just send a POST request containing the data. Using NSURLConnection is the simplest HTTP library to use, but there are others.
              – Amit Shah
              Feb 2 '12 at 14:30










            • @Devang so you want a SQLLite crash course AND a webservices crash course?
              – AnthonyBlake
              Feb 2 '12 at 15:01
















            • I know how to check internet connection. Tell me something about syncing data
              – Devang
              Feb 2 '12 at 14:24










            • Well, the way to do that would be to make a request to the server every so often when there is internet, and download the latest updates, and save them locally. Depending on the size of your online database you could just download it all at once.
              – Amit Shah
              Feb 2 '12 at 14:27










            • oh !! and how to upload app data on server ?
              – Devang
              Feb 2 '12 at 14:28










            • Depending on how your server is set up, you would just send a POST request containing the data. Using NSURLConnection is the simplest HTTP library to use, but there are others.
              – Amit Shah
              Feb 2 '12 at 14:30










            • @Devang so you want a SQLLite crash course AND a webservices crash course?
              – AnthonyBlake
              Feb 2 '12 at 15:01















            I know how to check internet connection. Tell me something about syncing data
            – Devang
            Feb 2 '12 at 14:24




            I know how to check internet connection. Tell me something about syncing data
            – Devang
            Feb 2 '12 at 14:24












            Well, the way to do that would be to make a request to the server every so often when there is internet, and download the latest updates, and save them locally. Depending on the size of your online database you could just download it all at once.
            – Amit Shah
            Feb 2 '12 at 14:27




            Well, the way to do that would be to make a request to the server every so often when there is internet, and download the latest updates, and save them locally. Depending on the size of your online database you could just download it all at once.
            – Amit Shah
            Feb 2 '12 at 14:27












            oh !! and how to upload app data on server ?
            – Devang
            Feb 2 '12 at 14:28




            oh !! and how to upload app data on server ?
            – Devang
            Feb 2 '12 at 14:28












            Depending on how your server is set up, you would just send a POST request containing the data. Using NSURLConnection is the simplest HTTP library to use, but there are others.
            – Amit Shah
            Feb 2 '12 at 14:30




            Depending on how your server is set up, you would just send a POST request containing the data. Using NSURLConnection is the simplest HTTP library to use, but there are others.
            – Amit Shah
            Feb 2 '12 at 14:30












            @Devang so you want a SQLLite crash course AND a webservices crash course?
            – AnthonyBlake
            Feb 2 '12 at 15:01




            @Devang so you want a SQLLite crash course AND a webservices crash course?
            – AnthonyBlake
            Feb 2 '12 at 15:01










            up vote
            1
            down vote













            use reachability class and then you can set a notifier that will notify when there will be a change of the network status



            [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkNetworkStatus:) name:kReachabilityChangedNotification object:nil];

            hostReachable = [[Reachability reachabilityWithHostName: @"www.google.com"] retain];
            [hostReachable startNotifier];


            - (void) checkNetworkStatus:(NSNotification *)notice

            // called after network status changes

            NetworkStatus hostStatus = [hostReachable currentReachabilityStatus];
            switch (hostStatus)


            case NotReachable:

            break;


            case ReachableViaWiFi:


            break;


            case ReachableViaWWAN:


            break;









            share|improve this answer






















            • I know how to check internet connection. Tell me something about syncing data.
              – Devang
              Feb 2 '12 at 14:24










            • run the web service you have multiple times?
              – user784625
              Feb 2 '12 at 14:38






            • 1




              @Devang How you sync the data will depend on your server and what you are transmitting. It is entirely up to you how you do this and if you ask 10 developers, you will probably get 10 different solutions. I suggest you go and think about it and come up with your own solution as this is quite a broad question to ask.
              – Nick Bull
              Feb 2 '12 at 15:41










            • @NickBull : I dont have any basic knowledge. I am just asking for basic knowledge.
              – Devang
              Feb 2 '12 at 16:19










            • @Devang Seriously, if you don't have any idea where to start with this, then I think you need to start learning some more basics of programming
              – Nick Bull
              Feb 2 '12 at 21:40














            up vote
            1
            down vote













            use reachability class and then you can set a notifier that will notify when there will be a change of the network status



            [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkNetworkStatus:) name:kReachabilityChangedNotification object:nil];

            hostReachable = [[Reachability reachabilityWithHostName: @"www.google.com"] retain];
            [hostReachable startNotifier];


            - (void) checkNetworkStatus:(NSNotification *)notice

            // called after network status changes

            NetworkStatus hostStatus = [hostReachable currentReachabilityStatus];
            switch (hostStatus)


            case NotReachable:

            break;


            case ReachableViaWiFi:


            break;


            case ReachableViaWWAN:


            break;









            share|improve this answer






















            • I know how to check internet connection. Tell me something about syncing data.
              – Devang
              Feb 2 '12 at 14:24










            • run the web service you have multiple times?
              – user784625
              Feb 2 '12 at 14:38






            • 1




              @Devang How you sync the data will depend on your server and what you are transmitting. It is entirely up to you how you do this and if you ask 10 developers, you will probably get 10 different solutions. I suggest you go and think about it and come up with your own solution as this is quite a broad question to ask.
              – Nick Bull
              Feb 2 '12 at 15:41










            • @NickBull : I dont have any basic knowledge. I am just asking for basic knowledge.
              – Devang
              Feb 2 '12 at 16:19










            • @Devang Seriously, if you don't have any idea where to start with this, then I think you need to start learning some more basics of programming
              – Nick Bull
              Feb 2 '12 at 21:40












            up vote
            1
            down vote










            up vote
            1
            down vote









            use reachability class and then you can set a notifier that will notify when there will be a change of the network status



            [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkNetworkStatus:) name:kReachabilityChangedNotification object:nil];

            hostReachable = [[Reachability reachabilityWithHostName: @"www.google.com"] retain];
            [hostReachable startNotifier];


            - (void) checkNetworkStatus:(NSNotification *)notice

            // called after network status changes

            NetworkStatus hostStatus = [hostReachable currentReachabilityStatus];
            switch (hostStatus)


            case NotReachable:

            break;


            case ReachableViaWiFi:


            break;


            case ReachableViaWWAN:


            break;









            share|improve this answer














            use reachability class and then you can set a notifier that will notify when there will be a change of the network status



            [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkNetworkStatus:) name:kReachabilityChangedNotification object:nil];

            hostReachable = [[Reachability reachabilityWithHostName: @"www.google.com"] retain];
            [hostReachable startNotifier];


            - (void) checkNetworkStatus:(NSNotification *)notice

            // called after network status changes

            NetworkStatus hostStatus = [hostReachable currentReachabilityStatus];
            switch (hostStatus)


            case NotReachable:

            break;


            case ReachableViaWiFi:


            break;


            case ReachableViaWWAN:


            break;










            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Feb 2 '12 at 17:30









            DShah

            7,752961120




            7,752961120










            answered Feb 2 '12 at 14:18









            user784625

            99051936




            99051936











            • I know how to check internet connection. Tell me something about syncing data.
              – Devang
              Feb 2 '12 at 14:24










            • run the web service you have multiple times?
              – user784625
              Feb 2 '12 at 14:38






            • 1




              @Devang How you sync the data will depend on your server and what you are transmitting. It is entirely up to you how you do this and if you ask 10 developers, you will probably get 10 different solutions. I suggest you go and think about it and come up with your own solution as this is quite a broad question to ask.
              – Nick Bull
              Feb 2 '12 at 15:41










            • @NickBull : I dont have any basic knowledge. I am just asking for basic knowledge.
              – Devang
              Feb 2 '12 at 16:19










            • @Devang Seriously, if you don't have any idea where to start with this, then I think you need to start learning some more basics of programming
              – Nick Bull
              Feb 2 '12 at 21:40
















            • I know how to check internet connection. Tell me something about syncing data.
              – Devang
              Feb 2 '12 at 14:24










            • run the web service you have multiple times?
              – user784625
              Feb 2 '12 at 14:38






            • 1




              @Devang How you sync the data will depend on your server and what you are transmitting. It is entirely up to you how you do this and if you ask 10 developers, you will probably get 10 different solutions. I suggest you go and think about it and come up with your own solution as this is quite a broad question to ask.
              – Nick Bull
              Feb 2 '12 at 15:41










            • @NickBull : I dont have any basic knowledge. I am just asking for basic knowledge.
              – Devang
              Feb 2 '12 at 16:19










            • @Devang Seriously, if you don't have any idea where to start with this, then I think you need to start learning some more basics of programming
              – Nick Bull
              Feb 2 '12 at 21:40















            I know how to check internet connection. Tell me something about syncing data.
            – Devang
            Feb 2 '12 at 14:24




            I know how to check internet connection. Tell me something about syncing data.
            – Devang
            Feb 2 '12 at 14:24












            run the web service you have multiple times?
            – user784625
            Feb 2 '12 at 14:38




            run the web service you have multiple times?
            – user784625
            Feb 2 '12 at 14:38




            1




            1




            @Devang How you sync the data will depend on your server and what you are transmitting. It is entirely up to you how you do this and if you ask 10 developers, you will probably get 10 different solutions. I suggest you go and think about it and come up with your own solution as this is quite a broad question to ask.
            – Nick Bull
            Feb 2 '12 at 15:41




            @Devang How you sync the data will depend on your server and what you are transmitting. It is entirely up to you how you do this and if you ask 10 developers, you will probably get 10 different solutions. I suggest you go and think about it and come up with your own solution as this is quite a broad question to ask.
            – Nick Bull
            Feb 2 '12 at 15:41












            @NickBull : I dont have any basic knowledge. I am just asking for basic knowledge.
            – Devang
            Feb 2 '12 at 16:19




            @NickBull : I dont have any basic knowledge. I am just asking for basic knowledge.
            – Devang
            Feb 2 '12 at 16:19












            @Devang Seriously, if you don't have any idea where to start with this, then I think you need to start learning some more basics of programming
            – Nick Bull
            Feb 2 '12 at 21:40




            @Devang Seriously, if you don't have any idea where to start with this, then I think you need to start learning some more basics of programming
            – Nick Bull
            Feb 2 '12 at 21:40

















             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f9113727%2fiphone-how-to-sync-data-with-the-web-service-when-internet-is-reachable%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Top Tejano songwriter Luis Silva dead of heart attack at 64

            天津地下鉄3号線

            How to fill missing numeric if any value in a subset is missing, all other columns with the same subset are missing