Sample App

Getting Started - iOS Setup

Step 1- Download the iOS API Sample app

Version 1.0

Extract and open the sample app

Step 2- Copy SynCloud Files

Drag and drop all the files and folders within the SynCloud App Folder and subfolders into your app.

Step 3- Link Required Frameworks

Add the following frameworks to your project

  • libSynCloud.a -- from the sample app
  • AWSIOSSDK.framework -- also from the sample app
  • CFNetwork
  • libz.dylib
  • SystemConfiguration
  • StoreKit
  • Security
  • libz.dylib
  • MobileCoreServices.framework

Step 4- Set up an account with Amazon SimpleDB

Go to http://aws.amazon.com/simpledb/ and join Amazon Web Services.

Note that this is a paid service where you pay based on usage. The billing, ie "How much will this cost me" is very difficult to understand, however in my own experience, I have used this API in my app Inventory Tracker and have yet to receive a single bill from Amazon. I would consider these costs insignificant unless you are going to be using this on a massive scale.

In your project, open Syncloud_config.m and add the app ID and Secret Key from SimpleDB into your app.

Step 5- Set up an account with SocialScoresAPI.com

Sign up at SynCloudAPI.com and create a new App. You will be given a new API ID and Key for this new app. A new registration comes with a free trial period.

Note registration to use this API does come at a monthly cost, but keep in mind that you will be able to charge users for using your service.

In your project, open Syncloud_config.m and add the app ID and Secret Key from SynCloud app.

Step 6- Configuration

Open Syncloud_config.m and configure a few app Sync variables. A description of each can be found in the .m file

Step 7- Add CoreData Fields

Any tables that you wish to sync must have the following fields added to their entity definition.

  • sync_id (String)
  • lastSyncTimeStamp (double)
  • lastModTimeStamp (double)

You're ready to go!

Getting Started - Use it

1- Initialize the SyncService.

In your AppDelegate, ApplicationDidLaunch method, you should setup the SyncService

[[SyncService sharedService] setupWithWindow:dg.window andNavController:self.navigationController andCoreDataContext:self.managedObjectContext]; //ONLY do this on your first launch. It will automatically create any domains you need created to your //SimpleDB Account. If you add tables to your kSyncTables configuration, you should run this again. [[SyncService sharedService]createDomains];

Note that in your AppDelegate, where the ManagedObjectContext is created, it must be created with the NSMainQueueConcurrencyType concurrancy type

_managedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType];

2- Show the SyncSettingsController

Add a button in your project and when pressed, pushed the supplied SyncSettingsController. This will handle account creation, subscriptions, enabling / disabling, ect.

3- Add Pre and Post Edit methods

For your synced core data objects, you should call

-[[SyncService sharedService]prepareToEditRecord:[coreDataObject toSimpleDbObject]];// prior to editing an object
and
-[[SyncService sharedService]didEditRecord:[coreDataObject toSimpleDbObject]];// after editing an object

Note that these methods are contained in a category file so you must add an import

#import "NSManagedObject+syncloud.h"

There are many other ways you can use the API. See the documentation and the example code for various uses. Note this example code is still being expanded.

4- Add Automatic reloading

You may want to add a refresh call to your view controllers to refresh its data after a full sync has completed. Note that this is done automatically if you are using NSFetchedResultsControllers

You can do this by Implementing the SyncServiceDelegate protocol, then call

[[SyncService sharedService] setDelegate:self]

in your viewWillAppear: method

Implement the protocol by adding a

-(void)refreshData { //call viewWillAppear or whatever method you use to load your data [self.tableView reloadData]; }

Debugging server records

to view and edit your domains, please use the Amazon supplied javascript scratch pad to directly access the data stored to your SimpleDB account http://aws.amazon.com/code/developertools/1137

LICENSE

This software may NOT be used in any free or commercial applications without the express consent of iParty! Mobile or Logan Sease. This software and/or its source code should not be distributed under any circumstances. Logan Sease and iParty! Mobile maintain all intellectual property rights to original source code contained with in this project and to the processes performed by it, including and especially the data syncing algorithm used by this software. The use of this software is done free of any warantee or of any liablities from Logan Sease or iParty! Mobile. We make absolutely no guarantees about the functionality contained or offered within. By using this software within your project, you hereby agree to the terms of this license.