Skip to main content

I’m using Ionic with Capacitor.

The RevenueCat documentation recommends using a cordova plugin, but Ionic has been in the process of migrating away from Capacitor for the past few years, and this is now the only Cordova plugin in my app.

There’s already a capacitor plugin on github but I was wondering if there are any plans to release an official Capacitor plugin as well.

Hi @anuradha-a4da7c, we created this plugin using Capacitor 5 directly so we don’t have a version using Capacitor 4.x. What issues are you finding with Capacitor 4.x? Also, is it possible for you to update to Capacitor 5?


Hi @anuradha-a4da7c, we created this plugin using Capacitor 5 directly so we don’t have a version using Capacitor 4.x. What issues are you finding with Capacitor 4.x? Also, is it possible for you to update to Capacitor 5?

Hi @toni-rico - I could not install the npm package due to its peer dependency of Capacitor 5.x. However, I force installed to see how it works with Capacitor 4.x. Currently testing the implementation, so far seems to work well. If we run into issues, will keep you posted. 

Thanks for your response.


I have my Capacitor app built and working on IOS and Android. I’ve recently switched to using capacitor-purchases for my subscriptions. it’s the same codebase that I use for the both IOS and Android versions. I have my subscriptions woking in IOS, and I assumed in the RevenueCat dashboard it would be possible to just add in some extra details to get it working with Android aswell, but it seems like I have to set up a whole separate app, is this correct?


Hi @IrishCoder88, that’s correct. You need to create an android app inside the same project in the RC dashboard for each platform. You can check more info here: https://www.revenuecat.com/docs/projects#adding-an-app-to-a-project and https://www.revenuecat.com/docs/android-products


I’ve been using this the purchases-capacitor plugin for the past month or so. It’s working fine for my iOS and Android subscriptions, and for my one-time-purchases in iOS. In Android however, it can’t fetch my one-time purchases. They are set up correctly in RevenueCat and Google Play Console, they used to work fine with a different in-app-purchase library.

It’s the same code that works for iOS, so I’m not sure why it’s not working. Below is my code,  I was using the alerts to show the product data on the screen when testing with an actual device. It returns the info for both my subscriptions, but not for ‘androidpremium’ or ‘lifetimeandroid’. They just aren’t in the array at all, there are no error messages about it.

I’ve checked the debug logs and there is just no mention of any issues.
 

async mounted () {

const deviceInfo = await Device.getInfo();

this.isIOS = deviceInfo.platform === 'ios';

this.isAndroid = deviceInfo.platform === 'android'

await configurePurchases();

Purchases.getProducts({ productIdentifiers: u'premiumsubscribersm', 'premiumsubscribersy', 'Premium1988', 'androidpremium', 'lifetimeandroid'] })

.then((products) => {

alert('Fetched products successfully: ' + JSON.stringify(products));

this.$set(this, 'products', products.products); // Ensure reactivity

alert('Fetched products successfully: ' + JSON.stringify(products));

})

 


Hi @IrishCoder88, you need to pass in the `type` parameter as part of the `GetProductOptions` when trying to fetch one-time purchases: https://github.com/RevenueCat/purchases-capacitor?tab=readme-ov-file#getproductoptions.

So instead of:

Purchases.getProducts({ productIdentifiers:  'onetimeproduct'] })

You will need to do:

Purchases.getProducts({ 
productIdentifiers: 'onetimeproduct'],
type: PRODUCT_CATEGORY.NON_SUBSCRIPTION
})

This is due to some limitations in how the system currently works in Android. This parameter is ignored in iOS as mentioned in the documentation.

Hope that helps! Please let us know if you have any other issues!


Ok, so I’ve managed to fetch the product now. But when I try to purchase it, I get to this line, which works with all my other products. It’s only the android one-time purchase where it doesn’t work.

await Purchases.purchaseStoreProduct({ product: 'androidpremium' });

But it then throws the error ‘missing product parameter’, and the purchase doesn’t go through.


Hi @IrishCoder88,

You need to pass the whole object returned by `getProducts` into the `purchaseStoreProduct`. So the code would look like:

const products = await Purchases.getProducts({ 
productIdentifiers: ['onetimeproduct'],
type: PRODUCT_CATEGORY.NON_SUBSCRIPTION
}).products;
// Remember to account for the product not being found!
const purchaseResult = await Purchase.purchaseStoreProduct({ product: products[0] });

Lmk if you still have any issues!


I’ve got that working now. Thanks @toni-rico


Hey everyone, 

 

Anyone got it to work with Capacitor 6 recently released? 

I just did some people forces capacitor 4, so I’m gonna try to force the install with Capacitor 6. I’ll give feedback when I have some.


Hi @Undisconnected,

We released a version version 8.0.0-beta.2 with support for Capacitor 6. We plan to release this version as stable soon

Please let us know if you have any issues with that!


@toni-rico Thanks for this, sorry, I had to work on something else for a while. I’d be interested to test it, but I have no idea how to include this in my project.

I generally go with npm i @revenuecat/purchases-capacitor 

It seems in the package you are using typescript vs Js in the npm package. Not sure if that’s gonna be a problem. 

I’m gonna test to use --legacy-peer-deps with the current version for now, but I’m happy to test the beta if you explain a bit more how to test it. 

 

Thanks 

 

 

 


Hi @Undisconnected 

You should be able to specify the exact version you want to install, like

npm i @revenuecat/purchases-capacitor@8.0.0-beta.3

 


I just saw that you guys released the version 8.0.0 in prod.Si I installed this one instead of the beta and have the same problem. 

I need to do a release tomorrow, I would love to have that working.

 

Any help? Thanks a lot

 

 


Hi @Undisconnected,

That seems like a different issue. From that error message, it seems that your minimum deployment target might be lower than the one compatible for the SDK. Was this issue happening in a previous version of the SDK? Also, what minimum version are you using in your app? For reference, this is the Podfile in our sample app: https://github.com/RevenueCat/purchases-capacitor/blob/7cd4c6343f194d109c14fc1314914a6c64e5ff36/example/purchase-tester/ios/App/Podfile#L3. And you can also check the deployment version if you open your project in Xcode:  

Could you let us know your minimum version in those places?


Ok so I manage to reinstall the version that was working for my app before, and everything works fine again. ("@revenuecat/purchases-capacitor": "^7.5.10"). I just had to force it using the --force with npm. 

The minimum version is iOS 13.0 in xCode.

 

Are you suppose to do anything about Pods when you change version of the plugin? 

 

 

 

 


Hi @Undisconnected, release 8.0.0 only updates the Capacitor version to v6, and those release notes don’t indicate an increase in in min deployment target but a requirement in xcode version. You might need to update your xcode as well? Also, it might be helpful if you can post your Podfile to try to reproduce. 


Reply