PSPDFInstantClient


@interface PSPDFInstantClient : NSObject

The entry point to Instant, representing a client that can connect to PSPDFKit Server.

The Instant client manages the descriptors of the documents that you have access to. It provides the container for your downloaded documents, and controls the communication channel to the server. By providing a delegate, you are informed of relevant events regarding the synced documents and can manage tasks like authentication in a centralized manner.

  • The URL of the directory where Instant stores its documents, which is a subdirectory of Application Support.

    This may be used to set a data protection class for all Instant data as described in https://pspdfkit.com/guides/ios/current/instant/data-protection/ . It is possible to customize the directory by subclassing and overriding this method, but there should typically be no need to do so.

    Warning

    The internal structure of this directory is private!

    Declaration

    Objective-C

    @property (readonly, nonatomic, class) NSURL *_Nonnull dataDirectory;

    Swift

    class var dataDirectory: URL { get }
  • Undocumented

    Declaration

    Objective-C

    
    @interface PSPDFInstantClient : NSObject
  • Undocumented

    Declaration

    Objective-C

    
    @interface PSPDFInstantClient : NSObject
  • Initializes a new client object.

    Creating a new client object requires reading from, and potentially writing to permanent storage. There are a several scenarios where these operations can fail: running out of space, insufficient permissions, data corruption are just some of those.

    As such it is important that you appropriately handle the PSPDFInstantError in case of a failure. - parameter: serverURL The base URL of the PSPDFKit Server the client should connect to. - parameter: error A pointer to be populated with an error when creating the client failed. - returns: The newly created client.

    Declaration

    Objective-C

    - (nullable instancetype)initWithServerURL:(nonnull NSURL *)serverURL
                                         error:(NSError *_Nullable *_Nullable)error;

    Swift

    init(serverURL: URL) throws

    Parameters

    serverURL

    The base URL of the PSPDFKit Server the client should connect to.

    error

    A pointer to be populated with an error when creating the client failed.

    Return Value

    The newly created client.

  • The base URL of the PSPDFKit Server the client connects to, as provided when creating the client;

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSURL *_Nonnull serverURL;

    Swift

    var serverURL: URL { get }
  • Returns a descriptor for the document with a given identifier.

    A server client will keep a reference to the returned object and will always return the same instance if this is called again with the same identifier.

    This will fail if the document identifier is not valid.

    Declaration

    Objective-C

    - (nullable id<PSPDFInstantDocumentDescriptor>)
    documentDescriptorWithIdentifier:(nonnull NSString *)documentIdentifier
                               error:(NSError *_Nullable *_Nullable)error;

    Swift

    func documentDescriptor(withIdentifier documentIdentifier: String) throws -> PSPDFInstantDocumentDescriptor

    Parameters

    documentIdentifier

    The identifier for the document used by PSPDFKit Server.

    Return Value

    A document descriptor.

  • Removes the client’s local storage from disk, including storage for all documents. This will also cancel any in-progress network operations for all the client’s documents.

    If your app has a sign out procedure, this method should be called when a user signs out.

    Errors may occur due to file system operations failing.

    Declaration

    Objective-C

    - (BOOL)removeLocalStorageWithError:(NSError *_Nullable *_Nullable)error;

    Swift

    func removeLocalStorage() throws
  • An object to be notified of download and authentication events for documents managed by this client.

    All delegate methods will be called on a background thread.

    Declaration

    Objective-C

    @property (readwrite, nonatomic)
        id<PSPDFInstantClientDelegate> _Nullable delegate;

    Swift

    weak var delegate: PSPDFInstantClientDelegate? { get set }
  • Calls the designated initializer and throws an exception if that fails.

    Although failure of the designated initializer is unlikely, it can happen in cases of misconfiguration, data corruption etc. We therefore strongly suggest to use the designated initializer, and properly handle the error in case of failure.

    This method remains in place to ease the transition. It will be removed in a future update.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithServerURL:(nonnull NSURL *)serverURL;