You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native Android端内购功能报错求助(iOS端正常)

React Native 应用内购iOS端正常,Android真机订阅购买报错

我的React Native应用内购功能在iOS端运行完全正常,但在Android真机上执行订阅购买时出现报错,报错截图如下:

Android内购报错截图

以下是我实现订阅购买的核心代码:

const handleBuySubscription = async (productId, planType) => {
    setIsRequestInProgress(true);
    try {
      const offer = subscriptionOffers[productId]?.[planType];
      console.log("Selected Product ID:", productId);
      console.log("Selected Plan Type:", planType);
      console.log("Offer:", offer);
      if (Platform.OS === 'android' && offer && offer.basePlanId && offer.offerId) {
        try {
          await requestSubscription({
            sku: productId,
            subscriptionOffers: [{ basePlanId: offer.basePlanId, offerId: offer.offerId }],
          });
        } catch (error) {
          console.error("Error during requestSubscription:", error);
        }
      } else if (Platform.OS === 'ios') {
        await requestSubscription({ sku: productId });
      } else {
        throw new Error("Invalid subscription offer details.");
      }

      setLoading(false);
      setIsRequestInProgress(false);
    } catch (error) {
      setLoading(false);
      setIsRequestInProgress(false);
      if (error instanceof PurchaseError) {
        console.error(`[${error.code}]: ${error.message}`, error);
      } else {
        console.error("handleBuySubscription", error);
      }
    }
  };

我已经尝试过替换成requestPurchase方法调用,但问题依然存在。想问问有没有其他开发者遇到过相同的问题?

内容的提问来源于stack exchange,提问作者Dev07

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.21 01:50:58