One of the key features of 카우치베이스 모바일 data platform is the ability to sync data across the 카우치베이스 라이트 enabled mobile clients and the 동기화 게이트웨이. The ability to run apps in the background is typical in the mobile application life cycle on iOS, Android 그리고 .Net platforms and has several uses, for instance, to reduce initial sync/startup costs by ensuring that the app is launched with the latest data.
In this post, we will introduce you to a simple tutorial that discusses how you can use iOS 백그라운드 앱 새로 고침 capability to sync data when in the background. While the tutorial itself is iOS specific, concepts discussed here apply to all of the supported Couchbase Lite platforms.
소개
Every mobile platform has its own implementation of app backgrounding. In some instances, they may even vary with version of the OS. For instance, among the various options, you have Background Services on Android, 백그라운드 앱 새로 고침 on iOS and Background Tasks on UWP apps . For these reasons, with some exceptions, backgrounding support is an app level concern and is not built into Couchbase Lite. In other words, the mobile app will have to support the platform’s built-in backgrounding capability and then invoke Couchbase Mobile’s data sync capabilities whenever it gets the opportunity to execute in the background.
It is to be noted that on some platforms, the system uses its discretion to terminate the app when it is in the background. Hence, there are no guarantees that the app will even have an opportunity to run in the background.
Backgrounding Options in iOS
Background Task
Everytime the app is pushed into the background, Couchbase Lite will use the iOS Background Task capability to wrap up ongoing sync before going into idle mode. With the Background Task capability, the system provides the app with a finite amount of time to run in the background to perform critical tasks before suspending it.

Silent Notifications
In this mode, your backend system can be configured to send out silent push notifications to your apps whenever there is data available to be synced by the clients. Silent push notifications are like regular push notifications except that the end user is not notified. Instead, your app is notified and given the oppportunity to handle the notification. When your app is woken up in this mode, it can do a one-shot replication to sync and pending changes with the remote server.
백그라운드 앱 새로 고침
백그라운드 앱 새로 고침 lets your app run periodically in the background so that it can update its content. Over time, the system learns the usage of your app , will wake up your app at appropriate times and give it some finite amount of time to execute. When your app is woken up in this mode, it can do a one-shot replication to sync and pending changes with the remote server.
튜토리얼
The tutorial introduced in this post uses Background App Refresh mode and is available 여기. In this tutorial, you will learn how to –
- Configure your iOS app for Background App Refresh support
- Setup your app to do a one-shot sync with Couchbase Sync Gateway while in the background
여기서는 Couchbase Lite 지원 클라이언트의 예로 Swift 앱을 사용하겠습니다.
앱 개요
We will be working with a simple “User Profile” app which we introduced in the 기초 튜토리얼 and extended to support data sync capabilities in the Sync Tutorial. In the tutorial, we will be extending that app to support data sync when in the background.
The app does the following
– Allows users to log in and create or update his/her user profile information. The user profile view automatically updates every time the profile information changes in the underlying database
– The user profile information syncs with a remote Sync Gateway which then syncs it over to other devices (subject to access control and routing configurations specified in the sync function)
– When the app is woken up in the background, it does a one-shot replication with the remote Sync Gateway
다음 단계
At the end of the tutorial, you should have an understanding of how to sync between your Couchbase Lite enabled iOS apps and Sync Gateway while your app is in the backhround. While we discussed one background mode, you can apply it to Silent Notifications. The concepts apply to other platforms as well.
질문이나 피드백이 있으면 아래에 댓글을 남기거나 트위터로 언제든지 문의해 주세요. @rajagp 또는 다음 주소로 이메일을 보내주세요. priya.rajagopal@couchbase.com. . 카우치베이스 포럼 를 통해 질문할 수 있습니다.