PSPDFInstantClientDelegate

Objective-C

@protocol PSPDFInstantClientDelegate <NSObject>

Swift

protocol InstantClientDelegate : NSObjectProtocol

The delegate of a PSPDFInstantClient must adopt this protocol to be notified of download and authentication events.

Delegates that are interested in events around the sync cycle can also implement the optional methods listed in the “Sync Events” section. For a more detailed explanation of the sync cycle of a document and its possible states, please refer to the documentation on PSPDFInstantDocumentState.

If you need multiple observers or are only interested in the events of a single document, you can use the notifications posted by PSPDFInstantDocumentDescriptor.

Note

Important: All methods in this protocol will be called on a background thread!
  • Called when the document fails to authenticate with the PSPDFKit Server to synchronize annotations.

    This typically means either the user no longer has access to the document or the JWT expired. Your own server should be able to say if the user still has access.

    If the user still has access, obtain a new JWT from your server and call -[PSPDFInstantDocumentDescriptor reauthenticateWithJWT:] on the document descriptor. If the user no longer has access, consider stopping showing this document to the user and call -[PSPDFInstantDocumentDescriptor removeLocalStorageWithError:] on the document descriptor.

    Declaration

    Objective-C

    - (void)instantClient:(nonnull PSPDFInstantClient *)instantClient
        didFailAuthenticationForDocumentDescriptor:
            (nonnull id<PSPDFInstantDocumentDescriptor>)documentDescriptor;

    Swift

    func instantClient(_ instantClient: InstantClient, didFailAuthenticationFor documentDescriptor: InstantDocumentDescriptor)

    Parameters

    instantClient

    The sender of the message.

    documentDescriptor

    The descriptor of the document that failed authentication.

  • Called when a prior call to -[PSPDFInstantDocumentDescriptor reauthenticateWithJWT:] has completed successfully.

    The JWT that you passed into that method and which has been accepted is relayed back to you. The token would be safe to persist so that you can re-use it the next time your app launches.

    Declaration

    Objective-C

    - (void)instantClient:(nonnull PSPDFInstantClient *)instantClient
                      documentDescriptor:
                          (nonnull id<PSPDFInstantDocumentDescriptor>)
                              documentDescriptor
        didFinishReauthenticationWithJWT:(nonnull NSString *)validJWT;

    Swift

    func instantClient(_ instantClient: InstantClient, documentDescriptor: InstantDocumentDescriptor, didFinishReauthenticationWithJWT validJWT: String)

    Parameters

    instantClient

    The sender of the message.

    validJWT

    The JWT that has been used to authenticate the document.

    documentDescriptor

    The descriptor of the document that has been reauthenticated.

  • Called when a prior call to -[PSPDFInstantDocumentDescriptor reauthenticateWithJWT:] has failed.

    If authentication failed for any other reasons than a dropped connection and you chose to store a JWT for this document descriptor, you should delete the JWT when receiving this message.

    Declaration

    Objective-C

    - (void)instantClient:(nonnull PSPDFInstantClient *)instantClient
                      documentDescriptor:
                          (nonnull id<PSPDFInstantDocumentDescriptor>)
                              documentDescriptor
        didFailReauthenticationWithError:(nonnull NSError *)error;

    Swift

    func instantClient(_ instantClient: InstantClient, documentDescriptor: InstantDocumentDescriptor, didFailReauthenticationWithError error: Error)

    Parameters

    instantClient

    The sender of the message.

    documentDescriptor

    The descriptor of the document that could not be reauthenticated.

    error

    The an error detailing why reauthentication failed.