首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >RevenueCat显示价格

RevenueCat显示价格
EN

Stack Overflow用户
提问于 2022-01-02 11:56:56
回答 1查看 125关注 0票数 0

我有以下代码:

代码语言:javascript
复制
function Paywall({ onPress }) {

const getPrice = async () => {
    try {
        const offerings = await Purchases.getOfferings();
        if (offerings.current !== null && offerings.current.availablePackages.length !== 0) {
            console.log("OFFERING");
            console.log(offerings.current.monthly);
        }
    } catch (e) {
        console.log(e);
    }

    return offerings
}

useEffect(() => {
    getPrice()
})

return (
    <View style={styles.container}>
        <View style={styles.priceContainer}>
            <Text style={styles.headerText}>£9.99</Text>
            <Text style={styles.perMonthText}>per month</Text>
        </View>
        <View style={styles.buttonContainer}>
            <TouchableOpacity style={styles.button} onPress={onPress}>
                <Text style={styles.buttonText}>Subscribe for £9.99 / month</Text>
            </TouchableOpacity>
        </View>
    </View>
  );
}

我的日志带回来了:

代码语言:javascript
复制
{"identifier": "$rc_monthly", "offeringIdentifier": "sale", "packageType": "MONTHLY", "product": {"currency_code": "GBP", "description": "All Access", "discounts": null, "identifier": "app_499_1m", "introPrice": {"cycles": null, "period": null, "periodNumberOfUnits": null, "periodUnit": null, "price": null, "priceString": null}, "intro_price": null, "intro_price_cycles": null, "intro_price_period": null, "intro_price_period_number_of_units": null, "intro_price_period_unit": null, "intro_price_string": null, "price": 11.99, "price_string": "£11.99", "title": "All Access (App NAME)"}}

如何在我的price_string中显示<Text>

代码语言:javascript
复制
<Text style={styles.headerText}>£9.99</Text>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-01-02 12:17:17

您必须确保定义了它,然后访问密钥:

代码语言:javascript
复制
<Text style={styles.headerText}>{offerings?.current?.monthly?.product?.price_string}</Text>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70555744

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档