ParseSwift

public struct ParseSwift

ParseSwift contains static methods to handle global configuration for the Parse framework.

  • Configure the Parse Swift client. This should only be used when starting your app. Typically in the application(... didFinishLaunchingWithOptions launchOptions...).

    Declaration

    Swift

    public static func initialize(configuration: ParseConfiguration)

    Parameters

    configuration

    The Parse configuration.

  • Configure the Parse Swift client. This should only be used when starting your app. Typically in the application(... didFinishLaunchingWithOptions launchOptions...).

    Warning

    usingTransactions is experimental.

    Declaration

    Swift

    static public func initialize(
        applicationId: String,
        clientKey: String? = nil,
        masterKey: String? = nil,
        serverURL: URL,
        liveQueryServerURL: URL? = nil,
        allowingCustomObjectIds: Bool = false,
        usingTransactions: Bool = false,
        usingEqualQueryConstraint: Bool = false,
        keyValueStore: ParseKeyValueStore? = nil,
        requestCachePolicy: URLRequest.CachePolicy = .useProtocolCachePolicy,
        cacheMemoryCapacity: Int = 512_000,
        cacheDiskCapacity: Int = 10_000_000,
        migratingFromObjcSDK: Bool = false,
        deletingKeychainIfNeeded: Bool = false,
        httpAdditionalHeaders: [AnyHashable: Any]? = nil,
        maxConnectionAttempts: Int = 5,
        authentication: ((URLAuthenticationChallenge,
                          (URLSession.AuthChallengeDisposition,
                           URLCredential?) -> Void) -> Void)? = nil
    )

    Parameters

    applicationId

    The application id of your Parse application.

    clientKey

    The client key of your Parse application.

    masterKey

    The master key of your Parse application.

    serverURL

    The server URL to connect to Parse Server.

    liveQueryServerURL

    The live query server URL to connect to Parse Server.

    allowingCustomObjectIds

    Allows objectIds to be created on the client. side for each object. Must be enabled on the server to work.

    usingTransactions

    Use transactions when saving/updating multiple objects.

    usingEqualQueryConstraint

    Use the $eq query constraint when querying.

    keyValueStore

    A key/value store that conforms to the ParseKeyValueStore protocol. Defaults to nil in which one will be created an memory, but never persisted. For Linux, this this is the only store available since there is no Keychain. Linux users should replace this store with an encrypted one.

    requestCachePolicy

    The default caching policy for all http requests that determines when to return a response from the cache. Defaults to useProtocolCachePolicy. See Apple’s documentation for more info.

    cacheMemoryCapacity

    The memory capacity of the cache, in bytes. Defaults to 512KB.

    cacheDiskCapacity

    The disk capacity of the cache, in bytes. Defaults to 10MB.

    migratingFromObjcSDK

    If your app previously used the iOS Objective-C SDK, setting this value to true will attempt to migrate relevant data stored in the Keychain to ParseSwift. Defaults to false.

    deletingKeychainIfNeeded

    Deletes the Parse Keychain when the app is running for the first time. Defaults to false.

    httpAdditionalHeaders

    A dictionary of additional headers to send with requests. See Apple’s documentation for more info.

    authentication

    A callback block that will be used to receive/accept/decline network challenges. Defaults to nil in which the SDK will use the default OS authentication methods for challenges. It should have the following argument signature: (challenge: URLAuthenticationChallenge, completionHandler: (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) -> Void. See Apple’s documentation for more for details.

  • Update the authentication callback.

    Declaration

    Swift

    static public func updateAuthentication(_ authentication: ((URLAuthenticationChallenge,
                                                         (URLSession.AuthChallengeDisposition,
                                                          URLCredential?) -> Void) -> Void)?)

    Parameters

    authentication

    A callback block that will be used to receive/accept/decline network challenges. Defaults to nil in which the SDK will use the default OS authentication methods for challenges. It should have the following argument signature: (challenge: URLAuthenticationChallenge, completionHandler: (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) -> Void. See Apple’s documentation for more for details.

  • Delete the Parse iOS Objective-C SDK Keychain from the device.

    Note

    ParseSwift uses a different Keychain. After migration, the iOS Objective-C SDK Keychain is no longer needed.

    Warning

    The keychain cannot be recovered after deletion.

    Declaration

    Swift

    public static func deleteObjectiveCKeychain() throws
  • Manually remove all stored cache.

    Note

    The OS typically handles this automatically.

    Declaration

    Swift

    public static func clearCache()