Overview
Introduction
Lens offers out-of-the-box support for capturing and signing photos and videos without device connectivity. We call this process offline capture, for short. Here we’ll uncover the differences between being online and offline, and implementation guidelines to take into consideration.
Signing Online vs. Offline
Lens maintains two types of certificates on board each device.
- Short validity certificates, used for signing with connectivity (online), is valid for a maximum of 24 hours. Images signed while online always contain a trusted timestamp.
- Long valitidy cerificates, used for signing without connectivity (offline), is valid for up to 6 months. Images signed while offline never contain a trusted timestamp, this field will be intentionally null.
SDK Launch Activities
On Launch, Lens checks if it has online connectivity, and checks the validy times of the certificates. If the validity is about to end for any certificate, the SDK attempts to refresh the certificate. This is done without blocking the user interface.
Certificates can only be obtained while online. This means that for your users to successfully capture media offline, they must first launch your app at least once while connected to the internet, and your app must launch the Lens SDK (the camera does not need to be visible for this to happen) during that visit for a long validity certificate to be obtained.
If a long-validity certificate expires while a device is offline, Lens will be unable to sign images until the device recconnects and obtains a new certificate. We hope this will be a rare occurance, since the certificate is valid for 6 months.
Workflow Comparison
Below are the basic steps of capturing and signing a Truepic, with differences noted for when the device is online or offline in steps 1, 5, and 6.
Step 1: When the camera view is launched, check cerficiate validity.
- If online, the check completes.
- If offline, the check will fail.
Step 2: A photo or video is captured.
Step 3: The thumbnail is passed to the Host App.
Step 4: Gather assertion/claim data and queue it for signing.
Step 5: The signing process requests a trusted timestamp.
- If online, the timestamp is acquired, and the photo is signed with the short-validity certificate.
- If offline, the timestamp request fails, the photo is signed with the long-validity certificate without a timestamp
Step 6: The signed Truepic is passed to the Host App.
- If online, the Host App can then upload the Truepic, usually directly to the Lens API, or to the app’s own server.
- If offline, the Host App needs to start the upload process once the device regains connectivity, using the Truepics saved on disk.
Checking Long-Validity Length
As mentioned, a valid long-validity certificate is required to sign captures taken offline. To ensure a positive user experience, you may want to display information about how long a user has to remain offline before their certificate expires, or to prompt a user to open your app to obtain a new certificate while online. Here is how you may get the time remaining on the current long-validity certificate.
Android
Date getLongTermCertificateExpiration();
iOS Coming in a future release.
Implementation Notes
- The capture, signing, and potential uploading processes require a small amount of time, usually under 10 seconds.
- The Host App user should wait one or two seconds after a capture before moving the app to the background.
- After a device regains connectivity, please allow a few seconds for Lens to reconnect to Truepic servers.