Integrating real-time collaboration into your Android application
With Instant, it’s easier than ever to add real-time collaboration features to your Nutrient-powered app, allowing your users to seamlessly share, edit, and annotate PDF documents across Android, iOS, and Web apps. This article will guide you through integrating Instant into your own apps.
Requirements
- Nutrient Android SDK with Instant
Nutrient and Instant are two separate Android libraries available in the same download. Download the latest release from my.nutrient.io(opens in a new tab), or, for evaluation purposes, check out our free trial.
- A Document Engine Instance
See the example projects guide to get an instance up and running.
Quick start with the example project
The Catalog app(opens in a new tab) includes an Instant example that connects to our example server apps and demonstrates real-time collaboration.
Setting up Document Engine
- Follow the example projects guide to set up Document Engine with one of our example server projects. This will start Document Engine on port
5000and the web example on port3000. - Open http://localhost:3000 in a browser, enter a username when prompted, and upload a PDF using the Upload PDF button.
Connecting from the Android Catalog app
- Clone and open the Catalog app(opens in a new tab) in Android Studio.
- Run
adb reverse tcp:5000 tcp:5000 && adb reverse tcp:3000 tcp:3000to forward emulator/device ports to host ports. - Run the Instant example from the Catalog app (located at
app/src/main/java/com/pspdfkit/catalog/examples/kotlin/instant/). - Tap Enter Link Manually and fill in the fields:
- Document Link: Enter
http://localhost:3000 - Username: Enter the same username you used when accessing the web example (this is required for the example server’s API authentication)
- Document Link: Enter
- Tap Open Document. If you have multiple documents, select one from the list.
- Add annotations in the app or in the browser to see real-time annotation syncing.
Integrating into your app
To add Instant to your project:
Add the specific dependencies required for Instant to your
build.gradlefile:dependencies {implementation 'com.squareup.okhttp3:okhttp:<version>'}
Manual library file integration
Add the specific dependencies required for Instant to your
build.gradlefile:dependencies {implementation 'com.squareup.okhttp3:okhttp:<version>'}
ProGuard
There’s no need to specify additional ProGuard rules since PSPDFKit uses consumersProguardFiles to keep ProGuard from obfuscating the required symbols. If you want to check out the rules, look in the proguard.txt file, which is located inside the PSPDFKit .aar:
cd [YOUR_AAR_LOCATION]unzip [YOUR_AAR_NAME].aar -d aar-contentscat aar-contents/proguard.txt