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 }

Fetchable - 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.

    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.

Savable - Combine

  • savePublisher(options:) Extension method

    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.

    Declaration

    Swift

    func savePublisher(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.

Deletable - Combine

  • 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 }

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

    public 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.

    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.

    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 asynchronously and executes the given callback block.

    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 = [],
        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.

    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.

    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>).