{"id":32320618,"url":"https://github.com/convertigo/c8osdk-ios","last_synced_at":"2026-02-23T03:02:12.907Z","repository":{"id":56904122,"uuid":"92059949","full_name":"convertigo/c8osdk-ios","owner":"convertigo","description":"This is the Convertigo SDK for iOS. Developers can use this SDK to access all back end service provided by Convertigo mBaaS such as orchestrations, connectors data synchronization push notifications and remote logging","archived":false,"fork":false,"pushed_at":"2020-07-16T08:14:17.000Z","size":7023,"stargazers_count":6,"open_issues_count":1,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-11-12T00:20:14.655Z","etag":null,"topics":["c8o-instance","convertigo","convertigo-mbaas","convertigo-server","couchbase-lite","offline","offline-app","sdk"],"latest_commit_sha":null,"homepage":"http://www.convertigo.com","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/convertigo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-22T13:59:50.000Z","updated_at":"2023-11-15T06:38:04.000Z","dependencies_parsed_at":"2022-08-21T01:50:48.232Z","dependency_job_id":null,"html_url":"https://github.com/convertigo/c8osdk-ios","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/convertigo/c8osdk-ios","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/convertigo%2Fc8osdk-ios","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/convertigo%2Fc8osdk-ios/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/convertigo%2Fc8osdk-ios/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/convertigo%2Fc8osdk-ios/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/convertigo","download_url":"https://codeload.github.com/convertigo/c8osdk-ios/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/convertigo%2Fc8osdk-ios/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29735909,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-23T02:24:00.660Z","status":"ssl_error","status_checked_at":"2026-02-23T02:22:56.087Z","response_time":90,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c8o-instance","convertigo","convertigo-mbaas","convertigo-server","couchbase-lite","offline","offline-app","sdk"],"created_at":"2025-10-23T12:00:02.526Z","updated_at":"2026-02-23T03:02:12.888Z","avatar_url":"https://github.com/convertigo.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://www.convertigo.com/wp-content/themes/EightDegree/images/logo_convertigo.png\"\u003e\n  \u003ch2 align=\"center\"\u003e C8oSDK iOS\u003c/h2\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/License-Apache%202.0-blue.svg\" alt=\"License\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://travis-ci.org/convertigo/c8osdk-ios\"\u003e\u003cimg\n  src=\"https://travis-ci.org/convertigo/c8osdk-ios.svg?branch=master\" alt=\"Travis Status\"\u003e\u003c/a\u003e\n\u003c/a\u003e \n\u003c/p\u003e\n\n## TOC ##\n\n- [TOC](#toc)\n- [Introduction](#introduction)\n\t- [About SDKs](#about-sdks)\n\t- [About Convertigo Platform](#about-convertigo-platform)\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Documentation](#documentation)\n\t- [Initializing a Convertigo Endpoint](#initializing-a-convertigo-endpoint)\n\t- [Advanced instance settings](#advanced-instance-settings)\n\t- [Calling a Convertigo Requestable](#calling-a-convertigo-requestable)\n\t- [Call parameters](#call-parameters)\n\t- [Working with threads](#working-with-threads)\n\t- [Chaining calls](#chaining-calls)\n\t- [Handling failures](#handling-failures)\n\t- [Writing the device logs to the Convertigo server](#writing-the-device-logs-to-the-convertigo-server)\n\t\t- [Basic](#basic)\n\t\t- [Advanced](#advanced)\n\t- [Using the Local Cache](#using-the-local-cache)\n\t- [Using the Full Sync](#using-the-full-sync)\n\t- [Replicating Full Sync databases](#replicating-full-sync-databases)\n\t- [Replicating Full Sync databases with continuous flag](#replicating-full-sync-databases-with-continuous-flag)\n\t- [Full Sync FS_LIVE requests](#full-sync-fs_live-requests)\n\t- [Full Sync Change Listener](#full-sync-change-listener)\n- [Building c8osdk-ios](#building-c8osdk-ios)\n\n## Introduction ##\n\n### About SDKs ###\n\nThis is the Convertigo library for native swift iOS\n\nConvertigo Client SDK is a set of libraries used by mobile or Windows desktop applications to access Convertigo Server services. An application using the SDK can easily access Convertigo services such as Sequences and Transactions.\n\nThe Client SDK will abstract the programmer from handling the communication protocols, local cache, FullSync off line data management, UI thread management and remote logging. So the developer can focus on building the application.\n\nClient SDK is available for:\n* [Android Native](https://github.com/convertigo/c8osdk-android) apps as a standard Gradle dependency\n* [iOS native](https://github.com/convertigo/c8osdk-ios) apps as a standard Cocoapod\n* [React Native](https://github.com/convertigo/react-native-c8osdk) as a NPM package\n* [Google Angular framework](https://github.com/convertigo/c8osdk-angular) as typescript an NPM package\n* [Vue.js](https://github.com/convertigo/c8osdk-js), [ReactJS](https://github.com/convertigo/c8osdk-js), [AngularJS](https://github.com/convertigo/c8osdk-js) Framework, or any [Javascript](https://github.com/convertigo/c8osdk-js) project as a standard Javascript NPM package\n* [Windows desktop](https://github.com/convertigo/c8osdk-dotnet) or [Xamarin apps](https://github.com/convertigo/c8osdk-dotnet) as Nugets or Xamarin Components\n\n\nThis current package is the Native iOS SDK. For others SDKs see official [Convertigo Documentation.](https://www.convertigo.com/document/all/cmp-7/7-5-1/reference-manual/convertigo-mbaas-server/convertigo-client-sdk/programming-guide/)\n\n### About Convertigo Platform ###\n\nConvertigo Mobility Platform supports native iOS developers. Services brought by the platform are available for iOS clients applications thanks to the Convertigo MBaaS SDK. SDK provides an iOS framework you can use to access Convertigo Server’s services such as:\n\n- Connectors to back-end data (SQL, NoSQL, REST/SOAP, SAP, - WEB HTML, AS/400, Mainframes)\n- Server Side Business Logic (Protocol transform, Business logic augmentation, ...)\n- Automatic offline replicated databases with FullSync technology\n- Security and access control (Identity managers, LDAP , SAML, oAuth)\n- Server side Cache\n- Push notifications (APND, GCM)\n- Auditing Analytics and logs (SQL, and Google Analytics)\n\n[Convertigo Technology Overview](http://download.convertigo.com/webrepository/Marketing/ConvertigoTechnologyOverview.pdf)\n\n[Access Convertigo mBaaS technical documentation](http://www.convertigo.com/document/latest/)\n\n[Access Convertigo SDK Documentations](https://www.convertigo.com/document/all/cmp-7/7-5-1/reference-manual/convertigo-mbaas-server/convertigo-client-sdk/)\n\n## Requirements ##\n\n* Cocoapods \u003e= 1.5.3\n* Xcode \u003e= 9.4\n\n## Installation ##\nCreate a PodFile with :\n```pod\n    use_frameworks!\n\n\ttarget 'MyApp' do\n\t  pod 'C8oSDK', '2.3.3'\n\tend\n```\nThen type:\n\n```shell\n$ pod install\n```\n\nRestart Xcode and open the .xcworkspace\n\nAnd there you go !\n\n## Documentation ##\n\nFull documentation is available [here](https://www.convertigo.com/document/all/cmp-7/7-5-1/reference-manual/convertigo-mbaas-server/convertigo-client-sdk/programming-guide/)\n\n### Initializing a Convertigo Endpoint ###\n\n\nYou can have as many C8o instance,pointing to a same or different endpoint. Each instance handles its own session and settings. We strongly recommend using a single C8o instance per application because server licensing can based on the number of sessions used.\n\n```swift\nimport C8o\n\n// In swift there is two ways to handle errors :\n// We can either choose to don't care about errors using the following syntax (this may produce in case of error an \"EXC_BAD_INSTRUCTION\")\n\nlet c8o : C8o = try! C8o(endpoint: \"https://demo.convertigo.net/cems/projects/sampleMobileCtfGallery\")\n\t\n// or we can choose to use do/catch syntax that will allow us to catch errors\ndo{\n\tlet c8o : C8o = try C8o(endpoint: \"https://demo.convertigo.net/cems/projects/sampleMobileCtfGallery\")\n}\ncatch let e as NSError{\n\tprint(e.description\n}\n// the C8o instance is ready to interact over https with the demo.convertigo.net server, using sampleMobileUsDirectoryDemo as default project.\n```\n\t\n### Advanced instance settings ###\n\nThe endpoint is the mandatory setting to get a C8o instance, but there is additional settings through the C8oSettings class.  \nA C8oSettings instance should be passed after the endpoint. Settings are copied inside the C8o instance and a C8oSettings instance can be modified and reused after the C8o constructor.  \nSetters of C8oSettings always return its own instance and can be chained.  \nA C8oSettings can be instantiated from an existing C8oSettings or C8o instance.\n\n```swift \nimport C8o\n// The common way\nvar c8o : C8o = try! C8o(endpoint: \"https://demo.convertigo.net/cems/projects/sampleMobileCtfGallery\", c8oSettings: C8oSettings().setDefaultDatabaseName(\"mydb_fullsync\").setTimeout(30000))\n\n// The verbose way\nlet endpoint : String = \"https://demo.convertigo.net/cems/projects/sampleMobileCtfGallery\"\nlet c8oSettings : C8oSettings = C8oSettings()\nc8oSettings.setDefaultDatabaseName(\"mydb_fullsync\")\nc8oSettings.setTimeout(30000)\nc8o = try! C8o(endpoint: endpoint, c8oSettings: c8oSettings)\n\n// customize existing settings\nvar customSettings : C8oSettings = C8oSettings(c8oSettings: c8oSettings).setTimeout(60000);\n// or from a C8o instance\ncustomSettings = C8oSettings(c8oSettings: c8o).setTimeout(60000);\n\t\t\n// all settings can be retrieve from a C8o or C8oSettings instance\nlet timeout : Int = c8o.timeout\n```\n\n### Calling a Convertigo Requestable ###\n\nWith a C8o instance you can call Convertigo Sequence and Transaction or make query to your local FullSync database. You must specify the result type you want: an XML Document or a JSON Object response.\n  \nReturning JSON:   \nJust use the `c8o.callJson` method to request a JSON response.\n\n```swift\nimport SwiftyJSON\n\n// c8o is a C8o instance\nlet jObject : JSON = try! c8o.callJson(\".getSimpleData\").sync()!\n\n// You now have JSON object that you can use in your app!\n```\n\nReturning XML:  \nJust use the c8o.callXml method to request a XML response.\n```swift\nimport AEXML\n\n// c8o is a C8o instance\nlet document : AEXMLDocument = try! c8o.callXml(\".getSimpleData\").sync()!\n```\n\n### Call parameters ###\n\nThe call method expects the requester string of the following syntax:\n\n- For a transaction: [project].connector.transaction  \n- For a sequence: [project].sequence\n\n\nThe project name is optional, i.e. if not specified, the project specified in the endpoint will be used.  \nConvertigo requestables generally need key/value parameters. The key is always a string and the value can be any object but a string is the standard case.  \nHere a sample with JSON but this would be the same for XML calls:\n\n```swift\n// the common way with parameters\nlet JObject : JSON = try! c8o.callJson(\".getSimpleData\",\n\t\t\tparameters:\n\t\t\t\"firstname\", \"John\",\n\t\t\t\"lastname\", \"Do\"\n)!.sync()!\n\n// the verbose way\nvar parameters : Dictionary = Dictionary()\nparameters[\"firstname\"] = \"John\"\nparameters[\"lastname\"] = \"Do\"\nlet JSONObject : JSON = try! c8o.callJson(\".getSimpleData\", parameters: parameters)!.sync()!\n```\n\t\n### Working with threads ###\n\nMaybe you noticed that the calls methods doesn’t return the result directly and that all the sample code chains to the `.sync()` method.  \nThis is because the call methods return a `C8oPromise` instance. That allows the developer to choose if he wants to block the current thread, make an async request or get the response in a callback.  \nThe `.sync()` method locks the current thread and return the result as soon as it’s available. Of course this should not be used in a UI thread as this will result to a frozen UI until data is returned by the server. You should use the `.sync()` method only in worker threads.  \n\n```swift\n// lock the current thread while the request is done\nlet JSONObject : JSON = try! c8o.callJson(\".getSimpleData\")!.sync()!\n// the response can be used in this scope\n```\n\nAs in many cases, locking the current thread is not recommended, the `.then()` method allows to register a callback that will be executed on a worker thread.  \nThe `.thenUI()` method does the same but the callback will be executed on a UI thread. This is useful for quick UI widgets updates.  \nThe `.then()` and `.thenUI()` callbacks receives as parameters the response and the request parameters.\n\n```swift\n// doesn't lock the current thread while the request is done\n\nc8o.callJson(\".getSimpleData\")?.then({ (response, parameters) -\u003e (C8oPromise?) in\n\t// the jObject is available, the current code is executed in an another working thread\n\t\t\n\treturn nil // return nil for a simple call\n})\n\n// following lines are executed immediately, before the end of the request.\n\t\t\nc8o.callJson(\".getSimpleData\")?.thenUI({ (response, parameters) -\u003e (C8oPromise?) in\n\t// the jObject is available, the current code is executed in the UI thread\n\tself.simpleLabel.text = response.stringValue\n\n\treturn nil // return nil for a simple call\n})\n\n// following lines are executed immediately, before the end of the request.\n```\n\t\n### Chaining calls ###\n\nThe `.then()` or `.thenUI()` returns a C8oPromise that can be use to chain other promise methods, such as `.then()` or `.thenUI()` or failure handlers.  \n The last `.then()` or `.thenUI()` must return a nil value. `.then()` or `.thenUI()` can be mixed but the returning type must be the same: XML or JSON.\n\n```swift\nc8o.callJson(\".getSimpleData\", parameters: \"callNumber\", 1)?.then({ (response, parameters) -\u003e (C8oPromise?) in\n\t// you can do stuff here and return the next C8oPromise instead of deep nested blocks\n\treturn c8o.callJson(\".getSimpleData\", parameters: \"callNumber\", 2)\n})?.thenUI({ (response, parameters) -\u003e (C8oPromise?) in\n\t// you can do stuff here and even modify previous parameters\n\tvar parameters : [String : AnyObject]? = nil\n\tparameters![\"callNumber\"] = 3\n\tparameters![\"extraParameter\"] = \"ok\"\n\treturn c8o.callJson(\".getSimpleData\", parameters: parameters)\n})?.then({ (response, parameters) -\u003e (C8oPromise?) in\n\t// you can do stuff here and return nil because this is the end of the chain\n\treturn nil\n})\n```\n\n### Handling failures ###\n\nA call can throw an error for many reasons: technical failure, network error and so on.  \nThe standard do/catch should be used to handle this.  \nThis is the case for the `.sync()` method: if an exception occurs during the request execution, the original exception is thrown by the method and can be encapsulated in a `C8oException`.\n\n```swift\ndo{\n\ttry c8o.callJson(\".getSimpleData\")!.sync()\n} catch let Exception as NSError{\n\t// process the exception\n}\n```\n\t\nWhen you use the `.then()` or the `.thenUI()` methods, the do/catch mechanism can’t catch a “future” exception or throwable: you have to use the `.fail()` or `.failUI()` methods at the end on the promise chain.  \nOne fail handler per promise chain is allowed. The fail callback provide the object thrown (like an Exception) and the parameters of the failed request.\n\n```swift\nc8o.callJson(\".getSimpleData\", parameters: \"callNumber\", 1)?.then({ (jObject, parameters) -\u003e (C8oPromise?) in\n\treturn c8o.callJson(\".getSimpleData\", parameters: \"callNumber\", 2)\n})?.thenUI({ (response, parameters) -\u003e (C8oPromise?) in\n\treturn nil\n})?.fail({ (exception, parameters) in\n\t// exception caught from the first or the second CallJson, can be an Exception\n\t// this code runs in a worker thread\n\t//...\n})\n\t\t\nc8o.callJson(\".getSimpleData\", parameters: \"callNumber\", 1)?.then({ (jObject, parameters) -\u003e (C8oPromise?) in\n\treturn c8o.callJson(\".getSimpleData\", parameters: \"callNumber\", 2)\n})?.thenUI({ (jObject, parameters) -\u003e (C8oPromise?) in\n\treturn nil\n})?.failUI({ (exception, parameters) in\n\t// exception caught from the first or the second CallJson, can be an Exception\n\t// this code runs in a UI thread\n\t//...\n})\n```\n\n### Writing the device logs to the Convertigo server ###\n\n#### Basic ####\nAn application developer usually adds log information in his code. This is useful for the code execution tracking, statistics or debugging.\n\nThe Convertigo Client SDK offers an API to easily log on the standard device logger, generally in a dedicated console. To see this console, a device must be physically connected on a computer.\n\nFortunately, the same API also send log to the Convertigo server and they are merged with the server log. You can easily debug your device and server code on the same screen, on the same timeline. Logs from a device contain metadata, such as the device UUID and can help to filter logs on the server.\n\nA log level must be specified:\n\n* Fatal: used for critical error message\n* Error: used for common error message\n* Warn: used for not expected case\n* Info: used for high level messages\n* Debug: used for help the developer to understand the execution\n* Trace: used for help the developer to trace the code\n* To write a log string, use the C8oLogger instance of a C8o instance:\n\n```swift\ndo{\n    try c8o.log.info(\"hello world!\") // the message can be a simple string\n}\ncatch let e as C8oException{\n    c8o.log.error(\"bye world...\", exceptions: e) // the message can also take an Exception argument\n}\nif(c8o.log.isDebug){ // check if currents log levels are enough\n    // enter here only if a log level is 'trace' or 'debug', can prevent unnecessary CPU usage\n    let msg : String  = serializeData() // compute a special string, like a Document serialization\n    c8o.log.debug(msg)\n}\n```\n\n#### Advanced ####\n\nA C8oLogger have 2 log levels, one for local logging and the other for the remote logging. With the Android SDK, the local logging is set by the logcat options. With the .Net SDK, the local logging depends of the LogLevelLocal setting of C8oSettings.\n\nThe remote logging level is enslaved by Convertigo server Log levels property: devices output logger. In case of failure, the remote logging is disabled and cannot be re-enabled for the current C8o instance. It can also be disabled using the LogRemote setting of C8oSettings, enabled with true (default) and disabled with false.\n\nTo monitor remote logging failure, a LogOnFail handler can be registered with the C8oSetting.\n\nThe Convertigo Client SDK itself writes logs. They can be turned off using the LogC8o setting of C8oSettings, enabled with true (default) and disabled with false.\n\n```swift\nC8oSettings()\n    .setLogC8o(false)   // disable log from the Convertigo Client SDK itself\n    .setLogRemote(false) // disable remote logging\n    .setLogLevelLocal(C8oLogLevel.TRACE)\n    // or\nC8oSettings().setLogOnFail { (exception, parameters) -\u003e (Void) in\n    // the exception contains the cause of the remote logging failure\n}\n```\n\n### Using the Local Cache\nSometimes we would like to use local cache on C8o calls and responses, in order to:\n\n* save network traffic between the device and the server,\n* be able to display data when the device is not connected to the network.\n\nThe Local Cache feature allows to store locally on the device the responses to a C8o call, using the variables and their values as cache key.\n\nTo use the Local Cache, add to a call a pair parameter of \"__localCache\" and a C8oLocalCache instance. The constructor of C8oLocalCache needs some parameters:\n\n* C8oLocalCache.Priority (SERVER / LOCAL): defines whether the response should be retrieved from local cache or from Convertigo server when the device can access the network. When the device has no network access, the local cache response is used.\n* ttl: defines the time to live of the cached response, in milliseconds. If no value is passed, the time to live is infinite.\n* enabled: allows to enable or disable the local cache on a Convertigo requestable, default value is true.\n\n```swift\n// return the response if is already know and less than 180 sec else call the server\ntry! c8o.callJson(\".getSimpleData\",\n        parameters: C8oLocalCache.PARAM, C8oLocalCache(priority: C8oLocalCache.Priority.LOCAL, ttl: 180 * 1000)\n)!.sync()\n        \n// same sample but with parameters, also acting as cache keys\ntry! c8o.callJson(\".getSimpleData\",\n        parameters: \"firstname\", \"John\",\n                    \"lastname\", \"Doe\",\n        C8oLocalCache.PARAM, C8oLocalCache(priority: C8oLocalCache.Priority.LOCAL, ttl: 180 * 1000)\n)!.sync()\n        \n// make a standard network call with the server\n// but in case of offline move or network failure\n// return the response if is already know and less than 1 hour\ntry! c8o.callJson(\".getSimpleData\",\n            parameters: C8oLocalCache.PARAM, C8oLocalCache(priority: C8oLocalCache.Priority.SERVER, ttl: 3600 * 1000)\n)!.sync()\n```\n\n### Using the Full Sync ###\nFull Sync enables mobile apps to handle fully disconnected scenarios, still having data handled and controlled by back end business logic. See the presentation of the Full Sync architecture for more details.\n\nConvertigo Client SDK provides a high level access to local data following the standard Convertigo Sequence paradigm. They differ from standard sequences by a fs:// prefix. Calling these local Full Sync requestable will enable the app to read, write, query and delete data from the local database:\n\n* fs://\u003cdatabase\u003e.create creates the local database if not already exist\n* fs://\u003cdatabase\u003e.view queries a view from the local database\n* fs://\u003cdatabase\u003e.get reads an object from the local database\n* fs://\u003cdatabase\u003e.post writes/update an object to the local database\n* fs://\u003cdatabase\u003e.delete deletes an object from the local database\n* fs://\u003cdatabase\u003e.all gets all objects from the local database\n* fs://\u003cdatabase\u003e.sync synchronizes with server database\n* fs://\u003cdatabase\u003e.replicate_push pushes local modifications on the database server\n* fs://\u003cdatabase\u003e.replicate_pull gets all database server modifications\n* fs://\u003cdatabase\u003e.reset resets a database by removing all the data in it\n* fs://\u003cdatabase\u003e.put_attachment Puts (add) an attachment to a document in the database\n* fs://\u003cdatabase\u003e.get_attachment Gets an attachment from a document\n\nWhere fs://\u003cdatabase\u003e is the name of a specific FullSync Connector in the project specified in the endpoint. The fs://\u003cdatabase\u003e name is optional only if the default database name is specified with the method setDefaultDatabaseName on the C8oSetting.\n\nAn application can have many databases. On mobile (Android, iOS and Xamarin based) they are stored in the secure storage of the application. On Windows desktop application, they are stored in the user AppData/Local folder, without application isolation.\n\nAll platforms can specify a local database prefix that allows many local database copies of the same remote database. Use the method setFullSyncLocalSuffix on the C8oSetting.\n\n```swift\nc8o.callJson(\"fs://base.reset\")?.then({ (json, parameters) -\u003e (C8oPromise?) in\n    // json content:\n    // { \"ok\": true }\n    return c8o.callJson(\"fs://base.post\", // creates a new document on \"base\", with 2 key/value pairs\n        parameters: \"firstname\", \"John\",\n        \"lastname\", \"Doe\"\n    )\n})?.then({ (json, parameters) -\u003e (C8oPromise?) in\n    // json content:\n    // {\n    //   \"ok\": true,\n    //   \"id\": \"6f1b52df\",\n    //   \"rev\": \"1-b0620371\"\n    // }\n    return c8o.callJson(\"fs://base.get\",\n        parameters: \"docid\", json[\"id\"].stringValue) // retrieves the complet document from its \"docid\"\n})?.then({ (json, parameters) -\u003e (C8oPromise?) in\n    // json content:\n    // {\n    //   \"lastname\": \"Doe\",\n    //   \"rev\": \"1-b0620371\",\n    //   \"firstname\": \"John\",\n    //   \"_id\": \"6f1b52df\"\n    // }\n    c8o.log.info(json.stringValue) // output the document in the log\n    return nil\n})\n```\n\n### Replicating Full Sync databases\nFullSync has the ability to replicate mobile and Convertigo server databases over unreliable connections still preserving integrity. Data can be replicated in upload or download or both directions. The replication can also be continuous: a new document is instantaneously replicated to the other side.\n\nThe client SDK offers the progress event to monitor the replication progression thanks to a C8oProgress instance.\n\nA device cannot pull private documents or push any document without authentication. A session must be established before and the Convertigo server must authenticate the session (using the Set authenticated user step for example).\n\n```swift\n// Assuming c8o is a C8o instance properly instanciated and initiated as describe above.\n\nc8o.callJson(\".login\")?.then({ (json, parameters) -\u003e (C8oPromise?) in  \tif(json == \"ok\"){\n\t\t// replication_pull can also be sync or replication_push\n\t\tc8o.callJson(\"fs://base.replication_pull\")?.then({ (json, parameters) -\u003e (C8oPromise?) in  // launches a database replication from the server to the device\n\t\t\t// json content:\n\t\t\t// { \"ok\": true }\n\t\t\t// the documents are retrieved from the server and can be used\n\t\t\treturn nil\n\t\t\t\n\t\t})?.progress({ (progress) in\n\t\t\t// this code runs after each progression event\n\t\t\t// progress.Total is calculated and grows up then progress.Current increases to the total\n\t\t\tc8o.log.info(\"progress: \" + progress.description)\n\t\t})\n\t}\n\treturn nil\n})\n```\n\n### Replicating Full Sync databases with continuous flag ###\nAs mentioned above, a replication can also be continuous: a new document is instantaneously replicated to the other side.\n\nProgress will be called at each entering replication during the all life of the application until that you explicitly cancel that one\n\n```swift\nc8o.callJson(\"fs://base.replication_pull\", \"continuous\", true)?.then({ (json, parameters) -\u003e (C8oPromise?) in  // launches a database replication from the server to the device\n\t\t\t// json content:\n\t\t\t// { \"ok\": true }\n\t\t\t// the documents are retrieved from the server and can be used\n\t\t\treturn nil\n\t\t\t\n\t\t})?.progress({ (progress) in\n\t\t\t// this code runs after each progression event\n\t\t\t// progress.Total is calculated and grows up then progress.Current increases to the total\n\t\t\tc8o.log.info(\"progress: \" + progress.description)\n\t\t})\n```\n\n### Full Sync FS_LIVE requests\n\nFull Sync has the ability to re-execute your fs:// calls if the database is modified. The then or thenUI following a FS_LIVE parameter is re-executed after each database update. Database update can be local modification or remote modification replicated.\n\nThis allow you keep your UI synchronized with database documents.\n\nA FS_LIVE parameter must have a string value, its liveid. The liveid allow to cancel a FS_LIVE request.\n\n```swift\nc8o.callJson(\"fs://.view\",\n    parameters: \"ddoc\", \"design\",\n    \"view\", \"customers\",\n    C8O.FS_LIVE, \"customers\")?.thenUI({ (json, parameters) -\u003e (C8oPromise?) in  // launches a live view\n    // will be call now and after each database update\n    updateCustomersUI(json)\n  return nil\n})?\n…\n// cancel the previous FS_LIVE request, can be on application page change for example\nc8o.cancelLive(\"customers\")\t\n```\n\n\n### Full Sync Change Listener ###\n\nFull Sync has also the ability to notify your if there is any change on the database. The progress following a FS_LIVE parameter is triggered  after each database update. The changes contains the origin of the change, and other attributes :\n* isExternal\n* isCurrentRevision\n* isConflict\n* id\n* revisionId\n\n```swift\nlet changeListener = C8oFullSyncChangeListener(handler: {(changes: JSON) -\u003e () in\n    checkChanges(changes)\n})\n…\nc8o.addFullSyncChangeListener(\"base\", changeListener) // add this listener for the database \"base\" ; null or \"\" while use the default database.\n…\nc8o.removeFullSyncChangeListener(\"base\", changeListener) // remove this listener for the database \"base\" ; null or \"\" while use the default database.\n```\n\n## Building c8osdk-ios ##\n\nPlease see the [wiki page](https://github.com/convertigo/c8osdk-ios/wiki)\n\n\n    \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconvertigo%2Fc8osdk-ios","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fconvertigo%2Fc8osdk-ios","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconvertigo%2Fc8osdk-ios/lists"}