I'm building a React Native app using Expo and managing subscriptions with the Superwall SDK. I can successfully retrieve the user's subscription status with the following code:
Superwall.shared
.getSubscriptionStatus()
.then((status) => console.log(status));
This gives me the current subscription status (e.g., active, inactive), but I need to determine which specific subscription the user has purchased (e.g., monthly, yearly plan).
How can I retrieve detailed information about the specific subscription plan a user has purchased in React Native (Expo) using the Superwall SDK? Is there a method or approach that allows me to get details such as the plan name, duration, or other relevant information about the subscription?
What I’ve Tried:
I tried using Superwall.shared.getUserAttributes()
to retrieve additional details, but it didn't return any useful data related to the subscription plan.
You can extend the SuperwallDelegate
and use its handleSuperwallEvent(eventInfo:)
function to get the product id of the purchased product from the transactionComplete
event which is fired when a user completes a transaction. Here's an example of how to do this:
export class MySuperwallDelegate extends SuperwallDelegate {
handleSuperwallEvent(eventInfo: SuperwallEventInfo) {
switch (eventInfo.event.type) {
case EventType.transactionComplete:
const productId = eventInfo.event.product.productIdentifier;
// Do something with the purchased product id
default:
break;
}
}
// Other methods here
}
const delegate = new MySuperwallDelegate();
Superwall.shared.setDelegate(delegate);
Hope that helps!