📦 SwiftyLaunch Modules
⚙️ BackendKit
InAppPurchaseKit Integration

InAppPurchaseKit Integration in BackendKit

InAppPurchaseKit Integration

Access user subscription information using our pre-built InAppPurchaseKit functions.

Basic Usage

Import InAppPurchaseKit

To use InAppPurchaseKit functions, you first need to include InAppPurchases in your file.

import * as InAppPurchases from "./InAppPurchaseKit/InAppPurchases";

Function Definition

Now you can check if a user has premium your backend code using the doesUserHavePremium function.

InAppPurchasesInAppPurchases.ts
export async function doesUserHavePremium(userID: string): Promise<boolean> {}
  • userID: The ID of the user. Set to be the same as Firebase User ID when the user authenticates on the client-side. Pass RevenueCat User ID if you want to check for a specific user that is not the currently authenticated user.

Usage Example

This examples returns a boolean value indicating if the user has premium or not. (Only for authenticated users)

export const doIHavePremium = onCall(async (request) => {
  let requestingUserID = request.auth?.uid;
 
  if (!requestingUserID) {
    throw new Error("You must be logged in");
  }
 
  return await InA‚ppPurchases.doesUserHavePremium(requestingUserID);
});