Subscriptions

The subscription services APIs provide functionality to manage subscriptions, assign devices, check free trial eligibility, preview activation, and retrieve subscription pricing details.

Pre-requisite: The user has to be signed in to perform the following operations.


Get Subscriptions

To fetch all subscriptions associated with a space, The following method can be used:

  • spaceId (Required): The space ID of the User.
Factory.subscriptionService.getSubscriptions(
        spaceId: String
    ) -> IVPublisher<[SubscriptionDataModel]>

Manage Subscribed Devices

To associate or updates devices linked to a subscription, The following method can be used:

  • subscriptionId (Required): The ID of the subscription.
  • deviceIds (Required): SubscribeDeviceRequest(deviceIds:) — the full list of devices the subscription should cover; it replaces the current assignment.
Factory.subscriptionService.manageSubscribedDevices(
        subscriptionId: String,
        deviceIds: SubscribeDeviceRequest
) -> IVPublisher<Void>

Check Free Trial

To check whether a product is eligible for a free trial, The following method can be used:

  • productId (Required): A ProductType raw value — HomeSecurity, Baby, Pet, Bird or Trail.
Factory.subscriptionService.checkFreeTrial(
        productId: String
    ) -> IVPublisher<FreeTrialResponse>

Cancel Subscription

To cancel an active subscription, The following method can be used:

  • subscriptionId (Required): The ID of the subscription.
Factory.subscriptionService.cancelSubscription(
        subscriptionId: String
    ) -> IVPublisher<Void>

Activate Subscription Preview

To activate subscription preview, The following method can be used:

  • spaceId (required): The id of the space.
  • request (required): SubscriptionPreviewRequest(skuId:) — the SKU to preview.
Factory.subscriptionService.activateSubscriptionPreview(
        spaceId: String,
        request: SubscriptionPreviewRequest
    ) -> IVPublisher<Void>

Get Subscription Prices

To fetch pricing preview for subscription products, The following method can be used:

  • country (required): Country code for localized pricing.
  • productIds (required): List of product identifiers.
  • skuCategories (required): SKU category for filtering subscription pricing — SkuCategory.ai, .combo or .data.
Factory.subscriptionService.getSubscriptionPrices(
        country: String,
        productIds: [String],
        skuCategories: SkuCategory
    ) -> IVPublisher<[SubscriptionPricePreviewResponse]>

Get Grace Subscriptions

To fetch the subscriptions of a space that have expired but are still inside their grace period, The following method can be used:

  • spaceId (Required): The space ID of the User.
Factory.spaceService.getGraceSubscription(spaceId: String) -> IVPublisher<[GraceSubscriptionModel]>

GraceSubscriptionModel carries id, productId and a status string; map it with GraceType(rawValue:)"Grace" for a lapsed paid plan still inside its grace period, "TrialOverdue" (.trailOverdue) for an expired trial. See Types Reference.