Autoupload
To start auto upload, you first need to upload the existing data on the server and scan the device gallery.
Initialization
Assume that you have created an instance of CloudikePhotos - the Photos Manager.
let photosManager: CloudikePhotos
Read Photos From the Device Gallery
There are two ways to start CloudikePhotos: with photo auto upload enabled and without it.
public final class CloudikePhotos {
// ...
public func configureWithUploadSettings(_ uploadSettings: CloudikeAutoUploadSettings, with completion: ((NSError?) -> Void)?)
// ...
}
// ...
photosManager.configureWithUploadSettings(...)
If the isAutoUploadEnabled flag in CloudikeAutoUploadSettings is false, then to scan the local gallery after calling the method for configuring the SDK, you need to call the method:
public final class CloudikePhotos {
...
public func updateLocal()
...
}
// in your code it might look like:
photosManager.updateLocal()
Start/Stop Autoupload
To start or stop auto uploading, you need to call the CloudikePhotosKit method and pass the CloudikeAutoUploadSettings object with the auto upload settings:
To start autoupload for photo/video from your device, you should call:
while initializaition process
let isBackgroundMode: Bool (is "true" if app is in background mode) // optional parameter
let settings = CloudikeAutoUploadSettings(isAutoUploadEnabled: true, ....)
photos.configureWithUploadSettings(uploadSettings, in: isBackgroundMode) {
// completion block
}
while app is running
let settings = CloudikeAutoUploadSettings(isAutoUploadEnabled: true, ....)
self.photosManager.updateUploadSettings(settings) {
// completion block
}
To stop autoupload for photo/video from your device, you should call:
let settings = CloudikeAutoUploadSettings(isAutoUploadEnabled: false, ....)
self.photosManager.updateUploadSettings(settings) {
// completion block
}
Autoupload Settings
The auto upload settings configuration should be set up with the CloudikeAutoUploadSettings object. The default settings contain the following fields and values:
- isAutoUploadEnabled (Bool) - auto upload on/off.
- is3gUploadEnabled (Bool) - cellular data upload is allowed.
- minBatteryLevel (Bool) - minimum battery charge for auto upload.
- isVideoUploadEnabled (Bool) - video upload is allowed.
- maxRetryCount (Bool) - max retry count for particular photo/video. isPhotosUploadFirst Bool // video upload after all photo isBackgroundAutoUploadEnabled bool // auto upload is available in app background mode
To update auto upload settings, call:
let settings = CloudikeAutoUploadSettings(...)
photosManager.update(settings)
Monitoring Autoupload Status
The CloudikePhotos upload status can be tracked by setting up the closure:
photosManager.uploadStatusDidChange(((CloudikeAutoUploadStatus) -> Void)?)
The CloudikeAutoUploadStatus object contains values which describe a state of photo/video auto upload:
let status: Status
let reasons: Set<Reason>
let totalPhotos: Int
let photosUploaded: Int
let photosLeft: Int
let isDeviceGalleryScanned: Bool
The Status enum object has the cases below:
- uploading
- paused
The Reason enum obect has the cases below:
- backendTimelineNotDownloaded Backend gallery has not been read yet.
- deviceGalleryFirstBatchNotScanned Local gallery first batch of assets has not been read yet.
- competitionNotFinished Apps negotiating about which one will be responsible for uploading photos to the cloud.
- anotherAppInitialized Another app is responsible for uploading to the cloud. This app will not upload.
- autoUploadDisabled Auto upload is disabled in upload configuration.
- galleryPermissionNotGranted Permission to device photo gallery hasn't been granted.
- noInternetConnection No internet connection.
- noWiFiConnection No Wi-Fi connection, but the use of mobile network is prohibited.
- lowBattery Not enough battery level to continue auto-upload.
- lowDeviceStorage User does not have enough disk space on device to perform auto upload.
- lowCloudStorage User does not have enough space in the cloud storage.
- tokenExpired Auth token has been expired. App need to re-login user.
- loggingOut SDK is being logged out.
(Auto Upload Priority, Ongoing notification etc)
TBD