最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

xcode - React-Native-Iap not fetching subscriptions from StoreKit configuration file - Stack Overflow

programmeradmin6浏览0评论

I am working on a React Native project using react-native-iap to fetch in-app subscriptions from a StoreKit configuration file in a development environment. However, despite configuring the StoreKit file correctly, getSubscriptions() returns undefined for subscriptions.

Setup Xcode Version: 16.0 (Build 16A242d)
StoreKit File: Selected in the scheme for the project
Subscription Product ID: com.chatreal.ai.subscription.premium_monthly

StoreKit Configuration File:

{
  "appPolicies" : {
    "eula" : "",
    "policies" : [
      {
        "locale" : "en_US",
        "policyText" : "",
        "policyURL" : ""
      }
    ]
  },
  "identifier" : "4D497EE8",
  "nonRenewingSubscriptions" : [

  ],
  "products" : [

  ],
  "settings" : {
    "_failTransactionsEnabled" : false,
    "_storeKitErrors" : [
      {
        "current" : null,
        "enabled" : false,
        "name" : "Load Products"
      },
      {
        "current" : null,
        "enabled" : false,
        "name" : "Purchase"
      },
      {
        "current" : null,
        "enabled" : false,
        "name" : "Verification"
      },
      {
        "current" : null,
        "enabled" : false,
        "name" : "App Store Sync"
      },
      {
        "current" : null,
        "enabled" : false,
        "name" : "Subscription Status"
      },
      {
        "current" : null,
        "enabled" : false,
        "name" : "App Transaction"
      },
      {
        "current" : null,
        "enabled" : false,
        "name" : "Manage Subscriptions Sheet"
      },
      {
        "current" : null,
        "enabled" : false,
        "name" : "Refund Request Sheet"
      },
      {
        "current" : null,
        "enabled" : false,
        "name" : "Offer Code Redeem Sheet"
      }
    ]
  },
  "subscriptionGroups" : [
    {
      "id" : "D98471C1",
      "localizations" : [

      ],
      "name" : "com.chatreal.ai.subscription",
      "subscriptions" : [
        {
          "adHocOffers" : [

          ],
          "codeOffers" : [

          ],
          "displayPrice" : "0.99",
          "familyShareable" : false,
          "groupNumber" : 1,
          "internalID" : "3D229DD1",
          "introductoryOffer" : null,
          "localizations" : [
            {
              "description" : "",
              "displayName" : "",
              "locale" : "en_US"
            }
          ],
          "productID" : "com.chatreal.ai.subscription.premium_monthly",
          "recurringSubscriptionPeriod" : "P1M",
          "referenceName" : "Monthly Premium Subscription",
          "subscriptionGroupID" : "D98471C1",
          "type" : "RecurringSubscription",
          "winbackOffers" : [

          ]
        }
      ]
    }
  ],
  "version" : {
    "major" : 4,
    "minor" : 0
  }
}

React Native Code to Fetch Subscriptions I am using react-native-iap to fetch the subscriptions:

import { useIAP } from "react-native-iap";
import { useEffect, useState } from "react";
import { Platform } from "react-native";

const subscriptionSkus = Platform.select({
  ios: ["com.chatreal.ai.subscription.premium_monthly"],
});

export const Subscriptions = () => {
  const { subscriptions, getSubscriptions, connected } = useIAP({ useStorekitTest: true });
  
  useEffect(() => {
    const fetchSubscriptions = async () => {
      try {
        console.log("Running on IOS Simulator - Using Storekit File");
        const subs = await getSubscriptions({ skus: subscriptionSkus });
        console.log("Fetched Subscriptions:", subs);
      } catch (error) {
        console.error("Error fetching subscriptions", error);
      }
    };

    if (connected) {
      fetchSubscriptions();
    }
  }, [connected]);

  return null;
};

Issue The subscription (subscriptions) returns undefined when calling getSubscriptions(). The subscription appears correctly in the StoreKit configuration file. The scheme is properly set to use the StoreKit file.

App Store Connect

XCode

Subscriptions Products

Paid Apps Status

发布评论

评论列表(0)

  1. 暂无评论