Learn how to configure a server to synchronize your files and annotations or setup and try sample server projects.
Support for realtime collaboration is included with the SDK, including demonstration implementations for using WebViewer Server and Firebase as a central server. You may consult these implementations in the Collaboration Sample as reference implementations (found in the .dmg download at /Samples/Other/Collaboration/Collaboration/
, TRNWebViewerServerService.m
and TRNFirebaseCommunicationService.m
).
This guide will demonstrate how to add support for a new realtime collaboration server in an iOS app.
In realtime collaboration, the role of the server is to:
If your server is capable of the above, it can serve as the back-end to Apryse's realtime collaboration.
This guide will explain how to configure an iOS app to interface with a server that fulfils the above requirements.
To add support for a new server backend, you need to implement a single class, referred to here as the Collaboration Service. The purpose of the Collaboration Service object is to mediate between the server and the Apryse SDK. The Collaboration Service translates messages received from the server in its data format (for example json data) into to a format that the SDK understands (specifically a PTCollaborationAnnotation
), and vice versa.
A Collaboration Service must implement the PTCollaborationServerCommunication
protocol. The purpose of each API defined in the protocol will be described in the sections below.
The Collaboration Service implements 3 methods defined in PTCollaborationServerCommunication
in order to process changes made on the device:
Each of these methods is called by the PTCollaborationManager
to communicate when a change has occurred on the device. They pass an object of type PTCollaborationAnnotation
, which the collaboration service must then convert to a format appropriate for the server, and sends it to the server.
Here is a theoretical example:
Likewise, the collaboration service is responsible for receiving updates from the server and communicating them to the Collaboration Manager, referenced in its PTCollaborationManager
property.
This is done by calling the following Collaboration Manager methods:
As in the localAnnotationAdded/Modified/Removed
methods described in the previous section, these methods take a PTCollaborationAnnotation
parameter. It is the job of the collaboration service to receive a server message, translate it into a PTCollaborationAnnotation
object, and call the appropriate method.
Here is a theoretical example:
PTCollaborationServerCommunication
, which a Collaboration Service must conform to, defines three other required APIs:collaborationManager
. This should be assigned to the instance of the PTCollaborationManager
that exists on a PTToolManager
. This is done automatically if using a PTCollaborationDocumentViewController
, described below.-(void)documentLoaded
. This method is intended to be called when a document is first loaded, and so when invoked the service should send all of the document's annotations to the collaborationManager
's remoteAnnotationAdded:
method.(NSString*)userID
, which returns the server's unique ID associated with the user. This can be used by the local viewer to restrict which annotations a user can edit.PTCollaborationDocumentViewController
, which inherits from the standard PTDocumentController
, that implements two useful functions for collaboration:PTCollaborationServerCommunication
object, and automatically connects it with its PTCollaborationManager
.PTCollaborationServerCommunication
protocol does not have any opinion on where/how server login is performed.The iOS SDK includes a realtime collaboration sample app with the .dmg download (found in Samples/Other/Collaboration
). It includes support for two different back-end servers:
This guide will step you through running the sample.
The Apryse demonstration server uses WebSockets to communicate annotation changes and messages between the client and the server. The WebSocket API is provided by SocketRocket, and is integrated via CocoaPods.
Collaboration.xcworkspace
, and run the sample. The device will show the PDF viewer.Now, when you create annotations on the device or the computer's browser, the annotation will show up on the other.
Firebase's Realtime Database is a NoSQL database. Accessing firebase requires Google's Firebase SDK, which is integrated via Cocoapods:
Collaboration.xcworkspace
.-(void)viewDidAppear:(BOOL)animated
, comment out the line of code under "OPTION 1" (which uses the Apryse demonstration server), and uncomment the line under "OPTION 2" (which uses Firebase).Now, when you create annotations on the device or the computer's browser, the annotation will show up on the other.
The firebase sample can be configured to connect to your own Firebase instance. To do this, follow these instructions:
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales