Skip to content

Commit 6646ec4

Browse files
authored
Add Cordova VC docs (#1064)
1 parent 215886d commit 6646ec4

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Fetch virtual currencies
2+
Purchases.getVirtualCurrencies(
3+
virtualCurrencies => {
4+
// TODO: Handle virtual currencies
5+
},
6+
error => {
7+
// TODO: Handle error
8+
}
9+
);
10+
11+
// Get the details of a specific virtual currency
12+
const virtualCurrency = virtualCurrencies.all['<virtual_currency_code>'];
13+
const balance = virtualCurrency.balance;
14+
const name = virtualCurrency.name;
15+
const code = virtualCurrency.code;
16+
17+
// Keep in mind that serverDescription may be null if no description was provided
18+
// in the RevenueCat dashboard
19+
const serverDescription = virtualCurrency.serverDescription;
20+
21+
// Iterate through all virtual currencies
22+
for (const [virtualCurrencyCode, virtualCurrency] of Object.entries(virtualCurrencies.all)) {
23+
console.log(`${virtualCurrency.code}: ${virtualCurrency.balance}`);
24+
}

docs/offerings/virtual-currency.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ import fetchVCBalancesFlutter from "@site/code_blocks/virtual-currency/vc-balanc
111111
import fetchVCBalancesCapacitor from "@site/code_blocks/virtual-currency/virtual-currency-balance-capacitor.ts?raw";
112112
import fetchVCBalancesUnity from "@site/code_blocks/virtual-currency/vc-balance-unity.cs?raw";
113113
import fetchVCBalancesKMP from "@site/code_blocks/virtual-currency/vc-balance-sdk-kmp.kt?raw";
114+
import fetchVCBalancesCordova from "@site/code_blocks/virtual-currency/vc-balance-sdk-cordova.ts?raw";
114115

115116
Fetching virtual currency balances is supported in the following SDK versions:
116117

@@ -123,6 +124,7 @@ Fetching virtual currency balances is supported in the following SDK versions:
123124
| Capacitor SDK | 11.1.0+ |
124125
| Unity SDK | 8.1.0+ |
125126
| KMP SDK | 2.1.0+16.2.0+ |
127+
| Cordova SDK | 7.1.0+ |
126128

127129
You can use the `virtualCurrencies()` function to retrieve a customer's balance. The function returns a `VirtualCurrencies` object, which includes the customer's balances along with each virtual currency's metadata.
128130

@@ -168,6 +170,11 @@ You can use the `virtualCurrencies()` function to retrieve a customer's balance.
168170
title: "Kotlin Multiplatform",
169171
content: fetchVCBalancesKMP,
170172
},
173+
{
174+
type: 'cordova',
175+
title: "Cordova",
176+
content: fetchVCBalancesCordova,
177+
},
171178
]}
172179
/>
173180

0 commit comments

Comments
 (0)