Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

Latest commit

 

History

History
56 lines (36 loc) · 5.23 KB

File metadata and controls

56 lines (36 loc) · 5.23 KB

Quickstart in Couchbase Lite Data Sync with C#, .NET and Xamarin

Build an Cross Platform Mobile App in Xamarin Forms with Couchbase Lite

Couchbase Sync Gateway is a key component of the Couchbase Mobile stack. It is an internet-facing synchronization mechanism that securely syncs data across devices as well as between devices and the cloud. Couchbase Mobile is built upon a websocket based replication protocol.

The core functions of the Sync Gateway includes:

  • Data Synchronization across devices and the cloud
  • Authorization
  • Access Control
  • Data Validation

This repo is designed to show you an app that allows users to log in and make changes to their user profile information. User profile information is persisted as a Document in the local Couchbase Lite Database. When the user logs out and logs back in again, the profile information is loaded from the Database.

Full documentation can be found on the Couchbase Developer Portal.

Prerequisites

Prerequisites

Before you get started you should take the following prerequisites into consideration:

  • This learning path assumes familiarity with building apps with Xamarin, more specifically Xamarin.Forms using C# and XAML.

  • For iOS/Mac development, you will need a Mac running MacOS 11 or 12

  • iOS/Mac (Xcode 12/13) - Download latest version from the Mac App Store or via Xcodes

Note: If you are using an older version of Xcode, which you need to retain for other development needs, make a copy of your existing version of Xcode and install the latest Xcode version. That way you can have multiple versions of Xcode on your Mac. More information can be found in Apple's Developer Documentation. The open source Xcodes project simplifies this process.

  • For Android development SDK version 22 or higher. You can manage your Android SDK version in Visual Studio.
  • For Universal Windows Platform (UWP) development, a Windows computer running Windows 10 1903 or higher.

Note: You can not edit or debug UWP projects with Visual Studio for Mac and you can't edit or debug Mac projects with Visual Studio for PC.

  • Visual Studio for Mac or PC.

  • curl HTTP client

    • You could use any HTTP client of your choice, but we will use curl in our learning path. Download latest version from curl website. MacOS Package manager users can use homebrew. Windows Package Manager users can use winget.
  • Docker
    • We will be using Docker to run images of both Couchbase Server and the Sync Gateway — to download Docker, or for more information, see: Get Docker.

App Architecture

The sample app follows the MVP pattern, separating the internal data model, from a passive view through a presenter that handles the logic of our application and acts as the conduit between the model and the view

Try it out

  1. Open the UserProfileDemo.sln. The project would be located at /path/to/dotnet-xamarin-cblite-userprofile-sync/src.
open UserProfileDemo.sln
  1. Build and run the project using two simulators/emulators.
  2. Verify that you see the login screen on both the simulators/emulators.

Conclusion

This code is an example of how to use a Sync Gateway to synchronize data between Couchbase Lite enabled clients. The Couchbase Developer Portal tutorial will discuss how to configure your Sync Gateway to enforce relevant access control, authorization and data routing between Couchbase Lite enabled clients.