ParseInstallation

public protocol ParseInstallation : ParseObject

Objects that conform to the ParseInstallation protocol have a local representation of an installation persisted to the Parse cloud. This protocol inherits from the ParseObject protocol, and retains the same functionality of a ParseObject, but also extends it with installation-specific fields and related immutability and validity checks.

A valid ParseInstallation can only be instantiated via current because the required identifier fields are readonly. The timeZone is also a readonly property which is automatically updated to match the device’s time zone when the ParseInstallation is saved, thus these fields might not reflect the latest device state if the installation has not recently been saved.

ParseInstallations which have a valid deviceToken and are saved to the Parse Server can be used to target push notifications. Use setDeviceToken to set the deviceToken properly.

Warning

If the use of badge is desired, it should be retrieved by using UIKit, AppKit, etc. and stored in ParseInstallation.badge before saving/updating the installation.

Warning

Linux developers should set appName, appIdentifier, and appVersion manually as ParseSwift doesn’t have access to Bundle.main.

  • The device type for the ParseInstallation.

    Declaration

    Swift

    var deviceType: String? { get set }
  • The installationId for the ParseInstallation.

    Declaration

    Swift

    var installationId: String? { get set }
  • The device token for the ParseInstallation.

    Declaration

    Swift

    var deviceToken: String? { get set }
  • The badge for the ParseInstallation.

    Declaration

    Swift

    var badge: Int? { get set }
  • The name of the time zone for the ParseInstallation.

    Declaration

    Swift

    var timeZone: String? { get set }
  • The channels for the ParseInstallation.

    Declaration

    Swift

    var channels: [String]? { get set }
  • The application name for the ParseInstallation.

    Declaration

    Swift

    var appName: String? { get set }
  • The application identifier for the ParseInstallation.

    Declaration

    Swift

    var appIdentifier: String? { get set }
  • The application version for the ParseInstallation.

    Declaration

    Swift

    var appVersion: String? { get set }
  • The sdk version for the ParseInstallation.

    Declaration

    Swift

    var parseVersion: String? { get set }
  • The locale identifier for the ParseInstallation.

    Declaration

    Swift

    var localeIdentifier: String? { get set }

Async/Await

  • fetch(includeKeys:options:) Extension method, asynchronous

    Fetches the ParseInstallation aynchronously with the current data from the server and sets an error if one occurs.

    Throws

    An error of type ParseError.

    Important

    If an object fetched has the same objectId as current, it will automatically update the current.

    Note

    The default cache policy for this method is .reloadIgnoringLocalCacheData. If a developer desires a different policy, it should be inserted in options.

    Declaration

    Swift

    func fetch(includeKeys: [String]? = nil,
               options: API.Options = []) async throws -> Self

    Parameters

    includeKeys

    The name(s) of the key(s) to include that are ParseObjects. Use ["*"] to include all keys. This is similar to include and includeAll for Query.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    Returns saved ParseInstallation.

  • save(ignoringCustomObjectIdConfig:options:) Extension method, asynchronous

    Saves the ParseInstallation asynchronously.

    Throws

    An error of type ParseError.

    Important

    If an object saved has the same objectId as current, it will automatically update the current.

    Warning

    If you are using ParseConfiguration.isAllowingCustomObjectIds = true and plan to generate all of your objectId‘s on the client-side then you should leave ignoringCustomObjectIdConfig = false. Setting ParseConfiguration.isAllowingCustomObjectIds = true and ignoringCustomObjectIdConfig = true means the client will generate objectId’s and the server will generate an objectId only when the client does not provide one. This can increase the probability of colliiding objectId’s as the client and server objectId’s may be generated using different algorithms. This can also lead to overwriting of ParseObject’s by accident as the client-side checks are disabled. Developers are responsible for handling such cases.

    Note

    The default cache policy for this method is .reloadIgnoringLocalCacheData. If a developer desires a different policy, it should be inserted in options.

    Declaration

    Swift

    func save(ignoringCustomObjectIdConfig: Bool = false,
              options: API.Options = []) async throws -> Self

    Parameters

    ignoringCustomObjectIdConfig

    Ignore checking for objectId when ParseConfiguration.isAllowingCustomObjectIds = true to allow for mixed objectId environments. Defaults to false.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    Returns saved ParseInstallation.

  • create(options:) Extension method, asynchronous

    Creates the ParseInstallation asynchronously.

    Throws

    An error of type ParseError.

    Declaration

    Swift

    func create(options: API.Options = []) async throws -> Self

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    Returns saved ParseInstallation.

  • replace(options:) Extension method, asynchronous

    Replaces the ParseInstallation asynchronously.

    Throws

    An error of type ParseError.

    Important

    If an object replaced has the same objectId as current, it will automatically replace the current.

    Declaration

    Swift

    func replace(options: API.Options = []) async throws -> Self

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    Returns saved ParseInstallation.

  • delete(options:) Extension method, asynchronous

    Deletes the ParseInstallation asynchronously.

    Throws

    An error of type ParseError.

    Important

    If an object deleted has the same objectId as current, it will automatically update the current.

    Declaration

    Swift

    func delete(options: API.Options = []) async throws

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    Returns saved ParseInstallation.

Combine

  • Fetches the ParseInstallation aynchronously with the current data from the server and sets an error if one occurs. Publishes when complete.

    Important

    If an object fetched has the same objectId as current, it will automatically update the current.

    Note

    The default cache policy for this method is .reloadIgnoringLocalCacheData. If a developer desires a different policy, it should be inserted in options.

    Declaration

    Swift

    func fetchPublisher(includeKeys: [String]? = nil,
                        options: API.Options = []) -> Future<Self, ParseError>

    Parameters

    includeKeys

    The name(s) of the key(s) to include that are ParseObjects. Use ["*"] to include all keys. This is similar to include and includeAll for Query.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

  • Saves the ParseInstallation asynchronously and publishes when complete.

    Important

    If an object saved has the same objectId as current, it will automatically update the current.

    Warning

    If you are using ParseConfiguration.isAllowingCustomObjectIds = true and plan to generate all of your objectId‘s on the client-side then you should leave ignoringCustomObjectIdConfig = false. Setting ParseConfiguration.isAllowingCustomObjectIds = true and ignoringCustomObjectIdConfig = true means the client will generate objectId’s and the server will generate an objectId only when the client does not provide one. This can increase the probability of colliiding objectId’s as the client and server objectId’s may be generated using different algorithms. This can also lead to overwriting of ParseObject’s by accident as the client-side checks are disabled. Developers are responsible for handling such cases.

    Note

    The default cache policy for this method is .reloadIgnoringLocalCacheData. If a developer desires a different policy, it should be inserted in options.

    Declaration

    Swift

    func savePublisher(ignoringCustomObjectIdConfig: Bool = false,
                       options: API.Options = []) -> Future<Self, ParseError>

    Parameters

    ignoringCustomObjectIdConfig

    Ignore checking for objectId when ParseConfiguration.isAllowingCustomObjectIds = true to allow for mixed objectId environments. Defaults to false.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

  • createPublisher(options:) Extension method

    Creates the ParseInstallation asynchronously and publishes when complete.

    Declaration

    Swift

    func createPublisher(options: API.Options = []) -> Future<Self, ParseError>

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

  • replacePublisher(options:) Extension method

    Replaces the ParseInstallation asynchronously and publishes when complete.

    Important

    If an object replaced has the same objectId as current, it will automatically replace the current.

    Declaration

    Swift

    func replacePublisher(options: API.Options = []) -> Future<Self, ParseError>

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

  • deletePublisher(options:) Extension method

    Deletes the ParseInstallation asynchronously and publishes when complete.

    Important

    If an object deleted has the same objectId as current, it will automatically update the current.

    Declaration

    Swift

    func deletePublisher(options: API.Options = []) -> Future<Void, ParseError>

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

Default Implementations

  • className Extension method

    Declaration

    Swift

    static var className: String { get }
  • mergeParse(with:) Extension method

    Declaration

    Swift

    func mergeParse(with object: Self) throws -> Self
  • merge(with:) Extension method

    Declaration

    Swift

    func merge(with object: Self) throws -> Self

Convenience

  • setDeviceToken(_:) Extension method

    Sets the device token string property from an Data-encoded token.

    Declaration

    Swift

    public mutating func setDeviceToken(_ data: Data)

    Parameters

    data

    A token that identifies the device.

Current Installation Support

  • current Extension method

    Gets/Sets properties of the current installation in the Keychain.

    Declaration

    Swift

    internal(set) static var current: Self? { get set }

    Return Value

    Returns a ParseInstallation that is the current device. If there is none, returns nil.

Fetchable

  • fetch(includeKeys:options:) Extension method

    Fetches the ParseInstallation synchronously with the current data from the server and sets an error if one occurs.

    Throws

    An error of ParseError type.

    Important

    If an object fetched has the same objectId as current, it will automatically update the current.

    Note

    The default cache policy for this method is .reloadIgnoringLocalCacheData. If a developer desires a different policy, it should be inserted in options.

    Declaration

    Swift

    public func fetch(includeKeys: [String]? = nil,
                      options: API.Options = []) throws -> Self

    Parameters

    includeKeys

    The name(s) of the key(s) to include that are ParseObjects. Use ["*"] to include all keys. This is similar to include and includeAll for Query.

    options

    A set of header options sent to the server. Defaults to an empty set.

  • Fetches the ParseInstallation asynchronously and executes the given callback block.

    Important

    If an object fetched has the same objectId as current, it will automatically update the current.

    Note

    The default cache policy for this method is .reloadIgnoringLocalCacheData. If a developer desires a different policy, it should be inserted in options.

    Declaration

    Swift

    public func fetch(
        includeKeys: [String]? = nil,
        options: API.Options = [],
        callbackQueue: DispatchQueue = .main,
        completion: @escaping (Result<Self, ParseError>) -> Void
    )

    Parameters

    includeKeys

    The name(s) of the key(s) to include that are ParseObjects. Use ["*"] to include all keys. This is similar to include and includeAll for Query.

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    The block to execute when completed. It should have the following argument signature: (Result<Self, ParseError>).

Savable

  • save(options:) Extension method

    Saves the ParseInstallation synchronously and throws an error if there’s an issue.

    Throws

    An error of type ParseError.

    Important

    If an object saved has the same objectId as current, it will automatically update the current.

    Declaration

    Swift

    public func save(options: API.Options = []) throws -> Self

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    Returns saved ParseInstallation.

  • Saves the ParseInstallation synchronously and throws an error if there’s an issue.

    Throws

    An error of type ParseError.

    Important

    If an object saved has the same objectId as current, it will automatically update the current.

    Warning

    If you are using ParseConfiguration.isAllowingCustomObjectIds = true and plan to generate all of your objectId‘s on the client-side then you should leave ignoringCustomObjectIdConfig = false. Setting ParseConfiguration.isAllowingCustomObjectIds = true and ignoringCustomObjectIdConfig = true means the client will generate objectId’s and the server will generate an objectId only when the client does not provide one. This can increase the probability of colliding objectId’s as the client and server objectId’s may be generated using different algorithms. This can also lead to overwriting of ParseObject’s by accident as the client-side checks are disabled. Developers are responsible for handling such cases.

    Note

    The default cache policy for this method is .reloadIgnoringLocalCacheData. If a developer desires a different policy, it should be inserted in options.

    Declaration

    Swift

    public func save(ignoringCustomObjectIdConfig: Bool,
                     options: API.Options = []) throws -> Self

    Parameters

    ignoringCustomObjectIdConfig

    Ignore checking for objectId when ParseConfiguration.isAllowingCustomObjectIds = true to allow for mixed objectId environments. Defaults to false.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    Returns saved ParseInstallation.

  • Saves the ParseInstallation asynchronously and executes the given callback block.

    Important

    If an object saved has the same objectId as current, it will automatically update the current.

    Warning

    If you are using ParseConfiguration.isAllowingCustomObjectIds = true and plan to generate all of your objectId‘s on the client-side then you should leave ignoringCustomObjectIdConfig = false. Setting ParseConfiguration.isAllowingCustomObjectIds = true and ignoringCustomObjectIdConfig = true means the client will generate objectId’s and the server will generate an objectId only when the client does not provide one. This can increase the probability of colliding objectId’s as the client and server objectId’s may be generated using different algorithms. This can also lead to overwriting of ParseObject’s by accident as the client-side checks are disabled. Developers are responsible for handling such cases.

    Note

    The default cache policy for this method is .reloadIgnoringLocalCacheData. If a developer desires a different policy, it should be inserted in options.

    Declaration

    Swift

    public func save(
        ignoringCustomObjectIdConfig: Bool = false,
        options: API.Options = [],
        callbackQueue: DispatchQueue = .main,
        completion: @escaping (Result<Self, ParseError>) -> Void
    )

    Parameters

    ignoringCustomObjectIdConfig

    Ignore checking for objectId when ParseConfiguration.isAllowingCustomObjectIds = true to allow for mixed objectId environments. Defaults to false.

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    The block to execute. It should have the following argument signature: (Result<Self, ParseError>).

  • Creates the ParseInstallation asynchronously and executes the given callback block.

    Note

    The default cache policy for this method is .reloadIgnoringLocalCacheData. If a developer desires a different policy, it should be inserted in options.

    Declaration

    Swift

    public func create(
        options: API.Options = [],
        callbackQueue: DispatchQueue = .main,
        completion: @escaping (Result<Self, ParseError>) -> Void
    )

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    The block to execute. It should have the following argument signature: (Result<Self, ParseError>).

  • Replaces the ParseInstallation asynchronously and executes the given callback block.

    Important

    If an object replaced has the same objectId as current, it will automatically replace the current.

    Note

    The default cache policy for this method is .reloadIgnoringLocalCacheData. If a developer desires a different policy, it should be inserted in options.

    Declaration

    Swift

    public func replace(
        options: API.Options = [],
        callbackQueue: DispatchQueue = .main,
        completion: @escaping (Result<Self, ParseError>) -> Void
    )

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    The block to execute. It should have the following argument signature: (Result<Self, ParseError>).

Deletable

  • delete(options:) Extension method

    Deletes the ParseInstallation synchronously with the current data from the server and sets an error if one occurs.

    Throws

    An error of ParseError type.

    Important

    If an object deleted has the same objectId as current, it will automatically update the current.

    Note

    The default cache policy for this method is .reloadIgnoringLocalCacheData. If a developer desires a different policy, it should be inserted in options.

    Declaration

    Swift

    public func delete(options: API.Options = []) throws

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

  • Deletes the ParseInstallation asynchronously and executes the given callback block.

    Important

    If an object deleted has the same objectId as current, it will automatically update the current.

    Note

    The default cache policy for this method is .reloadIgnoringLocalCacheData. If a developer desires a different policy, it should be inserted in options.

    Declaration

    Swift

    public func delete(
        options: API.Options = [],
        callbackQueue: DispatchQueue = .main,
        completion: @escaping (Result<Void, ParseError>) -> Void
    )

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    The block to execute when completed. It should have the following argument signature: (Result<Void, ParseError>).