chirag04 / react-native-in-app-utils

A react-native wrapper for handling in-app payments
MIT License
890 stars 185 forks source link

The products returns an empty Array [] ? #84

Closed Asterism1985 closed 7 years ago

Asterism1985 commented 7 years ago

Hi,

Any resolution to this issue? I'm seeing the same thing.... The products returns an empty Array [].

RCT_EXPORT_METHOD(loadProducts:(NSArray )productIdentifiers callback:(RCTResponseSenderBlock)callback) { if([SKPaymentQueue canMakePayments]){ SKProductsRequest productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithArray:productIdentifiers]]; productsRequest.delegate = self; _callbacks[RCTKeyForInstance(productsRequest)] = callback; [productsRequest start]; } else { callback(@[@"not_available"]); } }

In this code, productIdentifiers is always nil value. Why is productIdentifiers empty array []?

chirag04 commented 7 years ago

it's empty array because that's what apple is returning. Make sure your in-app purchases are ready for sale on itunes connect. Also it takes around 24 hrs after your create those in-app purchases on itunes to be available.

Asterism1985 commented 7 years ago

Hi Chirag,

Thanks for your response. My IAPs are ready for sale on iTunesConnect. But I can't get any products on the app. The products returns an empty Array []. Please help me..

        InAppUtils.loadProducts(products, (error, products) => {
            console.log('porducts: ', products);
            if (error !== null) {
                AlertIOS.alert('products error', JSON.stringify(error));
            }
            InAppUtils.purchaseProduct(this.props.data.product_id_app_store, (error, response) => {
                // NOTE for v3.0: User can cancel the payment which will be availble as error object here.
                if (response && response.productIdentifier) {
                    AlertIOS.alert('Purchase Successful', 'Your Transaction ID is ' + response.transactionIdentifier);
                    //unlock store here.
                    AlertIOS.alert('Purchase response', JSON.stringify(response));
                }
                else if (error !== null) {
                    AlertIOS.alert('products purchase', JSON.stringify(error));
                }
                console.log('purchase error: ', error);
                console.log('purchase response: ', response);
            });
        });
TestTitans commented 7 years ago

I have an same issiue. Some stackoverflow post argue that login sandbox test user but ios have bug I do not login icloud&appstore sandbox test user. Normally if user doesnt logged in in app purchase show login dialog but I do not see in this module. so I do not test it? or how can you test it ? I'm allays get products []. Thanks.

camel113 commented 6 years ago

The process to create in app purchase is not really clear. After creating my first in app puchase on iTunes connect the status remained waiting for review. A message from iTunes connect says I must submit a new version of my app to make this in app purchase available... Seems strange. It is not possible to test my in app purchase without submitting a new version of my app?

BenBach commented 6 years ago

@camel113 Hi were you able to resolve this. Would appreciate every help

camel113 commented 6 years ago

@BenBach After waiting few minutes my in app purchase was available for testing within my app even if Apple did not review it.