Skip to main content

Getting Started

Requirements​

  • Xcode 16.0 or later
  • CocoaPods 1.15.2 or later
  • Target of iOS 13 or later
  • Swift 5+

Before You Begin​

This SDK is stored in the private pod repo and developed for use with the Cloudike Backend. If you need access, please Contacts Us.

Installation​

Add SDK to your app​

The Cloudike Photos SDK is available through CocoaPods or XCFramework static library. To install it, simply add the following lines to your Podfile:

# Add Cloudike podspec to sources
source 'git@git.cloudike.com:cloudike-ios/pod_spec.git'

target 'YourApp' do
# Add CloudikePhotosKit as dependency to your target
pod 'CloudikePhotosKit', '~> 0.2.10'
end

Initialization​

Initialization is performed in two stages.

Stage 1. Initialize library.​

To initialize an instance of CloudikePhotos, you need to add the following calls:

var photos: CloudikePhotos?

let apiBaseURL = URL(string: "Base URL of the backend")!
let token = "Authentication token received during user login"
let userId = "User profile id"
let userAgent = "User agent string"

let core = CloudikeCore(apiBaseUrl: apiBaseURL)
core.applyUser(
apiToken: token,
userId: userId,
deviceId: "Unique device id",
userAgent: userAgent
)
let competitionSettings = CloudikePhotosSettings.CompetitionSettings(
mode: .standalone,
appGroupId: nil,
lastActivityMaxInterval: 86400
)
let settings = CloudikePhotosSettings(
isPermissionsRequestAllowed: false,
competition: competitionSettings,
apiBaseURL: apiBaseUrl,
apiUserId: userId,
apiToken: token,
userAgent: userAgent
)
var networkMonitor: NetworkMonitorable
var storageSizeUpdater: StorageInformable
let photos = CloudikePhotos(
settings: settings,
core: core,
networkMonitor: networkMonitor,
storageSizeUpdater: storageSizeUpdater,
userLanguage: {
// user language
},
externalLogHandler: {
// external log handler
}
)
self.photos = photos

Stage 2. Configuration.​

To configure an instance of CloudikePhotos, you need to add the following calls:

let uploadSettings = CloudikeAutoUploadSettings(
isAutoUploadEnabled: true, // Auto upload on/off.
is3gUploadEnabled: true, // Cellular data upload allowed.
isVideoUploadEnabled: true, // Video upload allowed.
minBatteryLevel: 0.3, // Minimum battery charge for auto upload.
maxRetryCount: 0, // The maximum number of attempts to upload a photo/video file to the cloud.
// If 0, then the number of attempts is not limited. If 1 - only one attempt is given, etc.
isPhotosUploadFirst: false, // If true, photos will be uploaded first, then videos. If false, the priority is not defined.
isBackgroundAutoUploadEnabled: false, // Set to true if your app is expected to upload photos/videos while running in background mode.
isRestoreEnabled: false // If set to false, deleted photos will not be restored and will remain in the trash bin.
)
let background = UIApplication.shared.applicationState == .background
self.photos.configureWithUploadSettings(uploadSettings, in: background) { error in
// completion block
}

Dependencies​

Our SDK uses the following dependencies:

pod 'CloudikeCoreKit', '= 3.1.3'