PFInstallation


@interface PFInstallation : PFObject <PFSubclassing>

A Parse Framework Installation Object that is a local representation of an installation persisted to the Parse cloud. This class is a subclass of a PFObject, and retains the same functionality of a PFObject, but also extends it with installation-specific fields and related immutability and validity checks.

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

PFInstallation objects which have a valid deviceToken and are saved to the Parse cloud can be used to target push notifications.

  • Gets the currently-running installation from disk and returns an instance of it.

    If this installation is not stored on disk this method will create a new PFInstallation with deviceType and installationId fields set to those of the current installation.

    @result Returns a PFInstallation that represents the currently-running installation if it could be loaded from disk, otherwise - nil.

    Declaration

    Objective-C

    + (nullable instancetype)currentInstallation;

    Swift

    class func current() -> Self?
  • Asynchronously loads the currently-running installation from disk and returns an instance of it.

    If this installation is not stored on disk this method will create a new PFInstallation with deviceType and installationId fields set to those of the current installation.

    @result Returns a task that incapsulates the current installation.

    Declaration

    Objective-C

    + (nonnull BFTask<__kindof PFInstallation *> *)
        getCurrentInstallationInBackground;

    Swift

    class func getCurrentInstallationInBackground() -> BFTask
  • The device type for the PFInstallation.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic) NSString *_Nonnull deviceType;

    Swift

    var deviceType: String { get }
  • The installationId for the PFInstallation.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic) NSString *_Nonnull installationId;

    Swift

    var installationId: String { get }
  • The device token for the PFInstallation.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) NSString *deviceToken;

    Swift

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

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) NSInteger badge;

    Swift

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

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic, nullable) NSString *timeZone;

    Swift

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

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) NSArray<NSString *> *channels;

    Swift

    var channels: [String]? { get set }
  • Sets the device token string property from an NSData-encoded token.

    Declaration

    Objective-C

    - (void)setDeviceTokenFromData:(nullable NSData *)deviceTokenData;

    Swift

    func setDeviceTokenFrom(_ deviceTokenData: Data?)

    Parameters

    deviceTokenData

    A token that identifies the device.

  • Creates a PFQuery for PFInstallation objects.

    Only the following types of queries are allowed for installations:

    • [query getObjectWithId:<value>]
    • [query whereKey:@"installationId" equalTo:<value>]
    • [query whereKey:@"installationId" matchesKey:<key in query> inQuery:<query>]

    You can add additional query conditions, but one of the above must appear as a top-level AND clause in the query.

    Declaration

    Objective-C

    + (nullable PFQuery *)query;

    Swift

    class func query() -> PFQuery?